def create_org(self, username=org_user_name, password=org_user_password, org_name='org', prefix='org_p', quota=100, member_limit=100): new_org = ccnet_threaded_rpc.get_org_by_url_prefix(prefix) if new_org: return new_org quota = int(quota) User.objects.create_user(username, password, is_staff=False, is_active=True) create_org(org_name, prefix, username) new_org = ccnet_threaded_rpc.get_org_by_url_prefix(prefix) from seahub_extra.organizations.models import OrgMemberQuota OrgMemberQuota.objects.set_quota(new_org.org_id, member_limit) quota = quota * get_file_size_unit('MB') seafserv_threaded_rpc.set_org_quota(new_org.org_id, quota) return new_org
def sys_org_set_quota(request, org_id): if request.method != 'POST': raise Http404 content_type = 'application/json; charset=utf-8' result = {} org_id = int(org_id) quota_mb = int(request.POST.get('quota', 0)) quota = quota_mb * get_file_size_unit('MB') try: seafserv_threaded_rpc.set_org_quota(org_id, quota) except SearpcError as e: logger.error(e) result['error'] = _('Failed to set quota: internal server error') return HttpResponse(json.dumps(result), status=500, content_type=content_type) result['success'] = True return HttpResponse(json.dumps(result), content_type=content_type)
def sys_org_set_quota(request, org_id): if request.method != 'POST': raise Http404 content_type = 'application/json; charset=utf-8' result = {} org_id = int(org_id) quota_mb = int(request.POST.get('quota', 0)) quota = quota_mb * (1 << 20) try: seafserv_threaded_rpc.set_org_quota(org_id, quota) except SearpcError as e: logger.error(e) result['error'] = _(u'Failed to set quota: internal server error') return HttpResponse(json.dumps(result), status=500, content_type=content_type) result['success'] = True return HttpResponse(json.dumps(result), content_type=content_type)