diff --git a/seahub/templates/sysadmin/sys_useradmin.html b/seahub/templates/sysadmin/sys_useradmin.html
index 0d8a3c0239b..cf9b0360df5 100644
--- a/seahub/templates/sysadmin/sys_useradmin.html
+++ b/seahub/templates/sysadmin/sys_useradmin.html
@@ -35,11 +35,13 @@
{% trans "Add user" %}
+ {% if enable_guest %}
+ {% endif %}
@@ -86,9 +88,11 @@ {% trans "Import users from a CSV file" %}
var form = $(this),
form_id = $(this).attr('id'),
email = $.trim(form.children('[name="email"]').val()),
+ {% if enable_guest %}
+ role = $('select[name="role"]', form).val(),
+ {% endif %}
pwd1 = $.trim(form.children('[name="password1"]').val()),
- pwd2 = $.trim(form.children('[name="password2"]').val()),
- role = $('select[name="role"]', form).val();
+ pwd2 = $.trim(form.children('[name="password2"]').val());
if (!email) {
apply_form_error(form_id, "{% trans "Email cannot be blank" %}");
@@ -117,9 +121,11 @@ {% trans "Import users from a CSV file" %}
beforeSend: prepareCSRFToken,
data: {
'email': email,
+ {% if enable_guest %}
+ 'role': role,
+ {% endif %}
'password1': pwd1,
- 'password2': pwd2,
- 'role': role
+ 'password2': pwd2
},
success: function(data) {
if (data['success']) {
diff --git a/seahub/templates/sysadmin/useradmin_table.html b/seahub/templates/sysadmin/useradmin_table.html
index b1bc6991dc5..a0f2b4f1290 100644
--- a/seahub/templates/sysadmin/useradmin_table.html
+++ b/seahub/templates/sysadmin/useradmin_table.html
@@ -36,12 +36,16 @@
{% else %}
{% trans "Default" %}
{% endif %}
+ {% if enable_guest %}
+ {% endif %}
+ {% if enable_guest %}
+ {% endif %}
{% endif %}
diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py
index 906ab4474df..a6ffd98e7fe 100644
--- a/seahub/views/sysadmin.py
+++ b/seahub/views/sysadmin.py
@@ -615,7 +615,7 @@ def user_add(request):
post_values = request.POST.copy()
post_email = request.POST.get('email', '')
- post_role = request.POST.get('role', '')
+ post_role = request.POST.get('role', DEFAULT_USER)
post_values.update({
'email': post_email.lower(),
'role': post_role,
@@ -788,6 +788,13 @@ def user_search(request):
user.self_usage = -1
user.share_usage = -1
user.quota = -1
+
+ # check user's role
+ if user.role == GUEST_USER:
+ user.is_guest = True
+ else:
+ user.is_guest = False
+
# populate user last login time
user.last_login = None
for last_login in last_logins:
@@ -797,6 +804,9 @@ def user_search(request):
return render_to_response('sysadmin/user_search.html', {
'users': users,
'email': email,
+ 'default_user': DEFAULT_USER,
+ 'guest_user': GUEST_USER,
+ 'enable_guest': ENABLE_GUEST,
}, context_instance=RequestContext(request))
@login_required