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