This repository has been archived by the owner on Jan 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup and mostly stylistic changes in preparation for inclusion in …
…the Pinax project. git-svn-id: http://django-locations.googlecode.com/svn/trunk@10 7dd5b791-a154-0410-b265-8553752079d8
- Loading branch information
Showing
12 changed files
with
199 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var ymap = document.getElementById('ymap'); | ||
if(ymap) { | ||
var map = new YMap(ymap); | ||
// Add map type control | ||
map.addTypeControl(); | ||
// Add map zoom (long) control | ||
map.addZoomLong(); | ||
// Add the Pan Control | ||
map.addPanControl(); | ||
for(var i = 0; i < _geo.length; ++i) { | ||
var g = _geo[i]; | ||
var yPoint = new YGeoPoint(g[0], g[1]); | ||
// Display the map centered on a geocoded location | ||
map.drawZoomAndCenter(yPoint, 12); | ||
// Create a new marker for an address | ||
var myMarker = new YMarker(yPoint); | ||
// Create some content to go inside the SmartWindow | ||
var myMarkerContent = g[2]; | ||
// When the marker is clicked, show the SmartWindow | ||
YEvent.Capture(myMarker, EventsList.MouseClick, function() { | ||
myMarker.openSmartWindow(myMarkerContent); | ||
}); | ||
// Put the marker on the map | ||
map.addOverlay(myMarker); | ||
var pageLink = document.getElementById('loc_' + i); | ||
if(pageLink) { | ||
pageLink.onclick = function() { | ||
var geoIndex = parseInt(this.id.replace('loc_', ''), 10); | ||
var g = _geo[geoIndex]; | ||
var yPoint = new YGeoPoint(g[0], g[1]); | ||
map.drawZoomAndCenter(yPoint, 12); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
# Author : Yashh (www.yashh.com) | ||
# Since i would be just showing a list of checkins, I haven't included any extra methods on the model. | ||
# Since I would be just showing a list of checkins, I haven't included any extra | ||
# methods on the model. | ||
|
||
|
||
from django.db import models | ||
from django.contrib.auth.models import User | ||
|
||
class Location(models.Model): | ||
user = models.ForeignKey(User) | ||
time_checkin = models.DateTimeField() | ||
place = models.CharField(max_length=100) | ||
latitude = models.FloatField() | ||
longitude = models.FloatField() | ||
|
||
class Meta: | ||
ordering = ('-time_checkin',) | ||
get_latest_by = 'time_checkin' | ||
user = models.ForeignKey(User) | ||
time_checkin = models.DateTimeField() | ||
place = models.CharField(max_length=100) | ||
latitude = models.FloatField() | ||
longitude = models.FloatField() | ||
class Meta: | ||
ordering = ('-time_checkin',) | ||
get_latest_by = 'time_checkin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,21 @@ | ||
{% extends "locations/base.html" %} | ||
|
||
|
||
{% block head_title %}All Locations{% endblock %} | ||
{% block extra_head %} | ||
<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=y.Z4iD9nV34EdofUSyd_B5bLj5hrf6wiNszlLacUyxedUanphrJ_ibbMjlntY9eufKwtW"></script> | ||
<script type="text/javascript"> | ||
function initialize_ymap() | ||
{ | ||
// Create a map object | ||
var map = new YMap(document.getElementById('ymap')); | ||
var yPoint = new YGeoPoint({{ location.latitude }},{{ location.longitude }}); | ||
// Display the map centered on a geocoded location | ||
map.drawZoomAndCenter(yPoint, 12); | ||
// Create a new marker for an address | ||
var myMarker = new YMarker(yPoint); | ||
// Create some content to go inside the SmartWindow | ||
var myMarkerContent = "{{location.place}}"; | ||
// When the marker is clicked, show the SmartWindow | ||
YEvent.Capture(myMarker, EventsList.MouseClick, | ||
function() { | ||
myMarker.openSmartWindow(myMarkerContent); | ||
}); | ||
// Put the marker on the map | ||
map.addOverlay(myMarker); | ||
} | ||
</script> | ||
<style type="text/css"> | ||
div#ymap { | ||
width: 300px; height: 200px; float: right; border: 1px solid grey; | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<p>Did you mean: | ||
{{ location.place }}</p> | ||
|
||
<form action="/locations/checkin/" method="POST"> | ||
<p>Did you mean: {{ location.place }}</p> | ||
<form action="{% url loc_checkin %}" method="POST"> | ||
<input type="hidden" name="place" value="{{ location.place }}" id="id_place" /> | ||
<input type="hidden" name="latitude" value="{{ location.latitude }}" id="id_latitude" /> | ||
<input type="hidden" name="longitude" value="{{ location.longitude }}" id="id_longitude" /> | ||
<p><input type="submit" value="Checkin →"></p> | ||
</form> | ||
<div id="ymap"></div> | ||
{% endblock %} | ||
|
||
{% block extra_body %} | ||
<script type="text/javascript"> | ||
var _geo = [[{{ location.latitude }}, {{ location.longitude }}, '{{ location.place }}']]; | ||
</script> | ||
<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid={{ YAHOO_MAPS_API_KEY }}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p class="location"><a href="{{ location.user.get_absolute_url }}">{{ request.user }}</a> checked in at {% if forloop %}<a href="#" id="loc_{{ forloop.counter0 }}">{% endif %}{{ location.place }}{% if forloop %}</a>{% endif %} at {{ location.time_checkin|date:"F d Y g:i a" }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
{% extends "locations/base.html" %} | ||
{% load pagination_tags %} | ||
|
||
{% block head_title %}Near by checkins{% endblock %} | ||
{% block head_title %}Nearby checkins{% endblock %} | ||
|
||
{% block body %} | ||
|
||
{% if queryset %} | ||
{% for location in queryset %} | ||
<p><a href="{{ location.user.get_absolute_url }}">{{ location.user }}</a> checked in at {{ location.place }} on {{ location.time_checkin|date:"F d Y g:i a" }}</p> | ||
{% endfor %} | ||
{% for location in queryset %} | ||
{% include "locations/location.html" %} | ||
{% endfor %} | ||
{% else %} | ||
<p>There are no users who checked in near your location.</p> | ||
{% endif %} | ||
|
||
{% if message %} | ||
<p>{{ message }}</p> | ||
<p>There are no users who checked in near your location.</p> | ||
{% endif %} | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
# Just a few url's. One for the new form and one for displaying checkins of the user and one for getting the search result | ||
# Just a few url's. One for the new form and one for displaying checkins of the user and one for getting the search result | ||
# and then checkin in to that place. | ||
|
||
urlpatterns = patterns('', | ||
url(r'^$', 'locations.views.your_locations', name='your_checkins'), | ||
(r'^new/$', 'locations.views.new'), | ||
(r'^checkin/$', 'locations.views.checkin'), | ||
url(r'^friends/checkins/$', 'locations.views.friends_checkins', name='friends_checkins'), | ||
url(r'^nearby/checkins/$', 'locations.views.nearby_checkins', name='nearby_checkins'), | ||
url(r'^$', 'locations.views.your_locations', name='loc_yours'), | ||
url(r'^new/$', 'locations.views.new', name='loc_new'), | ||
url(r'^checkin/$', 'locations.views.checkin', name='loc_checkin'), | ||
url(r'^friends/checkins/$', 'locations.views.friends_checkins', name='loc_friends'), | ||
url(r'^nearby/checkins/$', 'locations.views.nearby_checkins', name='loc_nearby'), | ||
) |
Oops, something went wrong.