</ul>
{% endif %}
+ {% with object_list|enabled:is_search as object_list %}
{% if object_list %}
- {% with object_list|filter_groups:user as d %}
- {% with d|lookup:'mine' as mine %}
+ {% with object_list|split:user as d %}
+ {% with d|lookup:'own' as mine %}
{% if mine %}
<div class="full-dotted">
<table class="alt-style table_sorting" id="">
{% if is_search %}
<h2>No groups found!</h2>
{% endif %}
- {% endif %}
+ {% endif %}
+ {% endwith %}
</div>
{% endblock %}
return d.keys()
@register.filter
-def filter_groups(object_list, user):
+def enabled(object_list, is_search):
+ if not is_search:
+ return object_list
+ return [g for g in object_list if g.is_enabled]
+
+@register.filter
+def split(object_list, user):
try:
d = {}
- d['mine'] = filter(lambda o: user in o.owner.all(), object_list)
- d['other'] = list(set(object_list) - set(d['mine']))
+ d['own'] = [g for g in object_list if user in g.owner.all()]
+ d['other'] = list(set(object_list) - set(d['own']))
return d
except:
- return {'mine':object_list, 'other':[]}
+ return {'own':object_list, 'other':()}
\ No newline at end of file
@login_required
def group_list(request):
list = request.user.astakos_groups.select_related().all()
- return object_list(request, queryset=list)
+ return object_list(request, queryset=list,
+ extra_context=dict(
+ is_search=False
+ )
+ )
@signed_terms_required
@login_required