Commit a67bb6a1 by Őry Máté

school: group show add csrf, etc

parent 3b466b6c
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<ul> <ul>
{% for i in t.myshares %} {% for i in t.myshares %}
<li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%) <li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%)
<form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post"><input type="submit" value="unshare"/></form> <form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post">{% csrf_token %}<input type="submit" value="unshare"/></form>
</li> </li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<ul> <ul>
{% for i in t.myshares %} {% for i in t.myshares %}
<li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%) <li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%)
<form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post"><input type="submit" value="unshare"/></form> <form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post">{% csrf_token %}<input type="submit" value="unshare"/></form>
</li> </li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</div> </div>
</div> </div>
<div class="boxes"> <div class="boxes">
{% if noshare %}
<div id="new-wm-tooltip" style="position:absolute"> <div id="new-wm-tooltip" style="position:absolute">
<div id="new-wm-tooltip-container"> <div id="new-wm-tooltip-container">
<p> <p>
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
<div id="new-wm-tooltip-tail"></div> <div id="new-wm-tooltip-tail"></div>
</div> </div>
</div> </div>
{% endif %}
{% include "box-templatelist.html" %} {% include "box-templatelist.html" %}
</div> </div>
{% endblock %} {% endblock %}
...@@ -154,18 +154,24 @@ def group_show(request, gid): ...@@ -154,18 +154,24 @@ def group_show(request, gid):
user = request.user user = request.user
group = get_object_or_404(Group, id=gid) group = get_object_or_404(Group, id=gid)
mytemplates = [t for t in Template.objects.filter(owner=request.user).all()] mytemplates = [t for t in Template.objects.filter(owner=request.user).all()]
noshare = True
for i, t in enumerate(mytemplates): for i, t in enumerate(mytemplates):
t.myshares = t.share_set.filter(group=group) t.myshares = t.share_set.filter(group=group)
if t.myshares.exists():
noshare = False
mytemplates[i] = t mytemplates[i] = t
publictemplates = [t for t in Template.objects.filter(public=True, state='READY').all()] publictemplates = [t for t in Template.objects.filter(public=True, state='READY').all()]
for i, t in enumerate(publictemplates): for i, t in enumerate(publictemplates):
t.myshares = t.share_set.filter(group=group) t.myshares = t.share_set.filter(group=group)
if t.myshares.exists():
noshare = False
publictemplates[i] = t publictemplates[i] = t
return render_to_response("show-group.html", RequestContext(request,{ return render_to_response("show-group.html", RequestContext(request,{
'group': group, 'group': group,
'members': group.members.all(), 'members': group.members.all(),
'mytemplates': mytemplates, 'mytemplates': mytemplates,
'publictemplates': publictemplates, 'publictemplates': publictemplates,
'noshare': noshare,
})) }))
@login_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 sign in to comment