Commit 7ea887ad authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Display only enabled groups in group search

parent 42c3a3b1
......@@ -32,9 +32,10 @@
</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="">
......@@ -131,6 +132,7 @@
{% if is_search %}
<h2>No groups found!</h2>
{% endif %}
{% endif %}
{% endif %}
{% endwith %}
</div>
{% endblock %}
......@@ -44,11 +44,17 @@ def dkeys(d):
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
......@@ -687,7 +687,11 @@ def group_add(request, kind_name='default'):
@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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment