Commit 11006465 by Dudás Ádám

school: refactored group_show view

parent 93f6d382
from datetime import datetime
from itertools import chain
from django.core.exceptions import PermissionDenied, ValidationError
from django.conf import settings
from django.contrib.auth.decorators import login_required
......@@ -153,27 +154,24 @@ def language(request, lang):
def group_show(request, gid):
user = request.user
group = get_object_or_404(Group, id=gid)
mytemplates = [
t for t in Template.objects.filter(owner=request.user).all()]
noshare = True
for i, t in enumerate(mytemplates):
mytemplates = Template.objects.filter(owner=request.user, state='READY')
for t in mytemplates:
t.myshares = t.share_set.filter(group=group)
if t.myshares.exists():
noshare = False
mytemplates[i] = t
publictemplates = [
t for t in Template.objects.filter(public=True, state='READY').all()]
for i, t in enumerate(publictemplates):
publictemplates = Template.objects.filter(public=True, state='READY')
for t in publictemplates:
t.myshares = t.share_set.filter(group=group)
if t.myshares.exists():
noshare = False
publictemplates[i] = t
all_templates = chain(mytemplates, publictemplates)
has_share = any([t.myshares.exists() for t in all_templates])
return render_to_response("show-group.html", RequestContext(request, {
'group': group,
'members': group.members.all(),
'mytemplates': mytemplates,
'publictemplates': publictemplates,
'noshare': noshare,
'noshare': not has_share,
'userdetails': UserCloudDetails.objects.get(user=request.user),
'owners': group.owners.all(),
}))
......
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 sign in to comment