Commit c3ea25b0 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Use Resource object getter methods instead of ResourcePresentation

parent 789b2f5c
......@@ -234,7 +234,9 @@ class DjangoBackend(BaseBackend):
@safe
def get_resource_usage(self, user_id):
user = self._lookup_user(user_id)
data = get_quota((user,))
data = get_quota(user)
if not data:
return ()
resources = []
append = resources.append
for t in data:
......@@ -247,6 +249,12 @@ class DjangoBackend(BaseBackend):
d = dict(name=name,
description=resource.desc,
unit=resource.unit or '',
help_text=resource.help_text,
help_text_input_each=resource.help_text_input_each,
is_abbreviation=resource.is_abbreviation,
report_desc=resource.report_desc,
placeholder=resource.placeholder,
verbose_name=resource.verbose_name,
maxValue=quantity + capacity,
currValue=quantity + imported - released - exported + returned)
append(d)
......@@ -302,4 +310,4 @@ class DjangoBackend(BaseBackend):
# TODO return information for unknown ids
q = Resource.objects.filter(service__id=service_id,
id__in=ids)
q.delete()
\ No newline at end of file
q.delete()
......@@ -4,7 +4,6 @@
{% block page.body %}
{% with object.project.approved_members as approved_members %}
{% with resource_catalog|populated_resource_catalog as resource_catalog%}
<div class="projects">
......@@ -95,15 +94,12 @@
{% if object.projectresourcegrant_set.all %}
<dl class="alt-style">
{% for rp in object.projectresourcegrant_set.all %}
{% with resource_catalog|lookup:'resources' as resource_info %}
{% with rp.resource|to_unicode as resource_name %}
{% with resource_info|lookup:resource_name as decorated_resource %}
<dt>
Max {% if decorated_resource.is_abbreviation %}{{ decorated_resource.verbose_name|upper }}{% else %}{{ decorated_resource.verbose_name }}{% endif %}{% if not q.unit %}s {% endif %} per user
Max {% if rp.resource.is_abbreviation %}{{ rp.resource.verbose_name|upper }}{% else %}{{ rp.resource.verbose_name }}{% endif %}{% if not q.unit %}s {% endif %} per user
</dt>
<dd>
{% if rp.member_capacity %}
{% if decorated_resource.unit %}
{% if rp.resource.unit %}
{{ rp.member_capacity|sizeof_fmt }}
{% else %}
{{ rp.member_capacity|isinf }}
......@@ -112,9 +108,6 @@
Unlimited
{% endif %}
</dd>
{% endwith %}
{% endwith %}
{% endwith %}
{% empty %}
No resources
{% endfor %}
......@@ -218,5 +211,4 @@
</div>
{% endwith %}
{% endwith %}
{% endblock %}
......@@ -3,12 +3,12 @@
{% load filters %}
{% block page.body %}
{% with resource_usage|populated_resource_usage as resource_usage %}
<div class="maincol {% block innerpage.class %}{% endblock %}">
<div class="stats clearfix">
<ul>
{% for rname, rdata in resource_usage.resources.items %}
<li class="clearfix {{ rdata.load_class }} {{ rname|get_value_after_dot }}">
{% for rdata in resource_usage %}
{{rdata}}
<li class="clearfix {{ rdata.load_class }} {{ rdata.name|get_value_after_dot }}">
<div class="img-wrap">&nbsp;</div>
<div class="info">
<h3>{{ rdata.report_desc }}</h3>
......@@ -40,5 +40,4 @@
</div>
</div>
{% endwith %}
{% endblock %}
......@@ -315,8 +315,3 @@ resource_presentation = ResourcePresentation(RESOURCES_PRESENTATION_DATA)
def populated_resource_catalog(resource_catalog):
resource_presentation.populate_resource_data(resource_catalog)
return resource_presentation
@register.filter
def populated_resource_usage(resource_usage):
resource_presentation.populate_report_data(resource_usage)
return resource_presentation
\ No newline at end of file
......@@ -1061,16 +1061,6 @@ def project_update(request, application_id):
@login_required
@transaction.commit_manually
def project_detail(request, application_id):
resource_catalog = None
result = callpoint.list_resources()
if not result.is_success:
messages.error(
request,
'Unable to retrieve system resources: %s' % result.reason
)
else:
resource_catalog = result.data
addmembers_form = AddProjectMembersForm()
if request.method == 'POST':
addmembers_form = AddProjectMembersForm(request.POST)
......@@ -1109,7 +1099,6 @@ def project_detail(request, application_id):
object_id=application_id,
template_name='im/projects/project_detail.html',
extra_context={
'resource_catalog':resource_catalog,
'sorting':sorting,
'addmembers_form':addmembers_form
}
......
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