first commit

This commit is contained in:
sanj 2010-03-15 17:00:31 +05:30
parent f67f4f5cce
commit d99fafc332
13 changed files with 606 additions and 0 deletions

0
vurbanism/__init__.py Normal file
View File

View File

View File

@ -0,0 +1,42 @@
from django.contrib.gis import admin
from django.contrib.gis.maps.google import GoogleMap
from models import *
from django.conf import settings
class ImageInline(admin.TabularInline):
model = Image
extra = 5
class VideoInline(admin.TabularInline):
model = Video
extra = 3
class AudioInline(admin.TabularInline):
model = Audio
extra = 2
class TextInline(admin.TabularInline):
model = Text
extra = 4
class FlyoverAdmin(admin.OSMGeoAdmin):
fieldsets = (
('Flyover Data', {'fields': (('point','name', 'txt',)), 'classes': ('show','extrapretty')}),
)
map_template = 'gis/admin/google.html'
default_lon = 72.855211097628413
default_lat = 19.415775291486027
default_zoom = 4
extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js', 'http://maps.google.com/maps?file=api&v=2&key=%s' % settings.GOOGLE_MAPS_API_KEY]
inlines = [ImageInline, VideoInline, AudioInline, TextInline]
admin.site.register(Flyover, FlyoverAdmin)
admin.site.register(Image)
admin.site.register(ImageCategory)
admin.site.register(Video)
admin.site.register(VideoCategory)
admin.site.register(Audio)
admin.site.register(AudioCategory)
admin.site.register(Text)
admin.site.register(TextCategory)

View File

