diff --git a/forms.py b/forms.py index 19ea4df019..5d7f4dd89d 100644 --- a/forms.py +++ b/forms.py @@ -215,3 +215,11 @@ class RepoPassowrdForm(forms.Form): else: raise forms.ValidationError(u'未知错误') +class SetUserQuotaForm(forms.Form): + """ + Form for setting user quota. + """ + email = forms.CharField(error_messages={'required': '参数错误'}) + quota = forms.IntegerField(min_value=0, + error_messages={'required': '容量不能为空', + 'min_value': '容量不能小于0'}) diff --git a/organizations/templates/organizations/org_useradmin.html b/organizations/templates/organizations/org_admin.html similarity index 83% rename from organizations/templates/organizations/org_useradmin.html rename to organizations/templates/organizations/org_admin.html index e3cf0519c7..27e2a069ca 100644 --- a/organizations/templates/organizations/org_useradmin.html +++ b/organizations/templates/organizations/org_admin.html @@ -3,18 +3,33 @@ {% block nav_useradmin_class %}class="cur"{% endblock %} +{% block left_panel %} + +
+

团体已用总空间

+

{{ org_quota_usage|filesizeformat }} {% if org_quota > 0 %} / {{ org_quota|filesizeformat }} {% endif %}

+
+ +{% endblock %} + {% block right_panel %} -

所有用户

- +

所有成员

+ - + + {% for user in users %} +
邮箱邮箱已用空间 操作
{{ user.props.email }} + {% if user.quota_usage >= 0 %} + {{ user.quota_usage|filesizeformat }} + {% endif %} + {% if not user.is_self %} 删除 diff --git a/organizations/templates/organizations/personal.html b/organizations/templates/organizations/personal.html index 6938e2b812..81ccd74b2b 100644 --- a/organizations/templates/organizations/personal.html +++ b/organizations/templates/organizations/personal.html @@ -21,6 +21,12 @@ {% endif %} + +
+

我已用的团体空间

+

{{ quota_usage|filesizeformat }}

+
+ {% include "snippets/my_groups.html" %} {% endblock %} diff --git a/organizations/urls.py b/organizations/urls.py index 42af1a9f08..36b8ff0943 100644 --- a/organizations/urls.py +++ b/organizations/urls.py @@ -27,7 +27,7 @@ urlpatterns = patterns('', ### Org admin ### url(r'^(?P[^/]+)/seafadmin/$', org_seafadmin, name='org_seafadmin'), - url(r'^(?P[^/]+)/useradmin/$', org_useradmin, name='org_useradmin'), + url(r'^(?P[^/]+)/orgadmin/$', org_admin, name='org_admin'), url(r'^(?P[^/]+)/useradmin/remove/(?P[^/]+)/$', org_user_remove, name='org_user_remove'), url(r'^(?P[^/]+)/groupadmin/$', org_group_admin, name='org_groupadmin'), url(r'^(?P[^/]+)/group/remove/(?P[\d]+)/$', org_group_remove, name='org_group_remove'), diff --git a/organizations/views.py b/organizations/views.py index 21edb4f08d..55459f3ae3 100644 --- a/organizations/views.py +++ b/organizations/views.py @@ -139,6 +139,8 @@ def org_personal(request, url_prefix): events = get_org_user_events(org.org_id, user) else: events = None + + quota_usage = seafserv_threaded_rpc.get_org_user_quota_usage(org.org_id, user) return render_to_response('organizations/personal.html', { 'owned_repos': owned_repos, @@ -151,6 +153,7 @@ def org_personal(request, url_prefix): 'allow_public_share': True, 'nickname': nickname, 'events': events, + 'quota_usage': quota_usage, }, context_instance=RequestContext(request)) @login_required @@ -281,7 +284,7 @@ def send_org_user_add_mail(request, email, password, org_name): @login_required @org_staff_required -def org_useradmin(request, url_prefix): +def org_admin(request, url_prefix): """ List and add org users. """ @@ -333,17 +336,28 @@ def org_useradmin(request, url_prefix): page_next = True else: page_next = False + + org = get_user_current_org(request.user.username, url_prefix) + if not org: + return HttpResponseRedirect(reverse(myhome)) users = users_plus_one[:per_page] for user in users: if user.props.id == request.user.id: user.is_self = True + try: + user.quota_usage = seafserv_threaded_rpc.get_org_user_quota_usage(org.org_id, user.email) + except: + user.quota_usage = -1 # My contacts contacts = Contact.objects.filter(user_email=request.user.username) + + org_quota_usage = seafserv_threaded_rpc.get_org_quota_usage(org.org_id) + org_quota = seafserv_threaded_rpc.get_org_quota(org.org_id) return render_to_response( - 'organizations/org_useradmin.html', { + 'organizations/org_admin.html', { 'users': users, 'contacts': contacts, 'current_page': current_page, @@ -351,6 +365,8 @@ def org_useradmin(request, url_prefix): 'next_page': current_page+1, 'per_page': per_page, 'page_next': page_next, + 'org_quota_usage': org_quota_usage, + 'org_quota': org_quota, }, context_instance=RequestContext(request)) diff --git a/templates/base.html b/templates/base.html index 746540c959..a0bae322c9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -49,7 +49,7 @@ {% endif %} {% if org.is_staff %} - 管理员工作台 + 管理员工作台 个人工作台 {% endif %} diff --git a/templates/myhome.html b/templates/myhome.html index f0b8fe45b4..152d0216c9 100644 --- a/templates/myhome.html +++ b/templates/myhome.html @@ -42,7 +42,7 @@

已用空间

-

{{ quota_usage|filesizeformat }} {% if cloud_mode %}/ 2 GB {% endif %}

+

{{ quota_usage|filesizeformat }} {% if quota > 0 %}/ {{ quota|filesizeformat }} {% endif %}

diff --git a/templates/org_admin_base.html b/templates/org_admin_base.html index 577fbd6ee3..6d42ee2d14 100644 --- a/templates/org_admin_base.html +++ b/templates/org_admin_base.html @@ -4,7 +4,7 @@