本文整理汇总了Python中seahub.utils.is_pro_version函数的典型用法代码示例。如果您正苦于以下问题:Python is_pro_version函数的具体用法?Python is_pro_version怎么用?Python is_pro_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_pro_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_group_info
def get_group_info(group_id):
group = ccnet_api.get_group(group_id)
isoformat_timestr = timestamp_to_isoformat_timestr(group.timestamp)
group_info = {
"id": group.id,
"name": group.group_name,
"owner": group.creator_name,
"owner_name": email2nickname(group.creator_name),
"created_at": isoformat_timestr,
"quota": seafile_api.get_group_quota(group_id) if is_pro_version() else 0,
"parent_group_id": group.parent_group_id if is_pro_version() else 0
}
return group_info
示例2: user_number_over_limit
def user_number_over_limit(new_users=0):
logger = logging.getLogger(__name__)
if is_pro_version():
try:
# get license user limit
license_dict = parse_license()
max_users = int(license_dict.get('MaxUsers', 3))
# get active user number
active_db_users = ccnet_api.count_emailusers('DB')
active_ldap_users = ccnet_api.count_emailusers('LDAP')
active_users = active_db_users + active_ldap_users if \
active_ldap_users > 0 else active_db_users
if new_users < 0:
logger.debug('`new_users` must be greater or equal to 0.')
return False
elif new_users == 0:
return active_users >= max_users
else:
return active_users + new_users > max_users
except Exception as e:
logger.error(e)
return False
else:
return False
示例3: populate_user_permissions
def populate_user_permissions(user):
if is_pro_version():
from seahub_extra.auth_extra.utils import populate_user_permissions
populate_user_permissions(user)
else:
# use default user permissions
pass
示例4: get
def get(self, request):
if not is_pro_version():
error_msg = 'Feature disabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# check the date format, should be like '2015-10-10'
start = request.GET.get('start', None)
end = request.GET.get('end', None)
if not check_time_period_valid(start, end):
error_msg = 'start or end date invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# Filtering a DateTimeField with dates won't include items on the last day,
# because the bounds are interpreted as '0am on the given date'.
end = end + ' 23:59:59'
result = []
from seahub_extra.sysadmin_extra.models import UserLoginLog
logs = UserLoginLog.objects.filter(login_date__range=(start, end))
for log in logs:
result.append({
'login_time': datetime_to_isoformat_timestr(log.login_date),
'login_ip': log.login_ip,
'name': email2nickname(log.username),
'email':log.username
})
return Response(result)
示例5: edit_profile
def edit_profile(request):
"""
Show and edit user profile.
"""
username = request.user.username
form_class = DetailedProfileForm
if request.method == 'POST':
form = form_class(request.POST)
if form.is_valid():
form.save(username=username)
messages.success(request, _(u'Successfully edited profile.'))
return HttpResponseRedirect(reverse('edit_profile'))
else:
messages.error(request, _(u'Failed to edit profile'))
else:
profile = Profile.objects.get_profile_by_user(username)
d_profile = DetailedProfile.objects.get_detailed_profile_by_user(
username)
init_dict = {}
if profile:
init_dict['nickname'] = profile.nickname
init_dict['login_id'] = profile.login_id
init_dict['contact_email'] = profile.contact_email
if d_profile:
init_dict['department'] = d_profile.department
init_dict['telephone'] = d_profile.telephone
form = form_class(init_dict)
# common logic
try:
server_crypto = UserOptions.objects.is_server_crypto(username)
except CryptoOptionNotSetError:
# Assume server_crypto is ``False`` if this option is not set.
server_crypto = False
sub_lib_enabled = UserOptions.objects.is_sub_lib_enabled(username)
default_repo_id = UserOptions.objects.get_default_repo(username)
if default_repo_id:
default_repo = seafile_api.get_repo(default_repo_id)
else:
default_repo = None
owned_repos = get_owned_repo_list(request)
owned_repos = filter(lambda r: not r.is_virtual, owned_repos)
return render_to_response('profile/set_profile.html', {
'form': form,
'server_crypto': server_crypto,
"sub_lib_enabled": sub_lib_enabled,
'force_server_crypto': settings.FORCE_SERVER_CRYPTO,
'default_repo': default_repo,
'owned_repos': owned_repos,
'is_pro': is_pro_version(),
'is_ldap_user': is_ldap_user(request.user),
'two_factor_auth_enabled': has_two_factor_auth(),
}, context_instance=RequestContext(request))
示例6: check_file_lock
def check_file_lock(repo_id, file_path, username):
""" Check if file is locked to current user
According to returned value of seafile_api.check_file_lock:
0: not locked
1: locked by other
2: locked by me
-1: error
Return (is_locked, locked_by_me)
"""
if not is_pro_version():
return (False, False)
return_value = seafile_api.check_file_lock(repo_id,
file_path.lstrip('/'), username)
if return_value == 0:
return (False, False)
elif return_value == 1:
return (True , False)
elif return_value == 2:
return (True, True)
else:
raise SearpcError('check file lock error')
示例7: get
def get(self, request):
if not is_pro_version():
error_msg = 'Feature disabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# check the date format, should be like '2015-10-10'
start = request.GET.get('start', None)
end = request.GET.get('end', None)
if not check_time_period_valid(start, end):
error_msg = 'start or end date invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
result = []
events = get_log_events_by_type_and_time('file_audit', start, end)
if events:
for ev in events:
tmp_repo = seafile_api.get_repo(ev.repo_id)
tmp_repo_name = tmp_repo.name if tmp_repo else ''
result.append({
'repo_id': ev.repo_id,
'repo_name': tmp_repo_name,
'time': datetime_to_isoformat_timestr(ev.timestamp),
'etype': ev.etype,
'ip': ev.ip,
'file_path': ev.file_path,
'etype': ev.etype,
'user_name': email2nickname(ev.user),
'user_email': ev.user
})
return Response(result)
示例8: _decorated
def _decorated(view, request, *args, **kwargs):
if not is_pro_version() or not EVENTS_ENABLED:
return api_error(status.HTTP_404_NOT_FOUND, 'Events not enabled.')
start_time = request.GET.get("start", "")
end_time = request.GET.get("end", "")
if not start_time:
error_msg = "Start time can not be empty"
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not end_time:
error_msg = "End time can not be empty"
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
start_time = datetime.datetime.strptime(start_time,
"%Y-%m-%d %H:%M:%S")
except:
error_msg = "Start time %s invalid" % start_time
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
end_time = datetime.datetime.strptime(end_time,
"%Y-%m-%d %H:%M:%S")
except:
error_msg = "End time %s invalid" % end_time
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
return func(view, request, start_time, end_time, *args, **kwargs)
示例9: get_user_info
def get_user_info(email):
user = User.objects.get(email=email)
d_profile = DetailedProfile.objects.get_detailed_profile_by_user(email)
profile = Profile.objects.get_profile_by_user(email)
info = {}
info['email'] = email
info['name'] = email2nickname(email)
info['contact_email'] = profile.contact_email if profile and profile.contact_email else ''
info['login_id'] = profile.login_id if profile and profile.login_id else ''
info['is_staff'] = user.is_staff
info['is_active'] = user.is_active
info['create_time'] = user.ctime
info['reference_id'] = user.reference_id if user.reference_id else ''
info['department'] = d_profile.department if d_profile else ''
info['quota_total'] = seafile_api.get_user_quota(email)
info['quota_usage'] = seafile_api.get_user_self_usage(email)
info['create_time'] = timestamp_to_isoformat_timestr(user.ctime)
if is_pro_version():
info['role'] = user.role
return info
示例10: if_locked_by_online_office
def if_locked_by_online_office(repo_id, path):
locked_by_online_office = False
if is_pro_version():
lock_info = seafile_api.get_lock_info(repo_id, path)
if lock_info and lock_info.user == ONLINE_OFFICE_LOCK_OWNER:
locked_by_online_office = True
return locked_by_online_office
示例11: put
def put(self, request, repo_id, format=None):
""" Currently only for lock and unlock file operation.
Permission checking:
1. user with 'rw' permission for current file;
"""
if not is_pro_version():
error_msg = 'file lock feature only supported in professional edition.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# argument check
path = request.GET.get('p', None)
if not path:
error_msg = 'p invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
operation = request.data.get('operation', None)
if not operation:
error_msg = 'operation invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
operation = operation.lower()
if operation not in ('lock', 'unlock'):
error_msg = "operation can only be 'lock', or 'unlock'."
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
file_id = seafile_api.get_file_id_by_path(repo_id, path)
if not file_id:
error_msg = 'File %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
parent_dir = os.path.dirname(path)
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.user.username
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
if operation == 'lock':
if not is_locked:
# lock file
expire = request.data.get('expire', FILE_LOCK_EXPIRATION_DAYS)
try:
seafile_api.lock_file(repo_id, path.lstrip('/'), username, expire)
except SearpcError, e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
示例12: delete
def delete(self, request, format=None):
if not is_pro_version():
error_msg = 'Feature disabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
seafile_api.clear_repo_sync_errors()
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True})
示例13: libraries
def libraries(request):
"""
New URL to replace myhome
"""
username = request.user.username
# options
if request.cloud_mode and request.user.org is None:
allow_public_share = False
else:
allow_public_share = True
sub_lib_enabled = UserOptions.objects.is_sub_lib_enabled(username)
max_upload_file_size = get_max_upload_file_size()
guide_enabled = UserOptions.objects.is_user_guide_enabled(username)
if guide_enabled:
create_default_library(request)
folder_perm_enabled = True if is_pro_version() and ENABLE_FOLDER_PERM else False
can_add_pub_repo = True if is_org_repo_creation_allowed(request) else False
return render_to_response('libraries.html', {
"allow_public_share": allow_public_share,
"guide_enabled": guide_enabled,
"sub_lib_enabled": sub_lib_enabled,
'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
'enable_resumable_fileupload': settings.ENABLE_RESUMABLE_FILEUPLOAD,
'enable_thumbnail': settings.ENABLE_THUMBNAIL,
'thumbnail_default_size': settings.THUMBNAIL_DEFAULT_SIZE,
'thumbnail_size_for_grid': settings.THUMBNAIL_SIZE_FOR_GRID,
'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
'max_upload_file_size': max_upload_file_size,
'folder_perm_enabled': folder_perm_enabled,
'is_pro': True if is_pro_version() else False,
'file_audit_enabled': FILE_AUDIT_ENABLED,
'can_add_pub_repo': can_add_pub_repo,
}, context_instance=RequestContext(request))
示例14: is_sub_lib_enabled
def is_sub_lib_enabled(self, username):
"""Return ``True`` if is not pro version AND sub lib enabled, otherwise ``False``.
Arguments:
- `self`:
- `username`:
"""
if is_pro_version():
return False
try:
user_option = super(UserOptionsManager, self).get(email=username, option_key=KEY_SUB_LIB)
return bool(int(user_option.option_val))
except UserOptions.DoesNotExist:
return False
示例15: _decorated
def _decorated(request, token, *args, **kwargs):
assert token is not None # Checked by URLconf
fileshare = FileShare.objects.get_valid_file_link_by_token(token) or \
FileShare.objects.get_valid_dir_link_by_token(token) or \
UploadLinkShare.objects.get_valid_upload_link_by_token(token)
if fileshare is None:
raise Http404
if not is_pro_version() or not settings.ENABLE_SHARE_LINK_AUDIT:
return func(request, fileshare, *args, **kwargs)
# no audit for authenticated user, since we've already got email address
if request.user.is_authenticated():
return func(request, fileshare, *args, **kwargs)
# anonymous user
if request.session.get('anonymous_email') is not None:
request.user.username = request.session.get('anonymous_email')
return func(request, fileshare, *args, **kwargs)
if request.method == 'GET':
return render_to_response('share/share_link_audit.html', {
'token': token,
}, context_instance=RequestContext(request))
elif request.method == 'POST':
code = request.POST.get('code', '')
email = request.POST.get('email', '')
cache_key = normalize_cache_key(email, 'share_link_audit_')
if code == cache.get(cache_key):
# code is correct, add this email to session so that he will
# not be asked again during this session, and clear this code.
request.session['anonymous_email'] = email
request.user.username = request.session.get('anonymous_email')
cache.delete(cache_key)
return func(request, fileshare, *args, **kwargs)
else:
return render_to_response('share/share_link_audit.html', {
'err_msg': 'Invalid token, please try again.',
'email': email,
'code': code,
'token': token,
}, context_instance=RequestContext(request))
else:
assert False, 'TODO'