Skip to content

Commit

Permalink
[#1633] Refactor listing of partner types
Browse files Browse the repository at this point in the history
Simplificate the code, remove duplicate listing of partner
type and fix punctuation and capitalization.
  • Loading branch information
zzgvh committed Aug 18, 2015
1 parent e8cb0f0 commit 9e1622d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
8 changes: 3 additions & 5 deletions akvo/rsr/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,15 @@ def search(request):
def partners(request, project_id):
"""."""
project = get_object_or_404(Project, pk=project_id)
partner_vals = project.all_partners().values()
for partner in partner_vals:
partners = project.all_partners().values()
for partner in partners:
id_key = "id".decode('unicode-escape')
p = Organisation.objects.get(pk=partner[id_key])
partner['partner_types'] = p.has_partner_types(project)
partner['organisation_obj'] = p
partner_types = _get_project_partners(project)
context = {
'project': project,
'partner_vals': partner_vals,
'partner_types': partner_types
'partners': partners,
}
return render(request, 'project_partners.html', context)

Expand Down
12 changes: 5 additions & 7 deletions akvo/templates/project_partners.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<section class="projectPartners">
<div class="container">
<h2 class="title">{% trans "Project partners" %}</h2>
{% for partner in partner_vals|dictsort:"name" %}
{% for partner in partners|dictsort:"name" %}
<div class="row verticalPadding projectPartners">
<div class="col-sm-2 img">
<a href='{% url 'organisation-main' partner.id %}'>{% img partner.organisation_obj 120 120 partner.name %}</a>
Expand All @@ -25,12 +25,10 @@ <h2>{{ partner.name }}</h2>
<h4 class="detailedInfo">{% trans "Roles" %}</h4>
<ul>
{% for type in partner.partner_types %}
<li>{{ type|title }} {% trans "partner" %}</li>
{% if forloop.first %}
<li>{{type|title}} {% trans "partner" %}{% if forloop.last %}.{% else %},{% endif %}</li>
{% else %}
<li>{{type|title}} {% trans "partner" %}</li>
{% endif %}
<li>
{% if forloop.first %}{{type|title}}{% else %}{{type}}{% endif %}
{% trans "partner" %}{% if forloop.last %}.{% else %},{% endif %}
</li>
{% endfor %}
</ul>
</div>
Expand Down

0 comments on commit 9e1622d

Please sign in to comment.