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

[#2189] Change project listing filters and hide status when not present #2241

Merged
merged 1 commit into from
Jun 9, 2016
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
6 changes: 3 additions & 3 deletions akvo/rsr/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class ProjectFilter(django_filters.FilterSet):

iati_status = django_filters.ChoiceFilter(
initial=_('All'),
label=_(u'iati status'),
choices=([('', _('All'))] + codelist_choices(ACTIVITY_STATUS)))
label=_(u'status'),
choices=([('', _('All'))] + codelist_choices(ACTIVITY_STATUS, False)))

title = django_filters.CharFilter(
lookup_type='icontains',
Expand All @@ -167,7 +167,7 @@ class ProjectFilter(django_filters.FilterSet):

class Meta:
model = Project
fields = ['status', 'location', 'organisation', 'category',
fields = ['status', 'iati_status', 'location', 'organisation', 'category',
'sector', 'title', ]


Expand Down
8 changes: 7 additions & 1 deletion akvo/templates/project_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>
<div>
<div class="btn-group">
{% bootstrap_field filter.form.status %}
{% bootstrap_field filter.form.iati_status %}
</div>
</div>
<div>
Expand Down Expand Up @@ -109,7 +109,9 @@ <h1><a href="{% url 'project-main' project.id %}"><i class="fa fa-folder-o"></i>
{% endif %}
<div class="visible-xs-block hidden-sm">
<p>
{% if project.iati_status %}
<span class="detailedInfo">{% trans "Status" %}</span> {{project.show_plain_status}}<br>
{% endif %}
{% if project.last_update %}
<span class="detailedInfo">{% trans "Latest update" %}</span> <a href="{% url 'update-main' project.pk project.last_update.pk %}"><i class="fa fa-calendar-o"></i> {{project.last_update.created_at|date:"d-M-Y"}}</a><br>
{% endif %}
Expand Down Expand Up @@ -140,7 +142,9 @@ <h1><a href="{% url 'project-main' project.id %}"><i class="fa fa-folder-o"></i>
{% endfor %}
<br/>
{% endif %}
{% if project.iati_status %}
<span class="detailedInfo">{% trans "Status" %}</span> {{project.show_plain_status}}<br>
{% endif %}
{% if project.last_update %}
<span class="detailedInfo">{% trans "Latest update" %}</span> <a href="{% url 'update-main' project.pk project.last_update.pk %}"><i class="fa fa-calendar-o"></i> {{project.last_update.created_at|date:"d-M-Y"}}</a><br>
{% endif %}
Expand Down Expand Up @@ -178,7 +182,9 @@ <h4 class="detailedInfo">{% trans "Sectors" %}</h4>
{% endfor %}
{% endif %}
</p>
{% if project.iati_status %}
<h4 class="detailedInfo">{% trans "Status" %}</h4>
{% endif %}
<p class="complete">{{project.show_plain_status}}</p>
<h4 class="detailedInfo">{% trans "Latest update" %}</h4>
{% if project.last_update %}
Expand Down
68 changes: 36 additions & 32 deletions akvo/templates/project_main_tabs/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,42 @@
{{ project.iati_activity_id }}
</li>
{% endif %}
<li>
<span class="detailedInfo">{% trans 'Status' %}</span>
<span class="detailedPoint">{{ project.show_plain_status }}</span>
{% if project.date_start_planned %}
<br/>
<span class="detailedInfo">{% trans 'Start date (planned)' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{ project.date_start_planned|date:"d-M-Y" }}
</span>
{% endif %}
{% if project.date_start_actual %}
<br/>
<span class="detailedInfo">{% trans 'Start date' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{ project.date_start_actual|date:"d-M-Y" }}
</span>
{% endif %}
{% if project.date_end_planned %}
<br/>
<span class="detailedInfo">{% trans 'End date (planned)' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{project.date_end_planned|date:"d-M-Y"}}
</span>
{% endif %}
{% if project.date_end_actual %}
<br/>
<span class="detailedInfo">{% trans 'End date' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{project.date_end_actual|date:"d-M-Y"}}
</span>
{% endif %}
</li>
{% if project.iati_status or project.date_start_planned or project.date_start_actual or project.date_end_planned or project.date_end_actual %}
<li>
{% if project.iati_status %}
<span class="detailedInfo">{% trans 'Status' %}</span>
<span class="detailedPoint">{{ project.show_plain_status }}</span>
{% endif %}
{% if project.date_start_planned %}
<br/>
<span class="detailedInfo">{% trans 'Start date (planned)' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{ project.date_start_planned|date:"d-M-Y" }}
</span>
{% endif %}
{% if project.date_start_actual %}
<br/>
<span class="detailedInfo">{% trans 'Start date' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{ project.date_start_actual|date:"d-M-Y" }}
</span>
{% endif %}
{% if project.date_end_planned %}
<br/>
<span class="detailedInfo">{% trans 'End date (planned)' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{project.date_end_planned|date:"d-M-Y"}}
</span>
{% endif %}
{% if project.date_end_actual %}
<br/>
<span class="detailedInfo">{% trans 'End date' %}</span>
<span class="detailedPoint">
<i class="fa fa-calendar-o"></i> {{project.date_end_actual|date:"d-M-Y"}}
</span>
{% endif %}
</li>
{% endif %}
{% if project.has_relations %}
<li>
<span class="detailedInfo">{% trans 'Hierarchy' %}</span>
Expand Down
5 changes: 3 additions & 2 deletions akvo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,12 @@ def filter_query_string(qs):
u'&'.join([u'{}={}'.format(k, u''.join(v)) for (k, v) in q.items()])).encode('utf-8')


def codelist_choices(codelist):
def codelist_choices(codelist, show_code=True):
"""
Based on a model from the codelists app, returns a list of tuples with the available choices.

:param codelist: Codelist from codelists store
:param show_code: Show the code (e.g. '1 - ..') in front of the name, True by default
:return: List of tuples with available choices, tuples in the form of (code, name)
"""
name_index = 0
Expand All @@ -500,7 +501,7 @@ def codelist_choices(codelist):
name_index = index
break

if name_index > 0:
if name_index > 0 and show_code:
return [(cl[0], '%s - %s' % (cl[0], cl[name_index])) for cl in codelist[1:]]
else:
return [(cl[0], cl[name_index]) for cl in codelist[1:]]
Expand Down