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