diff --git a/media/css/seahub.css b/media/css/seahub.css index 8531500760..fe86a1dc70 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -2591,6 +2591,7 @@ textarea:-moz-placeholder {/* for FF */ display: inline-block; } .share-permission-select, +.user-role-select, .user-status-select { position:relative;/*for long text in other lang in 'share admin'*/ padding:3px 2px; diff --git a/seahub/base/accounts.py b/seahub/base/accounts.py index be5fa18e45..6cb95331df 100644 --- a/seahub/base/accounts.py +++ b/seahub/base/accounts.py @@ -34,6 +34,13 @@ class UserManager(object): return self.get(email=email) + def update_role(self, email, role): + """ + If user has a role, update it; or create a role for user. + """ + ccnet_threaded_rpc.update_role_emailuser(email, role) + return self.get(email=email) + def create_superuser(self, email, password): u = self.create_user(email, password, is_staff=True, is_active=True) return u @@ -72,6 +79,7 @@ class UserManager(object): user.ctime = emailuser.ctime user.org = emailuser.org user.source = emailuser.source + user.role = emailuser.role return user diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 59d39485f9..40235a4d23 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -31,7 +31,17 @@ try: from seahub.settings import MULTI_TENANCY except ImportError: MULTI_TENANCY = False - + +try: + from seahub.constants import DEFAULT_USER +except ImportError: + DEFAULT_USER = 'default' + +try: + from seahub.constants import GUEST_USER +except ImportError: + GUEST_USER= 'guest' + def base(request): """ Add seahub base configure to the context. @@ -75,4 +85,6 @@ def base(request): 'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA, 'grps': grps, 'multi_tenancy': MULTI_TENANCY, + 'default_user': DEFAULT_USER, + 'guest_user': GUEST_USER, } diff --git a/seahub/constants.py b/seahub/constants.py new file mode 100644 index 0000000000..060cf1e24e --- /dev/null +++ b/seahub/constants.py @@ -0,0 +1,8 @@ +# Default user have common operations, +# like creating group and library. +DEFUALT_USER = 'default' + +# Guest user have limited operations, +# can not create group and library. +GUEST_USER = 'guest' + diff --git a/seahub/forms.py b/seahub/forms.py index ae4fb9821e..cfd5b38342 100644 --- a/seahub/forms.py +++ b/seahub/forms.py @@ -14,8 +14,13 @@ class AddUserForm(forms.Form): """ Form for adding a user. """ + from seahub import constants + DEFAULT_USER = getattr(constants, 'DEFAULT_USER', 'default') + GUEST_USER = getattr(constants, 'GUEST_USER', 'guest') email = forms.EmailField() + role = forms.ChoiceField( \ + choices=[(DEFAULT_USER, DEFAULT_USER), (GUEST_USER,GUEST_USER)]) password1 = forms.CharField(widget=forms.PasswordInput()) password2 = forms.CharField(widget=forms.PasswordInput()) diff --git a/seahub/group/templates/group/group_info.html b/seahub/group/templates/group/group_info.html index 285529ddcb..78119981cc 100644 --- a/seahub/group/templates/group/group_info.html +++ b/seahub/group/templates/group/group_info.html @@ -11,7 +11,9 @@
{% trans "After creating a group, you can add members and share libraries into it." %}
{% trans "You are a guest user now, can not create group. But group(s) you have joined in will be list right." %}
+{% blocktrans %}You can create a group by clicking "New Group" button. Group is a place for you and your friends leaving messages and collaborating on libraries.{% endblocktrans %}
{% trans "You are a guest user now, can not create group. But group(s) you have joined in will be list here." %}
+{% trans "Default library is the default place to store your personal documents and pictures." %}