Merge lp:~effie-jayx/loco-team-portal/toabctl_openlayer_merge into lp:loco-team-portal
- toabctl_openlayer_merge
- Merge into 0.2
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Michael Hall | ||||
Approved revision: | 153 | ||||
Merged at revision: | 153 | ||||
Proposed branch: | lp:~effie-jayx/loco-team-portal/toabctl_openlayer_merge | ||||
Merge into: | lp:loco-team-portal | ||||
Diff against target: |
406 lines (+221/-59) 10 files modified
loco_directory/media/css/newstyle.css (+15/-8) loco_directory/media/js/common.js (+103/-0) loco_directory/templates/base.html (+8/-17) loco_directory/templates/venues/venue_detail.inc.html (+2/-2) loco_directory/templates/venues/venue_detail_basic.inc.html (+22/-10) loco_directory/templates/venues/venue_new.html (+0/-16) loco_directory/templates/venues/venue_update.html (+23/-4) loco_directory/venues/migrations/0004_remove_venue_map_field.py (+46/-0) loco_directory/venues/models.py (+0/-1) loco_directory/venues/views.py (+2/-1) |
||||
To merge this branch: | bzr merge lp:~effie-jayx/loco-team-portal/toabctl_openlayer_merge | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Michael Hall (community) | Approve | ||
Review via email: mp+27121@code.launchpad.net |
Commit message
Description of the change
This Branch brings toabctl's Openlayers use for picking Longitude and Latitude and it was not merged back in rev 125. This is an attempt to get that in and fix a couple of bugs related to maps.
Michael Hall (mhall119) wrote : | # |
Efrain Valles (effie-jayx) wrote : | # |
somehow the line with the google maps javascript got omited, shall comit the change and push it to this branch
> I'm getting an empty square on the venue edit screen, is the map supposed to
> be there as well?
- 153. By Efrain Valles
-
fixed d missing google maps api js import
Efrain Valles (effie-jayx) wrote : | # |
Please make sure you have the GOOGLE_API_KEY in local_settings.py
> I'm getting an empty square on the venue edit screen, is the map supposed to
> be there as well?
Daniel Holbach (dholbach) wrote : | # |
I have a few questions:
- Why is this below changed?
394 - return render_
395 + return render_
396 context, RequestContext(
- Is the Javascript code copied from somewhere? Should we add this information somewhere?
Daniel Holbach (dholbach) wrote : | # |
Why is venue_new.html deleted? It still seems to be in urls.py
Daniel Holbach (dholbach) wrote : | # |
Generally great stuff though. Seems to work OK for me.
Michael Hall (mhall119) wrote : | # |
I think he's combining venue_new.html and venue_update.html because they were essentially identical.
Michael Hall (mhall119) wrote : | # |
Tested and working, it looks good.
Daniel Holbach (dholbach) wrote : | # |
Only question I have left is: "Is the Javascript code copied from somewhere? Should we add this information somewhere?"
Daniel Holbach (dholbach) wrote : | # |
<dholbach> hey toabctl - do you still know where the javascript code for the openlayers branch came from?
toabctl: seems like that's the only remaining question
<toabctl> dholbach, i think it was an example from openlayers.org and i change a lot of it.
<dholbach> toabctl: ok, so there's no licensing thing or "from: http://...." stuff we need to note down somewhere?
<toabctl> dholbach, i don't think so.
<dholbach> toabctl: ok, I'll merge the branch then
thanks
Preview Diff
1 | === modified file 'loco_directory/media/css/newstyle.css' |
2 | --- loco_directory/media/css/newstyle.css 2010-05-03 06:00:22 +0000 |
3 | +++ loco_directory/media/css/newstyle.css 2010-06-10 03:10:45 +0000 |
4 | @@ -7,14 +7,21 @@ |
5 | label { |
6 | font-weight: bold; |
7 | } |
8 | - |
9 | -div.map { |
10 | - width: 300px; |
11 | - height: 300px; |
12 | - border: 1px solid gray; |
13 | - position: absolute; |
14 | - top: 60px; |
15 | - right: 30px; |
16 | +#venue-map-selector { |
17 | + width: 400px; |
18 | + height: 300px; |
19 | + border: 1px solid #ccc; |
20 | + position: absolute; |
21 | + right: 30px; |
22 | + top: 40px; |
23 | +} |
24 | +#venue-map { |
25 | + width: 400px; |
26 | + height: 300px; |
27 | + border: 1px solid #ccc; |
28 | + position: absolute; |
29 | + right: 30px; |
30 | + bottom: 10px; |
31 | } |
32 | |
33 | #main-content { |
34 | |
35 | === added file 'loco_directory/media/js/common.js' |
36 | --- loco_directory/media/js/common.js 1970-01-01 00:00:00 +0000 |
37 | +++ loco_directory/media/js/common.js 2010-06-10 03:10:45 +0000 |
38 | @@ -0,0 +1,103 @@ |
39 | +//Click Control to get lonlat values. trigger function set the values |
40 | +OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |
41 | + defaultHandlerOptions: { |
42 | + 'single': true, |
43 | + 'double': false, |
44 | + 'pixelTolerance': 0, |
45 | + 'stopSingle': false, |
46 | + 'stopDouble': false |
47 | + }, |
48 | + |
49 | + initialize: function(options) { |
50 | + this.handlerOptions = OpenLayers.Util.extend( |
51 | + {}, this.defaultHandlerOptions |
52 | + ); |
53 | + OpenLayers.Control.prototype.initialize.apply( |
54 | + this, arguments |
55 | + ); |
56 | + this.handler = new OpenLayers.Handler.Click( |
57 | + this, { |
58 | + 'click': this.trigger |
59 | + }, this.handlerOptions |
60 | + ); |
61 | + }, |
62 | + |
63 | + trigger: function(e) { |
64 | + var lonlat = map.getLonLatFromViewPortPx(e.xy); |
65 | + $("#id_longitude").val(lonlat.lon) |
66 | + $("#id_latitude").val(lonlat.lat) |
67 | + map.markers.erase(); |
68 | + //alert("You clicked near " + lonlat.lat + " N, " + lonlat.lon + " E"); |
69 | + } |
70 | + |
71 | +}); |
72 | +//function to add markers to map |
73 | +function addMarker(layer, lon, lat, popupContentHTML) { |
74 | + var ll = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); |
75 | + var feature = new OpenLayers.Feature(layer, ll); |
76 | + feature.closeBox = true; |
77 | + feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, { minSize: new OpenLayers.Size(200, 100) }); |
78 | + feature.data.popupContentHTML = popupContentHTML; |
79 | + feature.data.overflow = "hidden"; |
80 | + |
81 | + var marker = new OpenLayers.Marker(ll); |
82 | + marker.feature = feature; |
83 | + |
84 | + var markerClick = function(evt) { |
85 | + if (this.popup == null) { |
86 | + this.popup = this.createPopup(this.closeBox); |
87 | + map.addPopup(this.popup); |
88 | + this.popup.show(); |
89 | + } else { |
90 | + this.popup.toggle(); |
91 | + } |
92 | + OpenLayers.Event.stop(evt); |
93 | + }; |
94 | + marker.events.register("mousedown", feature, markerClick); |
95 | + |
96 | + layer.addMarker(marker); |
97 | +} |
98 | + |
99 | +//openlayers map |
100 | +var map; |
101 | +function showmap(divid, select, lon, lat, htmltext){ |
102 | + map = new OpenLayers.Map(divid); |
103 | + map.addControl(new OpenLayers.Control.LayerSwitcher()); |
104 | + var gphy = new OpenLayers.Layer.Google( |
105 | + "Google Physical", |
106 | + {type: G_PHYSICAL_MAP} |
107 | + ); |
108 | + var gmap = new OpenLayers.Layer.Google( |
109 | + "Google Streets", // the default |
110 | + {numZoomLevels: 20} |
111 | + ); |
112 | + var ghyb = new OpenLayers.Layer.Google( |
113 | + "Google Hybrid", |
114 | + {type: G_HYBRID_MAP, numZoomLevels: 20} |
115 | + ); |
116 | + var gsat = new OpenLayers.Layer.Google( |
117 | + "Google Satellite", |
118 | + {type: G_SATELLITE_MAP, numZoomLevels: 22} |
119 | + ); |
120 | + var markers = new OpenLayers.Layer.Markers("Markers Layer"); |
121 | + |
122 | + map.addLayers([gphy, ghyb, gsat, markers]); |
123 | + if (lon === undefined && lat === undefined) { |
124 | + map.setCenter(new OpenLayers.LonLat(0, 0), 0); |
125 | + } else { |
126 | + for (i=0;i<lon.length;i++) { |
127 | + addMarker(markers, lon[i], lat[i], htmltext[i]); |
128 | + } |
129 | + var lonLat = new OpenLayers.LonLat(lon[0], lat[0]).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); |
130 | + map.setCenter (lonLat, 6); |
131 | + } |
132 | + //map.zoomToMaxExtent(); |
133 | + if (select) { |
134 | + var click = new OpenLayers.Control.Click(); |
135 | + map.addControl(click); |
136 | + click.activate(); |
137 | + } |
138 | + |
139 | + |
140 | +} |
141 | + |
142 | |
143 | === modified file 'loco_directory/templates/base.html' |
144 | --- loco_directory/templates/base.html 2010-05-26 14:59:32 +0000 |
145 | +++ loco_directory/templates/base.html 2010-06-10 03:10:45 +0000 |
146 | @@ -11,24 +11,12 @@ |
147 | <style type="text/css" media="all">@import "/media/css/classes.css";</style> |
148 | <style type="text/css" media="all">@import "/media/css/ubuntu09.css";</style> |
149 | <style type="text/css" media="all">@import "/media/css/newstyle.css";</style> |
150 | -{% block initmap %} |
151 | + <script type="text/javascript" src="{{MEDIA_URL}}/jquery/jquery.js"></script> |
152 | + <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script> |
153 | <script src="http://maps.google.com/maps?file=api&v=2&key={{ google_api_key }}" type="text/javascript"></script> |
154 | - <script type="text/javascript"> |
155 | - |
156 | - function showmap(Lo, La, Content) { |
157 | - if (GBrowserIsCompatible()) { |
158 | - var map = new GMap2(document.getElementById("map_canvas")); |
159 | - var center = new GLatLng(La, Lo) |
160 | - map.setCenter(center, 13); |
161 | - var marker = new GMarker(center) |
162 | - map.addOverlay(marker) |
163 | - GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(Content);}) |
164 | - } |
165 | - } |
166 | - |
167 | - </script> |
168 | -{% endblock %} |
169 | -{% block extrahead %}{% endblock %} |
170 | + <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> |
171 | + <script type="text/javascript" src="{{MEDIA_URL}}/js/common.js"></script> |
172 | + {% block extrahead %}{% endblock %} |
173 | </head> |
174 | |
175 | <body class="ubuntu09 front not-logged-in page-node node-type-page no-sidebars"> |
176 | @@ -97,5 +85,8 @@ |
177 | </div> |
178 | </div> |
179 | </div> |
180 | + <div id="bg-left"> </div><div id="bottom-left"> </div> |
181 | +</div> |
182 | +{% block extra_javascript %}{% endblock extra_javascript %} |
183 | </body> |
184 | </html> |
185 | |
186 | === modified file 'loco_directory/templates/venues/venue_detail.inc.html' |
187 | --- loco_directory/templates/venues/venue_detail.inc.html 2010-05-03 05:52:58 +0000 |
188 | +++ loco_directory/templates/venues/venue_detail.inc.html 2010-06-10 03:10:45 +0000 |
189 | @@ -15,6 +15,6 @@ |
190 | <br class="clear" /> |
191 | <h2>{{venue_object.name}}</h2> |
192 | {% include "venues/venue_detail_basic.inc.html" %} |
193 | - |
194 | - </div> |
195 | + |
196 | + <br class="clear" /> |
197 | </div> |
198 | |
199 | === modified file 'loco_directory/templates/venues/venue_detail_basic.inc.html' |
200 | --- loco_directory/templates/venues/venue_detail_basic.inc.html 2010-02-18 10:32:46 +0000 |
201 | +++ loco_directory/templates/venues/venue_detail_basic.inc.html 2010-06-10 03:10:45 +0000 |
202 | @@ -1,5 +1,5 @@ |
203 | {% load i18n %} |
204 | -<table id="team-event-venue"> |
205 | +<table> |
206 | {% if venue_object %} |
207 | {% if venue_object.name %} |
208 | <tr> |
209 | @@ -25,17 +25,23 @@ |
210 | <td>{{ venue_object.country }}</td> |
211 | </tr> |
212 | {% endif %} |
213 | - {% if venue_object.map_url %} |
214 | - <tr> |
215 | - <th scope="row"><label>{% trans "Map URL:" %}</label></th> |
216 | - <td><a href="{{ venue_object.map_url }}">Load Map</a></td> |
217 | - </tr> |
218 | - {% endif %} |
219 | {% if venue_object.venue_url %} |
220 | <tr> |
221 | <th scope="row"><label>{% trans "Homepage:" %}</label></th> |
222 | <td><a href="{{ venue_object.venue_url }}">{{ venue_object.venue_url }}</a></td> |
223 | </tr> |
224 | + {% endif %} |
225 | + {% if venue_object.longitude %} |
226 | + <tr> |
227 | + <th scope="row"><label>{% trans "Longitude:" %}</label></th> |
228 | + <td>{{ venue_object.longitude }}</td> |
229 | + </tr> |
230 | + {% endif %} |
231 | + {% if venue_object.latitude %} |
232 | + <tr> |
233 | + <th scope="row"><label>{% trans "Latitude:" %}</label></th> |
234 | + <td>{{ venue_object.latitude }}</td> |
235 | + </tr> |
236 | {% endif %} |
237 | {% if venue_object.comment %} |
238 | <tr> |
239 | @@ -47,9 +53,15 @@ |
240 | </table> |
241 | |
242 | {% if venue_object.longitude and venue_object.latitude %} |
243 | -<div id="map_canvas" class="map"></div> |
244 | +<div id="venue-map"></div> |
245 | <script><!-- |
246 | -showmap({{ venue_object.longitude }}, {{ venue_object.latitude }}, '<h3 style="margin: 0 0 0.4em 0;">{{ venue_object.name }}</h3><a href="http://maps.google.com/maps?saddr=&daddr={{ venue_object.address }}, {{ venue_object.city }}, {{ venue_object.country }}" target ="_blank">Get Directions<\/a>') |
247 | - |
248 | + var lon = new Array(); |
249 | + var lat = new Array(); |
250 | + var htmltext = new Array(); |
251 | + lon[0] = {{ venue_object.longitude }} |
252 | + lat[0] = {{ venue_object.latitude }} |
253 | + htmltext[0] = "{{ venue_object.name }}" |
254 | + var select = new Boolean(false); |
255 | + showmap('venue-map', select, lon, lat, htmltext) |
256 | --></script> |
257 | {% endif %} |
258 | |
259 | === removed file 'loco_directory/templates/venues/venue_new.html' |
260 | --- loco_directory/templates/venues/venue_new.html 2009-12-21 20:45:43 +0000 |
261 | +++ loco_directory/templates/venues/venue_new.html 1970-01-01 00:00:00 +0000 |
262 | @@ -1,16 +0,0 @@ |
263 | -{% extends "base.html" %} |
264 | -{% load i18n %} |
265 | - |
266 | -{% block title %}{% trans "New Venue" %}{% endblock %} |
267 | - |
268 | -{% block content %} |
269 | -<h1>{% trans "Add new Venue" %}</h1> |
270 | -<form action="." method="post"> |
271 | - <table> |
272 | - {{ form.as_table }} |
273 | - </table> |
274 | - <p><input type="submit" value="Submit" /></p> |
275 | -</form> |
276 | - |
277 | - |
278 | -{% endblock %} |
279 | |
280 | === modified file 'loco_directory/templates/venues/venue_update.html' |
281 | --- loco_directory/templates/venues/venue_update.html 2009-12-21 20:45:43 +0000 |
282 | +++ loco_directory/templates/venues/venue_update.html 2010-06-10 03:10:45 +0000 |
283 | @@ -1,16 +1,35 @@ |
284 | {% extends "base.html" %} |
285 | {% load i18n %} |
286 | |
287 | -{% block title %}{% trans "Update Venue" %}{% endblock %} |
288 | +{% block title %}{% if venue_object %}{% trans "Update Venue" %}{% else %}{% trans "New Venue" %}{% endif %}{% endblock %} |
289 | + |
290 | +{% block extra_javascript %} |
291 | +<script type="text/javascript"><!-- |
292 | + var lon = new Array(); |
293 | + var lat = new Array(); |
294 | + var htmltext = new Array(); |
295 | + var select = new Boolean(true); |
296 | + {% if venue_object %} |
297 | + lon[0] = $("#id_longitude").val() |
298 | + lat[0] = $("#id_latitude").val() |
299 | + htmltext[0] = "{{ venue_object.name }}" |
300 | + showmap('venue-map-selector', select, lon, lat, htmltext) |
301 | + {% else %} |
302 | + showmap('venue-map-selector', select) |
303 | + {% endif %} |
304 | +--></script> |
305 | +{% endblock extra_javascript %} |
306 | |
307 | {% block content %} |
308 | -<h1>{% trans "Update Venue" %}</h1> |
309 | +<h1>{% if venue_object %}{% trans "Update Venue" %}{% else %}{% trans "New Venue" %}{% endif %}</h1> |
310 | +<div style="float: left;"> |
311 | <form action="." method="post"> |
312 | <table> |
313 | {{ form.as_table }} |
314 | </table> |
315 | <p><input type="submit" value="Submit" /></p> |
316 | -</form> |
317 | - |
318 | + </form> |
319 | +</div> |
320 | +<div id="venue-map-selector" title="{% trans "Select venue position" %}"> </div> |
321 | |
322 | {% endblock %} |
323 | |
324 | === added file 'loco_directory/venues/migrations/0004_remove_venue_map_field.py' |
325 | --- loco_directory/venues/migrations/0004_remove_venue_map_field.py 1970-01-01 00:00:00 +0000 |
326 | +++ loco_directory/venues/migrations/0004_remove_venue_map_field.py 2010-06-10 03:10:45 +0000 |
327 | @@ -0,0 +1,46 @@ |
328 | + |
329 | +from south.db import db |
330 | +from django.db import models |
331 | +from venues.models import * |
332 | + |
333 | +class Migration: |
334 | + |
335 | + def forwards(self, orm): |
336 | + |
337 | + # Deleting field 'Venue.map_url' |
338 | + db.delete_column('venues_venue', 'map_url') |
339 | + |
340 | + |
341 | + |
342 | + def backwards(self, orm): |
343 | + |
344 | + # Adding field 'Venue.map_url' |
345 | + db.add_column('venues_venue', 'map_url', orm['venues.venue:map_url']) |
346 | + |
347 | + |
348 | + |
349 | + models = { |
350 | + 'teams.continent': { |
351 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
352 | + 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'}) |
353 | + }, |
354 | + 'teams.country': { |
355 | + 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']"}), |
356 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
357 | + 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'}) |
358 | + }, |
359 | + 'venues.venue': { |
360 | + 'Meta': {'unique_together': "(('name', 'country', 'city'), ('longitude', 'latitude'))"}, |
361 | + 'address': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}), |
362 | + 'city': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}), |
363 | + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), |
364 | + 'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['teams.Country']", 'null': 'True'}), |
365 | + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
366 | + 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), |
367 | + 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), |
368 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}), |
369 | + 'venue_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}) |
370 | + } |
371 | + } |
372 | + |
373 | + complete_apps = ['venues'] |
374 | |
375 | === modified file 'loco_directory/venues/models.py' |
376 | --- loco_directory/venues/models.py 2010-06-04 14:02:03 +0000 |
377 | +++ loco_directory/venues/models.py 2010-06-10 03:10:45 +0000 |
378 | @@ -21,7 +21,6 @@ |
379 | longitude = models.FloatField(help_text=_('Longitude in Degrees East'), null=True, blank=True) |
380 | latitude = models.FloatField(help_text=_('Latitude in Degrees North'), null=True, blank=True) |
381 | venue_url = models.URLField(help_text=_('URL for the Venue Homepage'), verbose_name=_('URL of the Venue'), max_length=200, verify_exists=False, blank=True, null=True) |
382 | - map_url = models.URLField(help_text=_('Map URL for the Venue'), verbose_name=_('URL of the Map'), max_length=200, verify_exists=False, blank=True, null=True) |
383 | comment = models.TextField(help_text=_('Comment about the Venue'), blank=True, null=True) |
384 | |
385 | class Meta: |
386 | |
387 | === modified file 'loco_directory/venues/views.py' |
388 | --- loco_directory/venues/views.py 2010-05-02 13:39:19 +0000 |
389 | +++ loco_directory/venues/views.py 2010-06-10 03:10:45 +0000 |
390 | @@ -59,7 +59,7 @@ |
391 | context = { |
392 | 'form': form, |
393 | } |
394 | - return render_to_response('venues/venue_new.html', |
395 | + return render_to_response('venues/venue_update.html', |
396 | context, RequestContext(request)) |
397 | |
398 | @login_required |
399 | @@ -80,6 +80,7 @@ |
400 | |
401 | context = { |
402 | 'form': form, |
403 | + 'venue_object':venue_object, |
404 | } |
405 | return render_to_response('venues/venue_update.html', |
406 | context, RequestContext(request)) |
I'm getting an empty square on the venue edit screen, is the map supposed to be there as well?