Commit 5433ef99 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Display resource limit details

parent 2d4be2bc
......@@ -193,8 +193,7 @@ class AstakosGroup(Group):
@property
def quota(self):
d = defaultdict(int)
query = self.astakosgroupquota_set.select_related().all()
for q in query:
for q in self.astakosgroupquota_set.select_related().all():
d[q.resource] += q.uplimit
return d
......@@ -297,9 +296,9 @@ class AstakosUser(User):
@property
def quota(self):
d = defaultdict(int)
for q in self.astakosuserquota_set.all():
for q in self.astakosuserquota_set.select_related().all():
d[q.resource.name] += q.uplimit
for m in self.membership_set.all():
for m in self.membership_set.select_related().all():
if not m.is_approved:
continue
g = m.group
......
......@@ -5,26 +5,39 @@
{% block page.body %}
<div class="maincol {% block innerpage.class %}{% endblock %}">
<div class="section">
{% if quota %}
<table class="zebra-striped id-sorted">
<thead>
<tr>
<th>Resource</th>
<th>Limit</th>
</tr>
</thead>
<tbody>
{% for k in quota|dkeys %}
<tr>
<td>{{ k }}</td>
<td>{{ quota|lookup:k }}</td>
</tr>
{% for k, v in user.quota|items %}
<strong>{{k}}</strong>
<table class="zebra-striped id-sorted">
<!--
<thead>
<tr>
<th>Limit (Group)</th>
</tr>
</thead>
-->
<tbody>
{% for m in user.membership_set.select_related.all %}
{% if m.group.is_enabled %}
{% with m.group.quota as quota %}
{% if quota %}
{% for kk, vv in quota|items %}
{% if k == kk %}
<tr>
<td>{{ vv }} ({{m.group.name}})</td>
</tr>
{% endif %}
{% endfor %}
{% endif %}
{% endwith %}
{% endif %}
{% endfor %}
<tr>
<td><strong>{{ v }}</strong></td>
</tr>
<tr/>
</tbody>
</table>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No policies</p>
{% endif %}
</div>
</div>
{% endblock %}
......@@ -34,6 +34,8 @@
import calendar
import datetime
from collections import defaultdict
from django import template
from django.core.paginator import Paginator, EmptyPage
from django.db.models.query import QuerySet
......@@ -126,4 +128,10 @@ def paginate(l, args):
def concat(str1, str2):
if not str2:
return str(str1)
return '%s%s%s' % (str1, DELIM, str2)
\ No newline at end of file
return '%s%s%s' % (str1, DELIM, str2)
@register.filter
def items(d):
if isinstance(d, defaultdict):
return d.iteritems()
return d
\ No newline at end of file
......@@ -1029,8 +1029,7 @@ def disapprove_member(request, membership):
def resource_list(request):
return render_response(
template='im/astakosuserquota_list.html',
context_instance=get_context(request),
quota=request.user.quota)
context_instance=get_context(request))
def group_create_list(request):
......
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