{{ org.org_name }} 公开的同步目录
+ +名字 | +描述 | +更新时间 | +操作 | +|
---|---|---|---|---|
{{ repo.props.name }} | +{{ repo.props.desc }} | + {% if repo.latest_modify %} +{{ repo.latest_modify|translate_commit_time }} | + {% else %} +—— —— | + {% endif %} +
+ ![]() ![]() |
+
diff --git a/avatar/templates/avatar/set_avatar.html b/avatar/templates/avatar/set_avatar.html index e3c9864bee..bec85474ed 100644 --- a/avatar/templates/avatar/set_avatar.html +++ b/avatar/templates/avatar/set_avatar.html @@ -1,4 +1,4 @@ -{% extends "myhome_base.html" %} +{% extends base_template %} {% load group_avatar_tags %} {% block nav_group_class %}class="cur"{% endblock %} diff --git a/base/context_processors.py b/base/context_processors.py index 4944bf1b6e..4c9d4b6b89 100644 --- a/base/context_processors.py +++ b/base/context_processors.py @@ -18,3 +18,4 @@ def base(request): 'seahub_title': settings.SEAHUB_TITLE, 'account_type': settings.ACCOUNT_TYPE, } + diff --git a/group/templates/group/group_info.html b/group/templates/group/group_info.html index 8e38cf0c34..25685ff936 100644 --- a/group/templates/group/group_info.html +++ b/group/templates/group/group_info.html @@ -1,4 +1,4 @@ -{% extends "myhome_base.html" %} +{% extends base_template %} {% load seahub_tags avatar_tags %} {% block nav_group_class %}class="cur"{% endblock %} diff --git a/group/templates/group/group_manage.html b/group/templates/group/group_manage.html index e22eb891d4..5bbba29981 100644 --- a/group/templates/group/group_manage.html +++ b/group/templates/group/group_manage.html @@ -1,4 +1,4 @@ -{% extends "myhome_base.html" %} +{% extends base_template %} {% load seahub_tags %} {% block nav_group_class %}class="cur"{% endblock %} diff --git a/group/templates/group/new_msg_reply.html b/group/templates/group/new_msg_reply.html index bca2bbac15..054539841c 100644 --- a/group/templates/group/new_msg_reply.html +++ b/group/templates/group/new_msg_reply.html @@ -1,4 +1,4 @@ -{% extends "myhome_base.html" %} +{% extends base_template %} {% load seahub_tags avatar_tags %} {% block nav_group_class %}class="cur"{% endblock %} diff --git a/group/views.py b/group/views.py index 9282f7d6f3..dea3e1421f 100644 --- a/group/views.py +++ b/group/views.py @@ -64,8 +64,11 @@ def group_remove(request, group_id): seafserv_threaded_rpc.remove_repo_group(group_id_int, None) if request.user.org: - ccnet_threaded_rpc.remove_org_group(request.user.org.org_id, - group_id_int) + org_id = request.user.org['org_id'] + url_prefix = request.user.org['url_prefix'] + ccnet_threaded_rpc.remove_org_group(org_id, group_id_int) + return HttpResponseRedirect(reverse('org_groups', + args=[url_prefix])) except SearpcError, e: return go_error(request, e.msg) diff --git a/organizations/__init__.py b/organizations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/organizations/context_processors.py b/organizations/context_processors.py new file mode 100644 index 0000000000..a74f5b7c7a --- /dev/null +++ b/organizations/context_processors.py @@ -0,0 +1,16 @@ +def org(request): + """ + Add org info and base template that html page will extends to context. + """ + if hasattr(request.user, 'org') and request.user.org is not None: + if request.user.org['is_staff']: + base_template = 'org_admin_base.html' + else: + base_template = 'org_base.html' + return {'cur_ctx': 'org', + 'org': request.user.org, + 'base_template': base_template} + else: + return {'cur_ctx': '', + 'base_template': 'myhome_base.html'} + diff --git a/organizations/forms.py b/organizations/forms.py new file mode 100644 index 0000000000..f83c93463f --- /dev/null +++ b/organizations/forms.py @@ -0,0 +1,19 @@ +# encoding: utf-8 +from django import forms +from seaserv import ccnet_threaded_rpc + +class OrgCreateForm(forms.Form): + org_name = forms.CharField(max_length=256, + widget=forms.TextInput(), + label="Organization Name") + url_prefix = forms.RegexField(label="Url Prefix", max_length=20, + regex=r'^[a-z0-9]+$', + error_message="域名前缀只能包含字母或数字") + + def clean_url_prefix(self): + url_prefix = self.cleaned_data['url_prefix'] + org = ccnet_threaded_rpc.get_org_by_url_prefix(url_prefix) + if not org: + return url_prefix + else: + raise forms.ValidationError("该域名前缀已被注册") diff --git a/organizations/middleware.py b/organizations/middleware.py new file mode 100644 index 0000000000..642a753023 --- /dev/null +++ b/organizations/middleware.py @@ -0,0 +1,30 @@ +from django.core.cache import cache +from django.http import HttpResponseRedirect + +from seaserv import get_org_by_url_prefix + +from settings import ORG_CACHE_PREFIX + +class OrganizationMiddleware(object): + """ + Middleware that add organization info to request when user in organization + context. + """ + + def process_request(self, request): + """ + """ + org = cache.get(ORG_CACHE_PREFIX + request.user.username) + request.user.org = org + + # full_path = request.get_full_path() + # if full_path.startswith('/organizations/'): + # url_prefix = full_path.split('/')[2] + # org = get_org_by_url_prefix(url_prefix) + # if org: + # request.org = org + + return None + + def process_response(self, request, response): + return response diff --git a/organizations/models.py b/organizations/models.py new file mode 100644 index 0000000000..71a8362390 --- /dev/null +++ b/organizations/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/organizations/settings.py b/organizations/settings.py new file mode 100644 index 0000000000..f18fa87b54 --- /dev/null +++ b/organizations/settings.py @@ -0,0 +1,3 @@ +from django.conf import settings + +ORG_CACHE_PREFIX = getattr(settings, 'ORG_CACHE_PREFIX', 'ORGANIZATION_') diff --git a/organizations/templates/organizations/change_account.html b/organizations/templates/organizations/change_account.html new file mode 100644 index 0000000000..597838ea1a --- /dev/null +++ b/organizations/templates/organizations/change_account.html @@ -0,0 +1,48 @@ +{% extends base_template %} +{% load avatar_tags %} + +{% block left_panel %} + +
名称 | +操作 | +
---|---|
{{ request.user}} | ++ |
{{ org.org_name }} | ++ |
创建者:{{ group.props.creator_name }}
+创建时间:{{ group.props.timestamp|tsstr_sec }}
+暂无
+{% endif %} + + + +{% endblock %} + +{% block extra_script %} + +{% endblock %} diff --git a/organizations/templates/organizations/org_info.html b/organizations/templates/organizations/org_info.html new file mode 100644 index 0000000000..edb5b02b58 --- /dev/null +++ b/organizations/templates/organizations/org_info.html @@ -0,0 +1,82 @@ +{% extends "org_base.html" %} +{% load seahub_tags avatar_tags %} + +{% block nav_org_class %}class="cur"{% endblock %} + +{% block main_panel %} +暂无
+{% endif %} + +{% if is_join %} +名字 | +描述 | +更新时间 | +操作 | +|
---|---|---|---|---|
{{ repo.props.name }} | +{{ repo.props.desc }} | + {% if repo.latest_modify %} +{{ repo.latest_modify|translate_commit_time }} | + {% else %} +—— —— | + {% endif %} +
+ ![]() ![]() |
+