mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 03:18:23 +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 import send_html_email, get_user_traffic_list, get_server_id
|
||||||
from seahub.utils.sysinfo import get_platform_name
|
from seahub.utils.sysinfo import get_platform_name
|
||||||
try:
|
try:
|
||||||
from seahub_extra.trialaccount.models import TrialAccount
|
from seahub.settings import ENABLE_TRIAL_ACCOUNT
|
||||||
enable_trial_account = True
|
|
||||||
except:
|
except:
|
||||||
enable_trial_account = False
|
ENABLE_TRIAL_ACCOUNT = False
|
||||||
|
if ENABLE_TRIAL_ACCOUNT:
|
||||||
|
from seahub_extra.trialaccount.models import TrialAccount
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -202,7 +203,7 @@ def sys_user_admin(request):
|
|||||||
|
|
||||||
users = users_plus_one[:per_page]
|
users = users_plus_one[:per_page]
|
||||||
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
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])
|
trial_users = TrialAccount.objects.filter(user_or_org__in=[x.email for x in users])
|
||||||
else:
|
else:
|
||||||
trial_users = []
|
trial_users = []
|
||||||
@@ -551,6 +552,9 @@ def remove_trial(request, user_or_org):
|
|||||||
Arguments:
|
Arguments:
|
||||||
- `request`:
|
- `request`:
|
||||||
"""
|
"""
|
||||||
|
if not ENABLE_TRIAL_ACCOUNT:
|
||||||
|
raise Http404
|
||||||
|
|
||||||
referer = request.META.get('HTTP_REFERER', None)
|
referer = request.META.get('HTTP_REFERER', None)
|
||||||
next = reverse('sys_useradmin') if referer is None else referer
|
next = reverse('sys_useradmin') if referer is None else referer
|
||||||
|
|
||||||
@@ -874,7 +878,7 @@ def sys_org_admin(request):
|
|||||||
per_page + 1)
|
per_page + 1)
|
||||||
orgs = orgs_plus_one[:per_page]
|
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])
|
trial_orgs = TrialAccount.objects.filter(user_or_org__in=[x.org_id for x in orgs])
|
||||||
else:
|
else:
|
||||||
trial_orgs = []
|
trial_orgs = []
|
||||||
@@ -1100,7 +1104,7 @@ def user_search(request):
|
|||||||
|
|
||||||
users = ccnet_threaded_rpc.search_emailusers(email, -1, -1)
|
users = ccnet_threaded_rpc.search_emailusers(email, -1, -1)
|
||||||
last_logins = UserLastLogin.objects.filter(username__in=[x.email for x in users])
|
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])
|
trial_users = TrialAccount.objects.filter(user_or_org__in=[x.email for x in users])
|
||||||
else:
|
else:
|
||||||
trial_users = []
|
trial_users = []
|
||||||
|
Reference in New Issue
Block a user