Merge lp:~dalkvist/ppvalbok/gpx-support into lp:ppvalbok

Proposed by Mattias Dalkvist
Status: Merged
Merged at revision: not available
Proposed branch: lp:~dalkvist/ppvalbok/gpx-support
Merge into: lp:ppvalbok
Diff against target: None lines
To merge this branch: bzr merge lp:~dalkvist/ppvalbok/gpx-support
Reviewer Review Type Date Requested Status
Daniel Nyström Pending
Review via email: mp+6462@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mattias Dalkvist (dalkvist) wrote :

added links from municipality pages to gps files with the sations

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ballot_system/urls.py'
2--- ballot_system/urls.py 2009-05-11 11:48:16 +0000
3+++ ballot_system/urls.py 2009-05-11 19:04:44 +0000
4@@ -8,6 +8,7 @@
5 url(r'^email/([0-9]+)/$', views.email, name="email"),
6 url(r'^valj-kommun/([0-9]{5})/$', views.choose_municipality, name="choose-municipality"),
7 url(r'^kommun/([0-9a-z_-]+)/$', views.municipality, name="municipality"),
8+ url(r'^kommun/([0-9a-z_-]+)/([0-9a-z_-]+).gpx$', views.gpx, name="gpx"),
9 url(r'^kommun/([0-9a-z_-]+)/fortidslokal/([0-9a-z_-]+)/$', views.earlystation, name="earlystation"),
10 url(r'^kommun/([0-9a-z_-]+)/fortidslokal/([0-9a-z_-]+)/save/$', views.save_earlystation, name="earlystation-save"),
11 url(r'^kommun/([0-9a-z_-]+)/fortidslokal/([0-9a-z_-]+)/tack/$', views.book_earlystation_thanks, name="earlystation-thanks"),
12
13=== modified file 'ballot_system/views.py'
14--- ballot_system/views.py 2009-05-11 11:48:16 +0000
15+++ ballot_system/views.py 2009-05-11 19:04:44 +0000
16@@ -102,10 +102,34 @@
17 return direct_to_template(request, 'view_municipality.html',
18 {'municipality_name': municipality.name,
19 'municipality_slug': municipality.slug,
20+ 'gpx': municipality.slug,
21+ 'gpxall': municipality.slug + '-all',
22+ 'gpxearly': municipality.slug + '-early',
23 'early_stations': earlystations,
24 'stations': stations,
25 'may_edit': stations[0].region.regiondata.user_may_edit(request.user)})
26
27+def gpx(request, slug, type):
28+ """
29+ Show voting stations in the specified municipality
30+ """
31+ municipality = get_object_or_404(Municipality, slug=slug)
32+ earlystations = \
33+ EarlyVotingStation.objects.filter(municipality=municipality).order_by('name')
34+ stations = VotingStation.objects.filter(municipality=municipality).order_by('name')
35+
36+ if type == municipality.slug + '-early':
37+ stations = None
38+
39+ if type == municipality.slug:
40+ earlystations = None
41+
42+ return direct_to_template(request, 'wpt.gpx',
43+ {'municipality_name': municipality.name,
44+ 'municipality_slug': municipality.slug,
45+ 'early_stations': earlystations,
46+ 'stations': stations,})
47+
48 def earlystation(request, municipality_slug, station_slug):
49 """
50 Show earlyvoting station details
51
52=== modified file 'templates/view_municipality.html'
53--- templates/view_municipality.html 2009-05-08 22:09:27 +0000
54+++ templates/view_municipality.html 2009-05-11 19:04:44 +0000
55@@ -91,6 +91,12 @@
56 {% endfor %}
57 </div>
58 </div>
59+<div id="gpx" style="clear:both;"
60+ <div> Vallokalerna GPS (.gpx) (högerklicka -> spara som)</div>
61+ <a href="{% url gpx municipality_slug gpxall %}">Alla</a>
62+ <a href="{% url gpx municipality_slug gpxearly %}">Förtidsröstningslokaler</a>
63+ <a href="{% url gpx municipality_slug gpx %}">Valdagen</a>
64+</div>
65 {% endblock %}
66
67 {% block postscript %}
68
69=== added file 'templates/wpt.gpx'
70--- templates/wpt.gpx 1970-01-01 00:00:00 +0000
71+++ templates/wpt.gpx 2009-05-11 19:04:44 +0000
72@@ -0,0 +1,21 @@
73+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
74+<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
75+ {% if early_stations %}
76+ {% for station in early_stations %}
77+ <wpt lat="{{ station.lat }}" lon="{{ station.lon }}" >
78+ {% if station.name %}
79+ <name>Förtidslokal - {{ station.name }}</name>
80+ {% endif %}
81+ </wpt>
82+ {% endfor %}
83+ {% endif %}
84+ {% if stations %}
85+ {% for station in stations %}
86+ <wpt lat="{{ station.lat }}" lon="{{ station.lon }}" >
87+ {% if station.name %}
88+ <name>{{ station.name }}</name>
89+ {% endif %}
90+ </wpt>
91+ {% endfor %}
92+ {% endif %}
93+</gpx>
94\ No newline at end of file

Subscribers

People subscribed via source and target branches