mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
[user-role] Select role when add a user / change role at user admin page;
Limit guest user's operation: can not create group and library.
This commit is contained in:
@@ -2591,6 +2591,7 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.share-permission-select,
|
.share-permission-select,
|
||||||
|
.user-role-select,
|
||||||
.user-status-select {
|
.user-status-select {
|
||||||
position:relative;/*for long text in other lang in 'share admin'*/
|
position:relative;/*for long text in other lang in 'share admin'*/
|
||||||
padding:3px 2px;
|
padding:3px 2px;
|
||||||
|
@@ -34,6 +34,13 @@ class UserManager(object):
|
|||||||
|
|
||||||
return self.get(email=email)
|
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):
|
def create_superuser(self, email, password):
|
||||||
u = self.create_user(email, password, is_staff=True, is_active=True)
|
u = self.create_user(email, password, is_staff=True, is_active=True)
|
||||||
return u
|
return u
|
||||||
@@ -72,6 +79,7 @@ class UserManager(object):
|
|||||||
user.ctime = emailuser.ctime
|
user.ctime = emailuser.ctime
|
||||||
user.org = emailuser.org
|
user.org = emailuser.org
|
||||||
user.source = emailuser.source
|
user.source = emailuser.source
|
||||||
|
user.role = emailuser.role
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
@@ -31,7 +31,17 @@ try:
|
|||||||
from seahub.settings import MULTI_TENANCY
|
from seahub.settings import MULTI_TENANCY
|
||||||
except ImportError:
|
except ImportError:
|
||||||
MULTI_TENANCY = False
|
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):
|
def base(request):
|
||||||
"""
|
"""
|
||||||
Add seahub base configure to the context.
|
Add seahub base configure to the context.
|
||||||
@@ -75,4 +85,6 @@ def base(request):
|
|||||||
'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA,
|
'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA,
|
||||||
'grps': grps,
|
'grps': grps,
|
||||||
'multi_tenancy': MULTI_TENANCY,
|
'multi_tenancy': MULTI_TENANCY,
|
||||||
|
'default_user': DEFAULT_USER,
|
||||||
|
'guest_user': GUEST_USER,
|
||||||
}
|
}
|
||||||
|
8
seahub/constants.py
Normal file
8
seahub/constants.py
Normal file
@@ -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'
|
||||||
|
|
@@ -14,8 +14,13 @@ class AddUserForm(forms.Form):
|
|||||||
"""
|
"""
|
||||||
Form for adding a user.
|
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()
|
email = forms.EmailField()
|
||||||
|
role = forms.ChoiceField( \
|
||||||
|
choices=[(DEFAULT_USER, DEFAULT_USER), (GUEST_USER,GUEST_USER)])
|
||||||
password1 = forms.CharField(widget=forms.PasswordInput())
|
password1 = forms.CharField(widget=forms.PasswordInput())
|
||||||
password2 = forms.CharField(widget=forms.PasswordInput())
|
password2 = forms.CharField(widget=forms.PasswordInput())
|
||||||
|
|
||||||
|
@@ -11,7 +11,9 @@
|
|||||||
<li class="tab"><a href="#grp-repos" class="a">{% trans "Libraries" %}</a></li>
|
<li class="tab"><a href="#grp-repos" class="a">{% trans "Libraries" %}</a></li>
|
||||||
<li class="tab long-tab"><a href="#grp-repos-commits" class="a">{% trans "Recent Changes" %}</a></li>
|
<li class="tab long-tab"><a href="#grp-repos-commits" class="a">{% trans "Recent Changes" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div id="grp-repos" class="hide">
|
<div id="grp-repos" class="hide">
|
||||||
{% if repos %}
|
{% if repos %}
|
||||||
|
@@ -1,8 +1,16 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<h3 class="info-item-top">{% trans "Tips" %}</h3>
|
<h3 class="info-item-top">{% trans "Tips" %}</h3>
|
||||||
<div class="info-item-bottom">
|
<div class="info-item-bottom">
|
||||||
<p class="not-last">{% trans "After creating a group, you can add members and share libraries into it." %}</p>
|
<p class="not-last">{% trans "After creating a group, you can add members and share libraries into it." %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="info-item">
|
||||||
|
<h3 class="info-item-top">{% trans "Tips" %}</h3>
|
||||||
|
<div class="info-item-bottom">
|
||||||
|
<p class="not-last">{% trans "You are a guest user now, can not create group. But group(s) you have joined in will be list right." %}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
<h3>{% trans "My Groups" %}</h3>
|
<h3>{% trans "My Groups" %}</h3>
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<button id="group-add"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Group" %}</span></button>
|
<button id="group-add"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Group" %}</span></button>
|
||||||
|
{% endif %}
|
||||||
{% if joined_groups %}
|
{% if joined_groups %}
|
||||||
<ul class="group-list w100 ovhd">
|
<ul class="group-list w100 ovhd">
|
||||||
{% for group in joined_groups %}
|
{% for group in joined_groups %}
|
||||||
@@ -24,10 +26,17 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<div class="empty-tips">
|
<div class="empty-tips">
|
||||||
<h2 class="alc">{% trans "You are not in any groups" %}</h2>
|
<h2 class="alc">{% trans "You are not in any groups" %}</h2>
|
||||||
<p>{% 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 %}</p>
|
<p>{% 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 %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty-tips">
|
||||||
|
<h2 class="alc">{% trans "You are a guest user" %}</h2>
|
||||||
|
<p class="not-last">{% trans "You are a guest user now, can not create group. But group(s) you have joined in will be list here." %}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form id="group-add-form" action="" method="post" name="group-add-form" class="hide">{% csrf_token %}
|
<form id="group-add-form" action="" method="post" name="group-add-form" class="hide">{% csrf_token %}
|
||||||
<h3>{% trans "New Group" %}</h3>
|
<h3>{% trans "New Group" %}</h3>
|
||||||
|
@@ -9,11 +9,13 @@
|
|||||||
<ul class="side-textnav-tabs">
|
<ul class="side-textnav-tabs">
|
||||||
<li class="tab"><a href="#user-basic-info">{% trans "Profile" %}</a></li>
|
<li class="tab"><a href="#user-basic-info">{% trans "Profile" %}</a></li>
|
||||||
<li class="tab"><a href="#lang-setting">{% trans "Language" %}</a></li>
|
<li class="tab"><a href="#lang-setting">{% trans "Language" %}</a></li>
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
{% if not force_server_crypto %}
|
{% if not force_server_crypto %}
|
||||||
<li class="tab"><a href="#enc-lib-setting">{% trans "Encrypted Libraries" %}</a></li>
|
<li class="tab"><a href="#enc-lib-setting">{% trans "Encrypted Libraries" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="tab"><a href="#sub-lib-setting">{% trans "Sub-library" %}</a></li>
|
<li class="tab"><a href="#sub-lib-setting">{% trans "Sub-library" %}</a></li>
|
||||||
<li class="tab"><a href="#default-lib">{% trans "Default Library" %}</a></li>
|
<li class="tab"><a href="#default-lib">{% trans "Default Library" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
<li class="tab"><a href="#del-account">{% trans "Delete Account" %}</a></li>
|
<li class="tab"><a href="#del-account">{% trans "Delete Account" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -72,6 +74,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
{% if not force_server_crypto %}
|
{% if not force_server_crypto %}
|
||||||
<div class="setting-item" id="enc-lib-setting">
|
<div class="setting-item" id="enc-lib-setting">
|
||||||
<h3>{% trans "Encrypted Libraries Setting" %}</h3>
|
<h3>{% trans "Encrypted Libraries Setting" %}</h3>
|
||||||
@@ -106,6 +109,7 @@
|
|||||||
<p>{% trans "Default library is the default place to store your personal documents and pictures." %}</p>
|
<p>{% trans "Default library is the default place to store your personal documents and pictures." %}</p>
|
||||||
<button id="default-lib">{% trans "Choose Default Library" %}</button>
|
<button id="default-lib">{% trans "Choose Default Library" %}</button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="setting-item" id="del-account">
|
<div class="setting-item" id="del-account">
|
||||||
<h3>{% trans "Delete Account" %}</h3>
|
<h3>{% trans "Delete Account" %}</h3>
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
<div class="side-tabnav">
|
<div class="side-tabnav">
|
||||||
<div class="hd w100 ovhd">
|
<div class="hd w100 ovhd">
|
||||||
<h3 class="fleft">{% trans "Personal" %}</h3>
|
<h3 class="fleft">{% trans "Personal" %}</h3>
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<img id="enable-mods" class="fright" title="{% trans "Enable Modules" %}" src="{{MEDIA_URL}}img/setting.png" alt="" />
|
<img id="enable-mods" class="fright" title="{% trans "Enable Modules" %}" src="{{MEDIA_URL}}img/setting.png" alt="" />
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<ul class="side-tabnav-tabs">
|
<ul class="side-tabnav-tabs">
|
||||||
<li class="tab {% block cur_my_lib %}{% endblock %}"><a href="{% url 'myhome' %}" class="lib">{% trans "Libraries" %}</a></li>
|
<li class="tab {% block cur_my_lib %}{% endblock %}"><a href="{% url 'myhome' %}" class="lib">{% trans "Libraries" %}</a></li>
|
||||||
|
@@ -6,14 +6,17 @@
|
|||||||
{% block extra_style %}
|
{% block extra_style %}
|
||||||
{% if need_guide %}
|
{% if need_guide %}
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
#guide-for-guest,
|
||||||
#guide-for-new {
|
#guide-for-new {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
width: 450px;
|
width: 450px;
|
||||||
}
|
}
|
||||||
|
#guide-for-guest .icon-lightbulb,
|
||||||
#guide-for-new .icon-lightbulb {
|
#guide-for-new .icon-lightbulb {
|
||||||
font-size:6em;
|
font-size:6em;
|
||||||
color:#feac74;
|
color:#feac74;
|
||||||
}
|
}
|
||||||
|
#guide-for-guest .txt,
|
||||||
#guide-for-new .txt {
|
#guide-for-new .txt {
|
||||||
margin-left:6.4em;
|
margin-left:6.4em;
|
||||||
}
|
}
|
||||||
@@ -33,15 +36,28 @@
|
|||||||
|
|
||||||
{% include "snippets/repo_create_form.html" %}
|
{% include "snippets/repo_create_form.html" %}
|
||||||
|
|
||||||
{% if need_guide %}
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<div id="guide-for-new" class="hide">
|
{% if need_guide %}
|
||||||
<span class="icon-lightbulb fleft"></span>
|
<div id="guide-for-new" class="hide">
|
||||||
<div class="txt">
|
<span class="icon-lightbulb fleft"></span>
|
||||||
<h3>{% trans "Welcome to Seafile!" %}</h3>
|
<div class="txt">
|
||||||
<p>{% trans "Seafile organizes files into libraries. Each library can be synced and shared separately. We have created a personal library for you. You can create more libraries later." %}</p>
|
<h3>{% trans "Welcome to Seafile!" %}</h3>
|
||||||
<button class="simplemodal-close" style="margin:8px 0 0 0;">{% trans "Close" %}</button>
|
<p>{% trans "Seafile organizes files into libraries. Each library can be synced and shared separately. We have created a personal library for you. You can create more libraries later." %}</p>
|
||||||
|
<button class="simplemodal-close" style="margin:8px 0 0 0;">{% trans "Close" %}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if need_guide %}
|
||||||
|
<div id="guide-for-guest" class="hide">
|
||||||
|
<span class="icon-lightbulb fleft"></span>
|
||||||
|
<div class="txt">
|
||||||
|
<h3>{% trans "Welcome to Seafile!" %}</h3>
|
||||||
|
<p>{% trans "You are a guest user, some operations are limited, you can ask system administrator to change you to commom user for full operations." %}</p>
|
||||||
|
<button class="simplemodal-close" style="margin:8px 0 0 0;">{% trans "Close" %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||||
@@ -62,9 +78,16 @@
|
|||||||
|
|
||||||
{% block extra_script %}{{block.super}}
|
{% block extra_script %}{{block.super}}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{% if need_guide %}
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
$(function() {$('#guide-for-new').modal({appendTo: '#main', focus:false});});
|
{% if need_guide %}
|
||||||
|
$(function() {$('#guide-for-new').modal({appendTo: '#main', focus:false});});
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if need_guide %}
|
||||||
|
$(function() {$('#guide-for-guest').modal({appendTo: '#main', focus:false});});
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% include "snippets/myhome_extra_script.html" %}
|
{% include "snippets/myhome_extra_script.html" %}
|
||||||
var cur_tab = $('.ui-tabs-selected .a');
|
var cur_tab = $('.ui-tabs-selected .a');
|
||||||
var lib_create_btn = $('#repo-create'),
|
var lib_create_btn = $('#repo-create'),
|
||||||
|
@@ -8,11 +8,13 @@
|
|||||||
<li class="nav-item" {% if grps %}style="position:relative;"{% endif %}>
|
<li class="nav-item" {% if grps %}style="position:relative;"{% endif %}>
|
||||||
<a href="{% url 'group_list' %}" class="a {% block cur_group %}{% endblock %}" {% if grps %}id="top-nav-grp"{% endif %}>{% trans "Groups" %}{% if grps %} <span class="icon-caret-down"></span>{% endif %}</a>
|
<a href="{% url 'group_list' %}" class="a {% block cur_group %}{% endblock %}" {% if grps %}id="top-nav-grp"{% endif %}>{% trans "Groups" %}{% if grps %} <span class="icon-caret-down"></span>{% endif %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
{% if request.user.org or not cloud_mode %}
|
{% if request.user.org or not cloud_mode %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="{% url 'pubrepo' %}" class="a {% block cur_pubinfo %}{% endblock %}">{% trans "Organization" %}</a>
|
<a href="{% url 'pubrepo' %}" class="a {% block cur_pubinfo %}{% endblock %}">{% trans "Organization" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="{{ SITE_ROOT }}help/" class="a {% block cur_help %}{% endblock %}">{% trans "Help" %}</a>
|
<a href="{{ SITE_ROOT }}help/" class="a {% block cur_help %}{% endblock %}">{% trans "Help" %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
<div id="tabs" class="tab-tabs">
|
<div id="tabs" class="tab-tabs">
|
||||||
<div class="hd ovhd">
|
<div class="hd ovhd">
|
||||||
<ul class="tab-tabs-nav fleft">
|
<ul class="tab-tabs-nav fleft">
|
||||||
|
{% if request.user.role == default_user or request.user.role == None %}
|
||||||
<li class="tab"><a href="#my-own-repos" class="a" id="mylib-tab">{% trans "Mine" %}</a></li>
|
<li class="tab"><a href="#my-own-repos" class="a" id="mylib-tab">{% trans "Mine" %}</a></li>
|
||||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||||
<li class="tab"><a href="#my-sub-repos" class="a" id="sublib-tab">{% trans "Sub-libraries" %}</a></li>
|
<li class="tab"><a href="#my-sub-repos" class="a" id="sublib-tab">{% trans "Sub-libraries" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<li class="tab"><a href="#repos-shared-to-me" class="a" id="shared-lib-tab">{% trans "Shared" %}</a></li>
|
<li class="tab"><a href="#repos-shared-to-me" class="a" id="shared-lib-tab">{% trans "Shared" %}</a></li>
|
||||||
<li class="tab"><a href="#group-repos" class="a" id="grp-lib-tab">{% trans "Group" %}</a></li>
|
<li class="tab"><a href="#group-repos" class="a" id="grp-lib-tab">{% trans "Group" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -40,6 +40,11 @@
|
|||||||
<input type="password" name="password1" id="id_password1" class="input" /><br />
|
<input type="password" name="password1" id="id_password1" class="input" /><br />
|
||||||
<label for="id_password2">{% trans "Confirm Password" %}</label><br />
|
<label for="id_password2">{% trans "Confirm Password" %}</label><br />
|
||||||
<input type="password" name="password2" id="id_password2" class="input" /><br />
|
<input type="password" name="password2" id="id_password2" class="input" /><br />
|
||||||
|
<label>{% trans "Role:"%} </label>
|
||||||
|
<select name="role">
|
||||||
|
<option value={{default_user}} selected="selected">{% trans "Default"%}</option>
|
||||||
|
<option value={{guest_user}}>{% trans "Guest"%}</option>
|
||||||
|
</select><br />
|
||||||
<p class="error hide"></p>
|
<p class="error hide"></p>
|
||||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||||
</form>
|
</form>
|
||||||
@@ -83,7 +88,8 @@ $('#add-user-form').submit(function() {
|
|||||||
form_id = $(this).attr('id'),
|
form_id = $(this).attr('id'),
|
||||||
email = $.trim(form.children('[name="email"]').val()),
|
email = $.trim(form.children('[name="email"]').val()),
|
||||||
pwd1 = $.trim(form.children('[name="password1"]').val()),
|
pwd1 = $.trim(form.children('[name="password1"]').val()),
|
||||||
pwd2 = $.trim(form.children('[name="password2"]').val());
|
pwd2 = $.trim(form.children('[name="password2"]').val()),
|
||||||
|
role = $('select[name="role"]', form).val();
|
||||||
|
|
||||||
if (!email) {
|
if (!email) {
|
||||||
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
|
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
|
||||||
@@ -113,7 +119,8 @@ $('#add-user-form').submit(function() {
|
|||||||
data: {
|
data: {
|
||||||
'email': email,
|
'email': email,
|
||||||
'password1': pwd1,
|
'password1': pwd1,
|
||||||
'password2': pwd2
|
'password2': pwd2,
|
||||||
|
'role': role
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data['success']) {
|
if (data['success']) {
|
||||||
|
@@ -40,10 +40,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="25%">{% trans "Email" %}</th>
|
<th width="25%">{% trans "Email" %}</th>
|
||||||
<th width="15%">{% trans "Status" %}</th>
|
<th width="12%">{% trans "Status" %}</th>
|
||||||
|
<th width="11%">{% trans "Role" %}</th>
|
||||||
<th width="15%">{% trans "Space Used" %}</th>
|
<th width="15%">{% trans "Space Used" %}</th>
|
||||||
<th width="22%">{% trans "Create At / Last Login" %}</th>
|
<th width="22%">{% trans "Create At / Last Login" %}</th>
|
||||||
<th width="23%">{% trans "Operations" %}</th>
|
<th width="15%">{% trans "Operations" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for user in admin_users %}
|
{% for user in admin_users %}
|
||||||
@@ -67,6 +68,23 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{% if user.source != 'LDAP' %}
|
||||||
|
<div class="user-role">
|
||||||
|
{% if user.role == default_user or user.role == None %}
|
||||||
|
<span class="user-role-cur-value">{% trans "Default" %}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="user-role-cur-value">{% trans "Guest" %}</span>
|
||||||
|
{% endif %}
|
||||||
|
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="user-role-edit-icon cspt vh" />
|
||||||
|
</div>
|
||||||
|
<select name="role" class="user-role-select hide">
|
||||||
|
<option value={{default_user}} {%if user.role == default_user or user.role == None %}selected="selected"{% endif %}>{% trans "Default" %}</option>
|
||||||
|
<option value={{guest_user}} {%if user.role == guest_user %}selected="selected"{% endif %}>{% trans "Guest"%}</option>
|
||||||
|
</select>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% if CALC_SHARE_USAGE %}
|
{% if CALC_SHARE_USAGE %}
|
||||||
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
||||||
|
@@ -22,21 +22,29 @@ $('#add-user-btn').click(function() {
|
|||||||
});
|
});
|
||||||
$('tr:gt(0)').hover(
|
$('tr:gt(0)').hover(
|
||||||
function() {
|
function() {
|
||||||
$(this).find('.user-status-edit-icon').removeClass('vh');
|
$(this).find('.user-status-edit-icon, .user-role-edit-icon').removeClass('vh');
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
$(this).find('.user-status-edit-icon').addClass('vh');
|
$(this).find('.user-status-edit-icon, .user-role-edit-icon').addClass('vh');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$('.user-status-edit-icon').click(function() {
|
// show 'user-status(role)-select'
|
||||||
|
$('.user-status-edit-icon, .user-role-edit-icon').click(function() {
|
||||||
$(this).parent().addClass('hide');
|
$(this).parent().addClass('hide');
|
||||||
$(this).parent().next().removeClass('hide'); // show 'user-status-select'
|
$(this).parent().next().removeClass('hide');
|
||||||
});
|
});
|
||||||
$('.user-status-select').change(function() {
|
$('.user-status-select, .user-role-select').change(function() {
|
||||||
var select = $(this),
|
var select = $(this),
|
||||||
uid = $(this).parent().prev().attr('data'),
|
|
||||||
select_val = select.val(),
|
select_val = select.val(),
|
||||||
url = "{{ SITE_ROOT }}useradmin/toggle_status/" + uid + "/?s=" + select_val;
|
class_val = $(this).attr('class');
|
||||||
|
|
||||||
|
if (class_val.indexOf('status') != -1) {
|
||||||
|
var uid = $(this).parent().prev().attr('data'),
|
||||||
|
url = "{{ SITE_ROOT }}useradmin/toggle_status/" + uid + "/?s=" + select_val;
|
||||||
|
} else {
|
||||||
|
var uid = $(this).parent().prev().prev().attr('data'),
|
||||||
|
url = "{{ SITE_ROOT }}useradmin/toggle_role/" + uid + "/?r=" + select_val;
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
@@ -53,14 +61,14 @@ $('.user-status-select').change(function() {
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data['email_sent']) {
|
if (data['email_sent']) {
|
||||||
feedback("{% trans "Edit succeeded, an email has been sent." %}", 'success');
|
feedback("{% trans "Edit succeeded, an email has been sent." %}", 'success');
|
||||||
select.prev().children('.user-status-cur-value').html(select.children('option[value="' +select.val() + '"]').text());
|
select.prev().children(select).html(select.children('option[value="' +select.val() + '"]').text());
|
||||||
|
|
||||||
} else if (data['email_sent'] === false) {
|
} else if (data['email_sent'] === false) {
|
||||||
feedback("{% trans "Edit succeeded, but failed to send email, please check your email configuration." %}", 'success');
|
feedback("{% trans "Edit succeeded, but failed to send email, please check your email configuration." %}", 'success');
|
||||||
select.prev().children('.user-status-cur-value').html(select.children('option[value="' +select.val() + '"]').text());
|
select.prev().children(select).html(select.children('option[value="' +select.val() + '"]').text());
|
||||||
} else {
|
} else {
|
||||||
feedback("{% trans "Edit succeeded" %}", 'success');
|
feedback("{% trans "Edit succeeded" %}", 'success');
|
||||||
select.prev().children('.user-status-cur-value').html(select.children('option[value="' +select.val() + '"]').text());
|
select.prev().children(select).html(select.children('option[value="' +select.val() + '"]').text());
|
||||||
}
|
}
|
||||||
|
|
||||||
select.addClass('hide');
|
select.addClass('hide');
|
||||||
@@ -79,8 +87,8 @@ $('.user-status-select').change(function() {
|
|||||||
$(document).click(function(e) {
|
$(document).click(function(e) {
|
||||||
var target = e.target || event.srcElement;
|
var target = e.target || event.srcElement;
|
||||||
// target can't be edit-icon
|
// target can't be edit-icon
|
||||||
if (!$('.user-status-edit-icon, .user-status-select').is(target)) {
|
if (!$('.user-status-edit-icon, .user-status-select, .user-role-edit-icon, .user-role-select').is(target)) {
|
||||||
$('.user-status').removeClass('hide');
|
$('.user-status, .user-role').removeClass('hide');
|
||||||
$('.user-status-select').addClass('hide');
|
$('.user-status-select, .user-role-select').addClass('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -2,10 +2,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="25%">{% trans "Email" %}</th>
|
<th width="25%">{% trans "Email" %}</th>
|
||||||
<th width="15%">{% trans "Status" %}</th>
|
<th width="12%">{% trans "Status" %}</th>
|
||||||
|
<th width="11%">{% trans "Role" %}</th>
|
||||||
<th width="15%">{% trans "Space Used" %}</th>
|
<th width="15%">{% trans "Space Used" %}</th>
|
||||||
<th width="22%">{% trans "Create At / Last Login" %}</th>
|
<th width="22%">{% trans "Create At / Last Login" %}</th>
|
||||||
<th width="23%">{% trans "Operations" %}</th>
|
<th width="15%">{% trans "Operations" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
@@ -28,7 +29,23 @@
|
|||||||
</select>
|
</select>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if user.source != 'LDAP' %}
|
||||||
|
<div class="user-role">
|
||||||
|
{% if user.role == default_user or user.role == None %}
|
||||||
|
<span class="user-role-cur-value">{% trans "Default" %}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="user-role-cur-value">{% trans "Guest" %}</span>
|
||||||
|
{% endif %}
|
||||||
|
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="user-role-edit-icon cspt vh" />
|
||||||
|
</div>
|
||||||
|
<select name="role" class="user-role-select hide">
|
||||||
|
<option value={{default_user}} {%if user.role == default_user or user.role == None %}selected="selected"{% endif %}>{% trans "Default" %}</option>
|
||||||
|
<option value={{guest_user}} {%if user.role == guest_user %}selected="selected"{% endif %}>{% trans "Guest"%}</option>
|
||||||
|
</select>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% if CALC_SHARE_USAGE %}
|
{% if CALC_SHARE_USAGE %}
|
||||||
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
|
||||||
|
@@ -193,6 +193,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^useradmin/activate/(?P<user_id>[^/]+)/$', user_activate, name='user_activate'),
|
url(r'^useradmin/activate/(?P<user_id>[^/]+)/$', user_activate, name='user_activate'),
|
||||||
url(r'^useradmin/deactivate/(?P<user_id>[^/]+)/$', user_deactivate, name='user_deactivate'),
|
url(r'^useradmin/deactivate/(?P<user_id>[^/]+)/$', user_deactivate, name='user_deactivate'),
|
||||||
url(r'^useradmin/toggle_status/(?P<user_id>[^/]+)/$', user_toggle_status, name='user_toggle_status'),
|
url(r'^useradmin/toggle_status/(?P<user_id>[^/]+)/$', user_toggle_status, name='user_toggle_status'),
|
||||||
|
url(r'^useradmin/toggle_role/(?P<user_id>[^/]+)/$', user_toggle_role, name='user_toggle_role'),
|
||||||
url(r'^useradmin/(?P<email>[^/]+)/set_quota/$', user_set_quota, name='user_set_quota'),
|
url(r'^useradmin/(?P<email>[^/]+)/set_quota/$', user_set_quota, name='user_set_quota'),
|
||||||
|
|
||||||
url(r'^useradmin/password/reset/(?P<user_id>[^/]+)/$', user_reset, name='user_reset'),
|
url(r'^useradmin/password/reset/(?P<user_id>[^/]+)/$', user_reset, name='user_reset'),
|
||||||
|
@@ -975,17 +975,20 @@ def myhome(request):
|
|||||||
allow_public_share = True
|
allow_public_share = True
|
||||||
|
|
||||||
# user guide
|
# user guide
|
||||||
|
from seahub import constants
|
||||||
|
DEFAULT_USER = getattr(constants, 'DEFAULT_USER', 'default')
|
||||||
need_guide = False
|
need_guide = False
|
||||||
if len(owned_repos) == 0:
|
if len(owned_repos) == 0:
|
||||||
need_guide = UserOptions.objects.is_user_guide_enabled(username)
|
need_guide = UserOptions.objects.is_user_guide_enabled(username)
|
||||||
if need_guide:
|
if need_guide:
|
||||||
UserOptions.objects.disable_user_guide(username)
|
UserOptions.objects.disable_user_guide(username)
|
||||||
# create a default library for user
|
# create a default library for user
|
||||||
create_default_library(request)
|
|
||||||
|
|
||||||
# refetch owned repos
|
if request.user.role == DEFAULT_USER or request.user.role == None:
|
||||||
owned_repos = get_owned_repo_list(request)
|
create_default_library(request)
|
||||||
calculate_repos_last_modify(owned_repos)
|
# refetch owned repos
|
||||||
|
owned_repos = get_owned_repo_list(request)
|
||||||
|
calculate_repos_last_modify(owned_repos)
|
||||||
|
|
||||||
repo_create_url = reverse("repo_create")
|
repo_create_url = reverse("repo_create")
|
||||||
|
|
||||||
|
@@ -495,6 +495,29 @@ def user_toggle_status(request, user_id):
|
|||||||
return HttpResponse(json.dumps({'success': False}), status=500,
|
return HttpResponse(json.dumps({'success': False}), status=500,
|
||||||
content_type=content_type)
|
content_type=content_type)
|
||||||
|
|
||||||
|
@login_required_ajax
|
||||||
|
@sys_staff_required
|
||||||
|
def user_toggle_role(request, user_id):
|
||||||
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
|
from seahub import constants
|
||||||
|
DEFAULT_USER = getattr(constants, 'DEFAULT_USER', 'default')
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_role = request.GET.get('r', DEFAULT_USER)
|
||||||
|
except ValueError:
|
||||||
|
user_role = DEFAULT_USER
|
||||||
|
|
||||||
|
try:
|
||||||
|
user = User.objects.get(id=int(user_id))
|
||||||
|
User.objects.update_role(user.email, user_role)
|
||||||
|
|
||||||
|
return HttpResponse(json.dumps({'success': True}),
|
||||||
|
content_type=content_type)
|
||||||
|
except User.DoesNotExist:
|
||||||
|
return HttpResponse(json.dumps({'success': False}), status=500,
|
||||||
|
content_type=content_type)
|
||||||
|
|
||||||
def send_user_reset_email(request, email, password):
|
def send_user_reset_email(request, email, password):
|
||||||
"""
|
"""
|
||||||
Send email when reset user password.
|
Send email when reset user password.
|
||||||
@@ -569,15 +592,23 @@ def user_add(request):
|
|||||||
|
|
||||||
post_values = request.POST.copy()
|
post_values = request.POST.copy()
|
||||||
post_email = request.POST.get('email', '')
|
post_email = request.POST.get('email', '')
|
||||||
post_values.update({'email': post_email.lower()})
|
post_role = request.POST.get('role', '')
|
||||||
|
post_values.update({
|
||||||
|
'email': post_email.lower(),
|
||||||
|
'role': post_role,
|
||||||
|
})
|
||||||
|
|
||||||
form = AddUserForm(post_values)
|
form = AddUserForm(post_values)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
email = form.cleaned_data['email']
|
email = form.cleaned_data['email']
|
||||||
|
role = form.cleaned_data['role']
|
||||||
password = form.cleaned_data['password1']
|
password = form.cleaned_data['password1']
|
||||||
|
|
||||||
user = User.objects.create_user(email, password, is_staff=False,
|
user = User.objects.create_user(email, password, is_staff=False,
|
||||||
is_active=True)
|
is_active=True)
|
||||||
|
if user:
|
||||||
|
User.objects.update_role(email, role)
|
||||||
|
|
||||||
if request.user.org:
|
if request.user.org:
|
||||||
org_id = request.user.org.org_id
|
org_id = request.user.org.org_id
|
||||||
url_prefix = request.user.org.url_prefix
|
url_prefix = request.user.org.url_prefix
|
||||||
|
Reference in New Issue
Block a user