@ -0,0 +1,77 @@
from django.contrib.gis.db import models
class Flyover(models.Model):
point = models.PointField()
name = models.CharField(max_length=255)
txt = models.TextField(blank=True, null=True)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Image(models.Model):
url = models.URLField("FlickR URL")
caption = models.CharField(max_length=255, blank=True, null=True)
category = models.ForeignKey("ImageCategory")
flyover = models.ForeignKey(Flyover)
def __unicode__(self):
return self.url + " - " + self.caption + " - " + self.category.name
class ImageCategory(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
class Video(models.Model):
url = models.URLField("Youtube URL")
caption = models.CharField(max_length=255, blank=True, null=True)
category = models.ForeignKey("VideoCategory")
flyover = models.ForeignKey(Flyover)
def __unicode__(self):
return self.url + " - " + self.caption + " - " + self.category.name
class VideoCategory(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
class Audio(models.Model):
url = models.URLField("Audio URL")
caption = models.CharField(max_length=255, blank=True, null=True)
category = models.ForeignKey("AudioCategory")
flyover = models.ForeignKey(Flyover)
def __unicode__(self):
return self.url + " - " + self.caption + " - " + self.category.name
class AudioCategory(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
class Text(models.Model):
# url = models.URLField("FlickR URL")
text = models.TextField(max_length=255)
category = models.ForeignKey("TextCategory")
flyover = models.ForeignKey(Flyover)
def __unicode__(self):
return self.text + " - " + self.category.name
class TextCategory(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
# Create your models here.

View File

@ -0,0 +1,23 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@ -0,0 +1 @@
# Create your views here.

19
vurbanism/importMyMaps.py Normal file
View File

@ -0,0 +1,19 @@
import elementtree.ElementTree as ET
from django.contrib.gis.geos import Point
from flyovers.models import *
def parseXml(fname):
root = ET.parse(fname).getroot()
channel = root.find('channel')
for item in channel.findall('item'):
title = item.find('title').text
description = item.find('description').text or ''
pt = item.find("{http://www.georss.org/georss}point").text.strip().split(" ")
lat = float(pt[0])
lng = float(pt[1])
point = Point(lng, lat,)
print point
f = Flyover(name=title, txt=description, point=point)
f.save()
# pt = item.find('georss:point').text

11
vurbanism/manage.py Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)

86
vurbanism/settings.py Normal file
View File

@ -0,0 +1,86 @@
# Django settings for vurbanism project.
import os
from os.path import join
PROJECT_PATH = os.path.dirname(__file__)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
GOOGLE_MAPS_API_KEY = 'ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA'
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'vurbanism' # Or path to database file if using sqlite3.
DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = ')s6v_j@m(o3n5qm0i^2h+#q3v+ltwkklkbxp#gz)#9vm_#-7&z'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
ROOT_URLCONF = 'vurbanism.urls'
TEMPLATE_DIRS = (
join(PROJECT_PATH, 'templates')
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.gis',
'flyovers',
)

View File

@ -0,0 +1,4 @@
{% extends "gis/admin/openlayers.html" %}
{% block openlayers %}
{% include "gis/admin/google.js" %}
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "gis/admin/openlayers.js" %}
{% block base_layer %}
new OpenLayers.Layer.Google("Google Terrain", {type: G_PHYSICAL_MAP, 'sphericalMercator': true});
{% endblock %}
{% block extra_layers %}
{{ module }}.layers.overlay = new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap (Mapnik)");
{{ module }}.map.addLayer({{ module }}.layers.overlay);
{% endblock %}

315
vurbanism/test_mymaps.xml Normal file
View File

@ -0,0 +1,315 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<channel>
<link>http://maps.google.com</link>
<title>Mumbaiflyovers</title>
<description><![CDATA[]]></description>
<item>
<guid isPermaLink="false">000467cd891cf78f803f5</guid>
<pubDate>Sat, 18 Apr 2009 05:26:13 +0000</pubDate>
<title>Sahar Airport Flyover</title>
<description><![CDATA[<div dir="ltr">Sahar Elevated Access Road linking Western Highway with Chhatrapati Shivaji International Airport</div>]]></description>
<author>andrewjharris</author>
<georss:point>
19.102898 72.866501
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467cd977ed767fb9ed</guid>
<pubDate>Sat, 18 Apr 2009 05:30:14 +0000</pubDate>
<title>Kalanagar Thackere Flyover</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.054695 72.846306
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467ce09f31ad2a85bf</guid>
<pubDate>Sat, 18 Apr 2009 06:02:14 +0000</pubDate>
<title>L and T flyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3476726162/" title="IMG_5706 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3626/3476726162_f7c2c93014.jpg" width="375" height="500" alt="IMG_5706"></a>
]]></description>
<author>andrewjharris</author>
<georss:point>
19.124968 72.893150
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467ce0d8e0b58f5439</guid>
<pubDate>Sat, 18 Apr 2009 06:03:15 +0000</pubDate>
<title>Jogeshwari Flyover</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.140568 72.854858
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467ce14bb91dcf5ccf</guid>
<pubDate>Sat, 18 Apr 2009 06:05:15 +0000</pubDate>
<title>Placemark 5</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.128778 72.920067
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467cee442527126c52</guid>
<pubDate>Sat, 18 Apr 2009 07:03:17 +0000</pubDate>
<title>Placemark 6</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.125200 72.925072
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d0715d910a760ed</guid>
<pubDate>Sat, 18 Apr 2009 08:54:19 +0000</pubDate>
<title>Andheri Flyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475854355/" title="mumbai07 237 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3592/3475854355_250ec7239d.jpg" width="375" height="500" alt="mumbai07 237"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.112692 72.854507
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d0715db05823f01</guid>
<pubDate>Sat, 18 Apr 2009 08:54:19 +0000</pubDate>
<title>barfiwala lane</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.116016 72.844353
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d0750d936338b3f</guid>
<pubDate>Sat, 18 Apr 2009 08:55:21 +0000</pubDate>
<title>Goregaon</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.165154 72.858368
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d078ae1fcc78e80</guid>
<pubDate>Sat, 18 Apr 2009 08:56:22 +0000</pubDate>
<title>Kandivali Times of India</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475922187/" title="IMG_5789 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3335/3475922187_bbd254db62.jpg" width="500" height="375" alt="IMG_5789"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.191698 72.858498
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d1c92c444d10e95</guid>
<pubDate>Sat, 18 Apr 2009 10:30:27 +0000</pubDate>
<title>Borivali</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475930109/" title="IMG_5823 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3538/3475930109_09d854c148.jpg" width="500" height="375" alt="IMG_5823"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.206663 72.866318
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d1cccfb431b481a</guid>
<pubDate>Sat, 18 Apr 2009 10:31:28 +0000</pubDate>
<title>Borivali2</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.221512 72.865341
</georss:point>
</item>
<item>
<guid isPermaLink="false">000467d1d072ae8aaea0d</guid>
<pubDate>Sat, 18 Apr 2009 10:32:29 +0000</pubDate>
<title>Placemark 13</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.232805 72.863380
</georss:point>
</item>
<item>
<guid isPermaLink="false">000468146385ccfd3e61f</guid>
<pubDate>Tue, 21 Apr 2009 17:58:05 +0000</pubDate>
<title>Thane Station</title>
<description><![CDATA[<object width="425" height="344" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.youtube.com/v/KjPN2Qpw2iA"></param><embed src="http://www.youtube.com/v/KjPN2Qpw2iA" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object>]]></description>
<author>andrewjharris</author>
<georss:point>
19.187164 72.976425
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004681474a3a5c53b135</guid>
<pubDate>Tue, 21 Apr 2009 18:02:52 +0000</pubDate>
<title>turbhe</title>
<description><![CDATA[<object width="425" height="344" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.youtube.com/v/UQoNKDNEaaw"></param><embed src="http://www.youtube.com/v/UQoNKDNEaaw" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object>]]></description>
<author>andrewjharris</author>
<georss:point>
19.065767 73.018829
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004686e8ad5932f80da5</guid>
<pubDate>Sun, 26 Apr 2009 05:31:31 +0000</pubDate>
<title>Kurla Flyover</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.067472 72.888405
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004686e8ad968e0c2359</guid>
<pubDate>Sun, 26 Apr 2009 05:31:32 +0000</pubDate>
<title>Kurla Flyover Model</title>
<description><![CDATA[]]></description>
<author>andrewjharris</author>
<georss:point>
19.067959 72.885490
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004686e8f60b1cafc8eb</guid>
<pubDate>Sun, 26 Apr 2009 05:32:48 +0000</pubDate>
<title>Kurla Flyover South</title>
<description><![CDATA[<object width="425" height="344" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.youtube.com/v/6xS-ToF71W4"></param><embed src="http://www.youtube.com/v/6xS-ToF71W4" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object>]]></description>
<author>andrewjharris</author>
<georss:point>
19.065565 72.887077
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004686f7eb8df73ab5b5</guid>
<pubDate>Sun, 26 Apr 2009 06:39:43 +0000</pubDate>
<title>TulsiPipeRoad</title>
<description><![CDATA[<object width="425" height="344" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.youtube.com/v/VL8dvZhmO_c"></param><embed src="http://www.youtube.com/v/VL8dvZhmO_c" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object>]]></description>
<author>andrewjharris</author>
<georss:point>
19.009094 72.833221
</georss:point>
</item>
<item>
<guid isPermaLink="false">000468775d0a2eae41fee</guid>
<pubDate>Sun, 26 Apr 2009 16:02:58 +0000</pubDate>
<title>thane-belapur road</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3476758210/" title="IMG_6438 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3579/3476758210_5ea693989b_m.jpg" alt="IMG_6438" height="240" width="180"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.112326 73.009094
</georss:point>
</item>
<item>
<guid isPermaLink="false">000468776cbac3dbfe2de</guid>
<pubDate>Sun, 26 Apr 2009 16:07:21 +0000</pubDate>
<title>Kemps Corner Flyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475948127/" title="IMG_6404 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3656/3475948127_c9a18cae98_m.jpg" width="240" height="180" alt="IMG_6404"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
18.964142 72.807579
</georss:point>
</item>
<item>
<guid isPermaLink="false">00046877754e1ce7e6ae6</guid>
<pubDate>Sun, 26 Apr 2009 16:09:45 +0000</pubDate>
<title>Santa Cruz skywalk</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3476754556/" title="IMG_6295 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3657/3476754556_92a25351f8.jpg" width="375" height="500" alt="IMG_6295"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.080309 72.846542
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004687782180c7d85660</guid>
<pubDate>Sun, 26 Apr 2009 16:13:19 +0000</pubDate>
<title>Khargar FLyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475943819/" title="IMG_6180 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3361/3475943819_5351d95219.jpg" width="500" height="375" alt="IMG_6180"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.032080 73.065994
</georss:point>
</item>
<item>
<guid isPermaLink="false">0004687785af89bfeeff1</guid>
<pubDate>Sun, 26 Apr 2009 16:14:20 +0000</pubDate>
<title>Kurla flyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475938279/" title="IMG_6050 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3611/3475938279_0e0d07f075.jpg" width="375" height="500" alt="IMG_6050"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.066418 72.887894
</georss:point>
</item>
<item>
<guid isPermaLink="false">00046878e54ca834f6fc1</guid>
<pubDate>Sun, 26 Apr 2009 17:52:39 +0000</pubDate>
<title>turningfromEEHtoSionTrombay Road</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475936597/" title="IMG_5940 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3597/3475936597_77e2edaf6a.jpg" alt="IMG_5940" height="500" width="375"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
19.052464 72.882355
</georss:point>
</item>
<item>
<guid isPermaLink="false">00046878eee914f007c9c</guid>
<pubDate>Sun, 26 Apr 2009 17:55:20 +0000</pubDate>
<title>Siontobyculla flyovers</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3475856003/" title="IMG_5385 by themumbaiflyover, on Flickr"><img src="http://farm4.static.flickr.com/3376/3475856003_c1f3315aac.jpg" alt="IMG_5385" height="500" width="375"></a>]]></description>
<author>andrewjharris</author>
<georss:point>
18.997652 72.837341
</georss:point>
</item>
<item>
<guid isPermaLink="false">00046878f280305a195aa</guid>
<pubDate>Sun, 26 Apr 2009 17:56:20 +0000</pubDate>
<title>JJ/Mohammed Ali Flyover</title>
<description><![CDATA[<a href="http://www.flickr.com/photos/37774301@N05/3476687626/" title="IMG_5547 by themumbaiflyover, on Flickr"><br></a>]]></description>
<author>andrewjharris</author>
<georss:point>
18.960985 72.831955
</georss:point>
</item>
</channel>
</rss>

17
vurbanism/urls.py Normal file
View File

@ -0,0 +1,17 @@
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^vurbanism/', include('vurbanism.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)