clarify team list page
This commit is contained in:
parent
efcc2fd405
commit
d3d091d4df
2 changed files with 10 additions and 12 deletions
|
@ -22,19 +22,15 @@
|
|||
{% if teams.exists %}
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Users</th>
|
||||
<th>Groups</th>
|
||||
<th class="col-md-2">Name</th>
|
||||
<th class="col-md-5">Users</th>
|
||||
<th class="col-md-5">Groups</th>
|
||||
</tr>
|
||||
{% for team in teams %}
|
||||
<tr>
|
||||
<td><a href="{% url 'show-team' team.pk %}"><b>{{ team }}</b></a></td>
|
||||
<td>{{ team.users|first_few:'user' }}</td>
|
||||
<td>{{ team.groups|first_few:'group' }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'edit-team' team.pk %}" class="btn btn-primary btn-xs">Edit</a>
|
||||
<a href="#" data-item="team" data-action="{% url 'delete-team' team.pk %}" data-toggle="modal" data-target="#confirm-delete" class="btn btn-danger btn-xs">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -15,14 +15,16 @@ def boolean(value):
|
|||
+ glyph + '" style="vertical-align: middle;"></span>')
|
||||
|
||||
@register.filter
|
||||
def first_few(items, arg='item'):
|
||||
def first_few(items, arg='item', max_items=5):
|
||||
if items.exists():
|
||||
if items.count() < 4:
|
||||
if items.count() <= max_items:
|
||||
return ', '.join(map(lambda x: x.__str__(), items.all()))
|
||||
else:
|
||||
r = ', '.join(map(lambda x: x.__str__(), items.all()[0:3]))
|
||||
plural = 's' if items.count() > 4 else ''
|
||||
r += ', ... (%s other%s)' % (items.count() - 3, plural)
|
||||
r = ', '.join(map(lambda x: x.__str__(),
|
||||
items.all()[0:max_items-1]))
|
||||
plural = 's' if items.count() > max_items else ''
|
||||
r += ', ... (%s other%s)' \
|
||||
% (items.count() - max_items + 1, plural)
|
||||
return r
|
||||
else:
|
||||
return 'no ' + arg + 's'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue