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

[#1563] Add option for showing all objects on Akvo Pages maps #1567

Merged
merged 1 commit into from
May 12, 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
2 changes: 1 addition & 1 deletion akvo/rsr/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ class PartnerSiteAdmin(TimestampsAdminDisplayMixin, admin.ModelAdmin):
(u'HTTP', dict(fields=('hostname', 'cname', 'custom_return_url', 'custom_return_url_text',
'piwik_id',))),
(u'Style and content',
dict(fields=('about_box', 'about_image', 'custom_css', 'custom_logo',
dict(fields=('all_maps', 'about_box', 'about_image', 'custom_css', 'custom_logo',
'custom_favicon',))),
(u'Languages and translation', dict(fields=('default_language', 'ui_translation',
'google_translation',))),
Expand Down
26 changes: 26 additions & 0 deletions akvo/rsr/migrations/0007_auto_20150512_1320.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('rsr', '0006_auto_20150506_1245'),
]

operations = [
migrations.AddField(
model_name='partnersite',
name='all_maps',
field=models.BooleanField(default=False, verbose_name='Show all projects, updates and organisations on the maps.'),
preserve_default=True,
),
migrations.AlterField(
model_name='organisation',
name='new_organisation_type',
field=models.IntegerField(default=22, help_text='Check that this field is set to an organisation type that matches your organisation.', db_index=True, verbose_name='IATI organisation type', choices=[(10, '10 - Government'), (15, '15 - Other Public Sector'), (21, '21 - International NGO'), (22, '22 - National NGO'), (23, '23 - Regional NGO'), (30, '30 - Public Private Partnership'), (40, '40 - Multilateral'), (60, '60 - Foundation'), (70, '70 - Private Sector'), (80, '80 - Academic, Training and Research')]),
preserve_default=True,
),
]
3 changes: 3 additions & 0 deletions akvo/rsr/models/partner_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def show_keywords(self):
'Keyword', verbose_name=_(u'keywords'), related_name='partnersites', blank=True)
exclude_keywords = models.BooleanField(
_(u'Exclude projects with selected keyword(s)'), default=False)
all_maps = models.BooleanField(
_(u'Show all projects, updates and organisations on the maps.'), default=False
)

def __unicode__(self):
"""Unicode representation."""
Expand Down
9 changes: 7 additions & 2 deletions akvo/rsr/views/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,25 @@ def directory(request):
filter_class = show_filter_class(qs, ['location', ])

# Yank Organisation collection
f = OrganisationFilter(qs, queryset=_organisation_directory_coll(request))
all_organisations = _organisation_directory_coll(request)
f = OrganisationFilter(qs, queryset=all_organisations)

# Build page
page = request.GET.get('page')
page, paginator, page_range = pagination(page, f.qs.distinct(), 10)

# Get organisations to be displayed on the map
map_orgs = all_organisations if request.rsr_page and request.rsr_page.all_maps else page

return render(request, 'organisation_directory.html', {
'orgs_count': f.qs.distinct().count(),
'filter': f,
'page': page,
'paginator': paginator,
'page_range': page_range,
'show_filters': filter_class,
'q': filter_query_string(qs)
'q': filter_query_string(qs),
'map_organisations': map_orgs,
})


Expand Down
9 changes: 7 additions & 2 deletions akvo/rsr/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ def directory(request):
sorting = sort_by if sort_by in available_sorting else '-last_modified_at'

# Yank project collection
f = ProjectFilter(qs, queryset=_project_directory_coll(request))
all_projects = _project_directory_coll(request)
f = ProjectFilter(qs, queryset=all_projects)
sorted_projects = f.qs.distinct().order_by(sorting)

# Build page
page = request.GET.get('page')
page, paginator, page_range = pagination(page, sorted_projects, 10)

# Get the current org filter for typeahead
org_filter = request.GET.get('organisation', '')
org_filter = request.GET.get('organisation', '')

# Get projects to be displayed on the map
map_projects = all_projects if request.rsr_page and request.rsr_page.all_maps else page

context = {
'project_count': sorted_projects.count(),
Expand All @@ -103,6 +107,7 @@ def directory(request):
'q': filter_query_string(qs),
'sorting': sorting,
'current_org': org_filter,
'map_projects': map_projects,
}
return render(request, 'project_directory.html', context)

Expand Down
11 changes: 8 additions & 3 deletions akvo/rsr/views/project_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,26 @@ def directory(request):
filter_class = show_filter_class(qs, ['location', 'partner', 'sector', ])

# Yank projectupdate collection
f = ProjectUpdateFilter(qs, queryset=_update_directory_coll(request))
all_updates = _update_directory_coll(request)
f = ProjectUpdateFilter(qs, queryset=all_updates)

# Build page
page = request.GET.get('page')
page, paginator, page_range = pagination(page, f.qs.distinct(), 10)

# Get updates to be displayed on the map
map_updates = all_updates if request.rsr_page and request.rsr_page.all_maps else page

return render(request, 'update_directory.html', {
'updates_count': f.qs.distinct().count(),
'filter': f,
'page': page,
'page_range': page_range,
'paginator': paginator,
'show_filters': filter_class,
'q': filter_query_string(qs)
})
'q': filter_query_string(qs),
'map_updates': map_updates,
})


def main(request, project_id, update_id):
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/organisation_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block maincontent %}

<section id="map" class="touch-navbar orgMap">
{% coll_map page '100%' '100%' %}
{% coll_map map_organisations '100%' '100%' %}
</section>

<form id="filterForm" action="" method="get" accept-charset="uft-8" class="searchContainer">
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/project_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block maincontent %}

<section id="map" class="touch-navbar">
{% coll_map page '100%' '100%' %}
{% coll_map map_projects '100%' '100%' %}
</section>
<form id="filterForm" action="" method="get" accept-charset="uft-8" class="searchContainer">
<section id="search-filter">
Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/update_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block maincontent %}

<section id="map" class="touch-navbar">
{% coll_map page '100%' '100%' %}
{% coll_map map_updates '100%' '100%' %}
</section>
<form id="filterForm" action="" method="get" accept-charset="uft-8" class="searchContainer">
<section id="search-filter">
Expand Down