mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 19:08:21 +00:00
[sysadmin] Add an option to enable trial account
This commit is contained in:
@@ -37,10 +37,11 @@ from seahub.settings import INIT_PASSWD, SITE_NAME, \
|
||||
from seahub.utils import send_html_email, get_user_traffic_list, get_server_id
|
||||
from seahub.utils.sysinfo import get_platform_name
|
||||
try:
|
||||
from seahub_extra.trialaccount.models import TrialAccount
|
||||
enable_trial_account = True
|
||||
from seahub.settings import ENABLE_TRIAL_ACCOUNT
|
||||
except:
|
||||
enable_trial_account = False
|
||||
ENABLE_TRIAL_ACCOUNT = False
|
||||
if ENABLE_TRIAL_ACCOUNT:
|
||||
from seahub_extra.trialaccount.models import TrialAccount
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -202,7 +203,7 @@ def sys_user_admin(request):
|
||||
|
||||
users = users_plus_one[:per_page]
|
||||
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||
if enable_trial_account:
|
||||
if ENABLE_TRIAL_ACCOUNT:
|
||||
trial_users = TrialAccount.objects.filter(user_or_org__in=[x.email for x in users])
|
||||
else:
|
||||
trial_users = []
|
||||
@@ -551,6 +552,9 @@ def remove_trial(request, user_or_org):
|
||||
Arguments:
|
||||
- `request`:
|
||||
"""
|
||||
if not ENABLE_TRIAL_ACCOUNT:
|
||||
raise Http404
|
||||
|
||||
referer = request.META.get('HTTP_REFERER', None)
|
||||
next = reverse('sys_useradmin') if referer is None else referer
|
||||
|
||||
@@ -874,7 +878,7 @@ def sys_org_admin(request):
|
||||
per_page + 1)
|
||||
orgs = orgs_plus_one[:per_page]
|
||||
|
||||
if enable_trial_account:
|
||||
if ENABLE_TRIAL_ACCOUNT:
|
||||
trial_orgs = TrialAccount.objects.filter(user_or_org__in=[x.org_id for x in orgs])
|
||||
else:
|
||||
trial_orgs = []
|
||||
@@ -1100,7 +1104,7 @@ def user_search(request):
|
||||
|
||||
users = ccnet_threaded_rpc.search_emailusers(email, -1, -1)
|
||||
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
||||
if enable_trial_account:
|
||||
if ENABLE_TRIAL_ACCOUNT:
|
||||
trial_users = TrialAccount.objects.filter(user_or_org__in=[x.email for x in users])
|
||||
else:
|
||||
trial_users = []
|
||||
|
Reference in New Issue
Block a user