Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #1643] Project partner page now sorted. #1644

Merged
merged 1 commit into from
Jul 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions akvo/rsr/templatetags/rsr_filters.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
# -*- coding: utf-8 -*-
"""
Akvo RSR is covered by the GNU Affero General Public License.

from django import template
register = template.Library()
See more details in the license.txt file located at the root folder of the Akvo RSR module.
For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
"""

from django.conf import settings
import datetime
import time

import time, datetime
from django import template
from django.conf import settings
from decimal import Decimal, ROUND_HALF_UP

register = template.Library()

DECIMAL_PLACES = getattr(settings, 'DECIMALS_DECIMAL_PLACES', 2)


@register.filter
def get_item(dictionary, key):
"""Enable lookup in dicts."""
return dictionary.get(key)


@register.filter
def string_to_date(value):
try:
Expand Down Expand Up @@ -64,4 +76,3 @@ def rsr_sorted_set(iterable):
set_list = list(frozenset(iterable))
set_list.sort()
return set_list

13 changes: 10 additions & 3 deletions akvo/rsr/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from ..forms import ProjectUpdateForm
from ..filters import remove_empty_querydict_items, ProjectFilter
from ..models import Invoice, Project, ProjectUpdate
from ..models import Invoice, Project, ProjectUpdate, Organisation
from ...utils import pagination, filter_query_string
from ...iati.iati_export import IatiXML
from .utils import apply_keywords, org_projects
Expand Down Expand Up @@ -455,13 +455,20 @@ def search(request):
context = {'projects': Project.objects.published()}
return render(request, 'project_search.html', context)


def partners(request, project_id):
"""."""
project = get_object_or_404(Project, pk=project_id)
partners = _get_project_partners(project)
partner_vals = project.all_partners().values()
for partner in partner_vals:
id_key = "id".decode('unicode-escape')
p = Organisation.objects.get(pk=partner[id_key])
partner['partner_types'] = p.has_partner_types(project)
partner_types = _get_project_partners(project)
context = {
'project': project,
'partners': partners
'partner_vals': partner_vals,
'partner_types': partner_types
}
return render(request, 'project_partners.html', context)

Expand Down
51 changes: 27 additions & 24 deletions akvo/templates/project_partners.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,40 @@
<section class="projectPartners">
<div class="container">
<h2 class="title">{% trans "Project partners" %}</h2>
{% for partner, types in partners.items %}
<div class="row verticalPadding projectPartners">
{% for partner in partner_vals|dictsort:"name" %}
<div class="row verticalPadding projectPartners">
{% if partner.logo %}
<div class="col-sm-2 img">
<a href='{% url 'organisation-main' partner.pk %}'>
<img src='{{partner.logo.url}}' class='extra-partner-entry'>
</a>
</div>
<div class="col-sm-6">
<div class="col-sm-2 img">
<a href='{% url 'organisation-main' partner.id %}'>
<img src='{{partner.logo.url}}' class='extra-partner-entry'>
</a>
</div>
<div class="col-sm-6">
{% else %}
<div class="col-sm-8">
<div class="col-sm-8">
{% endif %}
<a href='{% url 'organisation-main' partner.pk %}' class="org-link">
<i class="fa fa-users"></i>
<h2>{{partner}}</h2>
</a>
</div>
<div class="col-sm-4">
<h4 class="detailedInfo">{% trans "Roles" %}</h4>
<ul>
{% for type in types %}
<a href='{% url 'organisation-main' partner.id %}' class="org-link">
<i class="fa fa-users"></i>
<h2>{{partner.name}}</h2>
</a>
</div>
<div class="col-sm-4">
<h4 class="detailedInfo">{% trans "Roles" %}</h4>
<ul>
{% for type in partner.partner_types %}
<li>{{type|title}} {% trans "partner" %}</li>
{% comment %}
{% if forloop.first %}
<li>{{type|title}} {% trans "partner" %}</li>
<li>{{type|title}} {% trans "partner" %}{% if forloop.last %}.{% else %},{% endif %}</li>
{% else %}
<li>{{type}} {% trans "partner" %}</li>
<li>{{type}} {% trans "partner" %}{% if forloop.last %}.{% else %},{% endif %}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endcomment %}
{% endfor %}
</ul>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</section>
{% include "partials/project_footer.html" %}
Expand Down