Skip to content

Commit

Permalink
[#994] Updated the report page and project header
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Jan 19, 2015
1 parent 0e94e56 commit b0e95dc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
4 changes: 4 additions & 0 deletions akvo/rsr/iati/sector_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
115: (41081,),
116: (41082,),
122: (41020,),
123: (25010,),
124: (25010,),
125: (31130,),
126: (15150,),
24: (),
21: (),
25: (),
Expand Down
12 changes: 12 additions & 0 deletions akvo/rsr/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,18 @@ def siblings(self):
return (Project.objects.filter(related_projects__related_project=self, related_projects__relation=3) |
Project.objects.filter(related_to_projects__project=self, related_to_projects__relation=3)).distinct()

def has_results(self):
for result in self.results.all():
if result.title or result.type or result.aggregation_status or result.description:
return True
return False

def has_indicators(self):
for result in self.results.all():
if result.indicators.all():
return True
return False

class Meta:
app_label = 'rsr'
verbose_name = _(u'project')
Expand Down
5 changes: 5 additions & 0 deletions akvo/rsr/models/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def __unicode__(self):
def iati_type(self):
return dict(codelists.RESULT_TYPE)[self.type] if self.type else ""

def has_info(self):
if self.title or self.type or self.aggregation_status or self.description:
return True
return False

class Meta:
app_label = 'rsr'
verbose_name = _(u'result')
Expand Down
4 changes: 3 additions & 1 deletion akvo/templates/partials/project_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ <h1><a href="{% url 'project-main' project.pk %}">{{project.title}}</a></h1>
<a href="#" class="btn btn-primary">Follow project</a>
{% url 'project-report' project.pk as report_url %}
{% if not request.get_full_path == report_url %}
<a href="{% url 'project-report' project.pk %}" class="btn"><i class="fa fa-th-list"></i> Show full data report</a>
<a href="{% url 'project-report' project.pk %}" class="btn"><i class="fa fa-bar-chart"></i> Show full data report</a>
{% else %}
<a href="javascript:window.print();" class="btn"><i class="fa fa-print"></i> Print this page</a>
{% endif %}
</nav>
</div>
Expand Down
55 changes: 34 additions & 21 deletions akvo/templates/project_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h4>{% trans "Identifiers" %}</h4>
{% for partnership in project.partnerships.all %}
{% if partnership.internal_id %}
<tr>
<th scope="row">{{partnership.organisation.name}} {% trans "ID" %}</th>
<th scope="row">{{partnership.organisation}} {% trans "ID" %}</th>
<td>{{partnership.internal_id}}</td>
</tr>
{% endif %}
Expand Down Expand Up @@ -435,21 +435,41 @@ <h4>{% trans "Conditions" %}</h4>
</tbody>
</table>
{% endif %}
{% if project.results.all %}
{% if project.has_results %}
<h4>{% trans "Results" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Result" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Aggregation Status" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
{% for result in project.results.all %}
{% if result.has_info %}
<tr>
<td>{{result.title}}</td>
<td>{{result.iati_type}}</td>
<td>{{result.aggregation_status|yesno:"Aggregatable,Not Aggregatable,"}}</td>
<td>{{result.description}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif%}
{% if project.has_indicators %}
<h4>{% trans "Indicators" %}</h4>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Result" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Aggregation Status" %}</th>
<th>{% trans "Indicator" %}</th>
<th>{% trans "Measure" %}</th>
<th>{% trans "Ascending" %}</th>
<th>{% trans "Baseline" %}</th>
<th>{% trans "Baseline Year" %}</th>
<th>{% trans "Baseline Value" %}</th>
<th>{% trans "Period Start" %}</th>
<th>{% trans "Period End" %}</th>
<th>{% trans "Target Value" %}</th>
Expand All @@ -458,23 +478,18 @@ <h4>{% trans "Results" %}</h4>
</thead>
<tbody>
{% for result in project.results.all %}
{% for indicator in result.indicators.all %}
<tr>
<td>{{result.title}}</td>
<td>{{result.iati_type}}</td>
<td>{{result.aggregation_status|yesno:"Aggregatable,Not Aggregatable,"}}</td>
{% for indicator in result.indicators.all %}
{% if not forloop.first %}
<tr><td></td><td></td><td></td>
{% endif %}
<td>{{indicator.title}}</td>
<td>{{indicator.iati_measure}}</td>
<td>{{indicator.ascending|yesno:"Ascending,Descending,"}}</td>
<td>{{indicator.baseline_comment}}</td>
<td>{{indicator.baseline_year|default_if_none:""}}</td>
<td>{{indicator.baseline_value}}</td>
<td>{% if indicator.baseline_year %}{% trans "In" %}: {{indicator.baseline_year}}{% endif %}
{{indicator.baseline_value}}
{% if indicator.baseline_comment %}({{indicator.baseline_comment}}){% endif %}
</td>
{% for period in indicator.periods.all %}
{% if not forloop.first %}
<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<tr><td></td><td></td><td></td><td></td><td></td><td></td>
{% endif %}
<td>{{period.period_start|default_if_none:""}}</td>
<td>{{period.period_end|default_if_none:""}}</td>
Expand All @@ -483,11 +498,9 @@ <h4>{% trans "Results" %}</h4>
{% empty %}
<td></td><td></td><td></td><td></td>
{% endfor %}
{% empty %}
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
Expand Down

0 comments on commit b0e95dc

Please sign in to comment.