1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 14:21:23 +00:00

[address book] modification: nav icon, group owner

This commit is contained in:
llj
2018-04-20 11:22:26 +08:00
parent 5d2aa8af05
commit 30c0636791
5 changed files with 23 additions and 41 deletions

View File

@@ -74,15 +74,8 @@ class AdminAddressBookGroups(APIView):
error_msg = _(u'There is already a group with that name.') error_msg = _(u'There is already a group with that name.')
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# Group owner is 'system admin'
group_owner = request.data.get('group_owner', '') group_owner = request.data.get('group_owner', '')
if group_owner:
try:
User.objects.get(email=group_owner)
except User.DoesNotExist:
error_msg = 'User %s not found.' % group_owner
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
else:
group_owner = request.user.username
try: try:
parent_group = int(request.data.get('parent_group', -1)) parent_group = int(request.data.get('parent_group', -1))

View File

@@ -49,7 +49,7 @@
{% if is_pro and user.admin_permissions.can_manage_group %} {% if is_pro and user.admin_permissions.can_manage_group %}
<li class="tab<% if (cur_tab == 'address-book') { %> tab-cur<% } %>"> <li class="tab<% if (cur_tab == 'address-book') { %> tab-cur<% } %>">
<a href="{{ SITE_ROOT }}sysadmin/#address-book/"><span class="sf2-icon-contacts"></span>{% trans "Address Book" %}</a> <a href="{{ SITE_ROOT }}sysadmin/#address-book/"><span class="sf2-icon-organization"></span>{% trans "Address Book" %}</a>
</li> </li>
{% endif %} {% endif %}
@@ -683,6 +683,16 @@
</form> </form>
</script> </script>
<script type="text/template" id="address-book-group-add-form-tmpl">
<form id="group-add-form" action="" method="post" class="hide">{% csrf_token %}
<h3 id="dialogTitle">{% trans "New Group" %}</h3>
<label for="group-name">{% trans "Name" %}</label><br />
<input type="text" name="group_name" value="" class="input" id="group-name" /><br />
<p class="error hide"></p>
<input type="submit" class="submit" value="{% trans "Submit" %}" />
</form>
</script>
<script type="text/template" id="group-item-tmpl"> <script type="text/template" id="group-item-tmpl">
<td><a href="{{ SITE_ROOT }}sysadmin/#groups/<%= id %>/libs/"><%- name %></a></td> <td><a href="{{ SITE_ROOT }}sysadmin/#groups/<%= id %>/libs/"><%- name %></a></td>
<td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td> <td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td>
@@ -1023,10 +1033,9 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th width="35%">{% trans "Name" %}</th> <th width="50%">{% trans "Name" %}</th>
<th width="30%">{% trans "Owner" %}</th> <th width="30%">{% trans "Created At" %}</th>
<th width="25%">{% trans "Created At" %}</th> <th width="20%"><!--Operations--></th>
<th width="10%"><!--Operations--></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -1051,10 +1060,9 @@
<table class="hide"> <table class="hide">
<thead> <thead>
<tr> <tr>
<th width="35%">{% trans "Name" %}</th> <th width="50%">{% trans "Name" %}</th>
<th width="30%">{% trans "Owner" %}</th> <th width="30%">{% trans "Created At" %}</th>
<th width="25%">{% trans "Created At" %}</th> <th width="20%"><!--Operations--></th>
<th width="10%"><!--Operations--></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -1091,7 +1099,6 @@
</script> </script>
<script type="text/template" id="address-book-group-item-tmpl"> <script type="text/template" id="address-book-group-item-tmpl">
<td><a href="{{ SITE_ROOT }}sysadmin/#address-book/groups/<%= id %>/"><%- name %></a></td> <td><a href="{{ SITE_ROOT }}sysadmin/#address-book/groups/<%= id %>/"><%- name %></a></td>
<td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td>
<td><time title="<%= time %>"><%= time_from_now %></time></td> <td><time title="<%= time %>"><%= time_from_now %></time></td>
<td> <td>
<a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a> <a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>

View File

@@ -60,7 +60,7 @@
{% if is_pro and user.admin_permissions.can_manage_group %} {% if is_pro and user.admin_permissions.can_manage_group %}
<li class="tab"> <li class="tab">
<a href="{{ SITE_ROOT }}sysadmin/#address-book/"><span class="sf2-icon-contacts"></span>{% trans "Address Book" %}</a> <a href="{{ SITE_ROOT }}sysadmin/#address-book/"><span class="sf2-icon-organization"></span>{% trans "Address Book" %}</a>
</li> </li>
{% endif %} {% endif %}

View File

@@ -15,7 +15,7 @@ define([
template: _.template($("#address-book-group-tmpl").html()), template: _.template($("#address-book-group-tmpl").html()),
pathTemplate: _.template($("#address-book-group-path-tmpl").html()), pathTemplate: _.template($("#address-book-group-path-tmpl").html()),
groupAddFormTemplate: _.template($("#group-add-form-tmpl").html()), groupAddFormTemplate: _.template($("#address-book-group-add-form-tmpl").html()),
addMemberFormTemplate: _.template($('#add-group-member-form-tmpl').html()), addMemberFormTemplate: _.template($('#add-group-member-form-tmpl').html()),
initialize: function() { initialize: function() {
@@ -77,18 +77,9 @@ define([
$form.modal(); $form.modal();
$('#simplemodal-container').css({'height':'auto'}); $('#simplemodal-container').css({'height':'auto'});
$('[name="group_owner"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '268px',
containerCss: {'margin-bottom': '5px'},
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.submit(function() { $form.submit(function() {
var group_name = $.trim($('[name="group_name"]', $form).val()); var group_name = $.trim($('[name="group_name"]', $form).val());
var group_owner = $.trim($('[name="group_owner"]', $form).val()); var group_owner = 'system admin';
var $error = $('.error', $form); var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form); var $submitBtn = $('[type="submit"]', $form);

View File

@@ -13,7 +13,7 @@ define([
id: 'address-book', id: 'address-book',
template: _.template($("#address-book-tmpl").html()), template: _.template($("#address-book-tmpl").html()),
groupAddFormTemplate: _.template($("#group-add-form-tmpl").html()), groupAddFormTemplate: _.template($("#address-book-group-add-form-tmpl").html()),
initialize: function() { initialize: function() {
this.groupCollection = new GroupCollection(); this.groupCollection = new GroupCollection();
@@ -52,18 +52,9 @@ define([
$form.modal(); $form.modal();
$('#simplemodal-container').css({'height':'auto'}); $('#simplemodal-container').css({'height':'auto'});
$('[name="group_owner"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '268px',
containerCss: {'margin-bottom': '5px'},
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.submit(function() { $form.submit(function() {
var group_name = $.trim($('[name="group_name"]', $form).val()); var group_name = $.trim($('[name="group_name"]', $form).val());
var group_owner = $.trim($('[name="group_owner"]', $form).val()); var group_owner = 'system admin';
var $error = $('.error', $form); var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form); var $submitBtn = $('[type="submit"]', $form);