Shekhar Krishnan
13 years ago
commit
9ce871badd
13 changed files with 249 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||
To enter virtualenv: |
|||
. bin/activate |
|||
|
|||
To run server: |
|||
cd citysurvey |
|||
python manage.py runserver |
|||
|
@ -0,0 +1,18 @@ |
|||
from django.contrib.gis import admin |
|||
# from django.contrib.gis.maps.google import GoogleMap |
|||
from models import * |
|||
|
|||
class PropertyAdmin(admin.OSMGeoAdmin): |
|||
list_display = ('__unicode__', 'street_locality', 'tenure', 'ground_rent_due', 'laughton_no', 'area_sqm',) |
|||
list_filter = ('stable',) |
|||
search_fields = ('street_locality',) |
|||
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' % 'abcd'] |
|||
|
|||
|
|||
|
|||
admin.site.register(Property, PropertyAdmin) |
|||
admin.site.register(Stable) |
@ -0,0 +1,42 @@ |
|||
from django.contrib.gis.db import models |
|||
|
|||
class Property(models.Model): |
|||
filename = models.CharField(max_length=255) |
|||
division = models.CharField(max_length=255) |
|||
cs_no = models.CharField(max_length=255) |
|||
cs_reg_no = models.CharField(max_length=255) |
|||
cs_pg_no = models.CharField(max_length=255, blank=True, null=True) |
|||
cs_sheet_no = models.CharField(max_length=255, blank=True, null=True) |
|||
street_locality = models.TextField(blank=True, null=True) |
|||
street_no = models.CharField(max_length=255, blank=True, null=True) |
|||
tenure = models.CharField(max_length=255, blank=True, null=True) |
|||
area_sqm = models.CharField(max_length=255, blank=True, null=True) |
|||
laughton_no = models.CharField(max_length=255, blank=True, null=True) |
|||
collector_new_no = models.CharField(max_length=255, blank=True, null=True) |
|||
collector_rent_no = models.CharField(max_length=255, blank=True, null=True) |
|||
ground_rent_due = models.FloatField(blank=True, null=True) |
|||
grant = models.FloatField(blank=True, null=True) |
|||
total_due = models.FloatField(blank=True, null=True) |
|||
holders_history = models.TextField(blank=True, null=True) |
|||
stable = models.ForeignKey("Stable") |
|||
polygon = models.PolygonField(null=True) |
|||
objects = models.GeoManager() |
|||
|
|||
def __unicode__(self): |
|||
return "%s: %s" % (self.division, self.cs_no,) |
|||
|
|||
class Meta: |
|||
verbose_name_plural = "Properties" |
|||
|
|||
|
|||
class Stable(models.Model): |
|||
stable_id = models.IntegerField() |
|||
name = models.CharField(max_length=255) |
|||
polygon = models.PolygonField(null=True) |
|||
objects = models.GeoManager() |
|||
|
|||
def __unicode__(self): |
|||
return self.name |
|||
|
|||
class Meta: |
|||
ordering = ['stable_id'] |
@ -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 |
|||
"""} |
|||
|
@ -0,0 +1 @@ |
|||
# Create your views here. |
@ -0,0 +1,29 @@ |
|||
#Usage: |
|||
# python manage.py shell |
|||
# import import_stable as i |
|||
# i.importStable(1, "Fort") |
|||
|
|||
from cs.models import * |
|||
from os.path import join |
|||
import json |
|||
|
|||
JSON_DIR = '/home/shekhar/Documents/projects/citysurvey' |
|||
|
|||
def importStable(no, name): |
|||
s = Stable(stable_id=no, name=name) |
|||
s.save() |
|||
filename = join(JSON_DIR, "JSONforStable%d.json" % no) |
|||
data = json.loads(open(filename).read()) |
|||
for d in data: |
|||
p = Property() |
|||
for key in d.keys(): |
|||
val = d[key] |
|||
if key in ['ground_rent_due', 'grant', 'total_due']: |
|||
if val == '': |
|||
val = 0.0 |
|||
# if key in ['cs_no', 'cs_reg_no', 'cs_pg_no', 'cs_sheet_no']: |
|||
# if val == '' or val.find('..') != -1: |
|||
# val = 0 |
|||
p.__setattr__(key, val) |
|||
p.__setattr__('stable', s) |
|||
p.save() |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/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) |
@ -0,0 +1,86 @@ |
|||
# Django settings for citysurvey project. |
|||
import os |
|||
from os.path import join |
|||
|
|||
DEBUG = True |
|||
TEMPLATE_DEBUG = DEBUG |
|||
PROJECT_PATH = os.path.dirname(__file__) |
|||
|
|||
ADMINS = ( |
|||
# ('Your Name', 'your_email@domain.com'), |
|||
) |
|||
|
|||
MANAGERS = ADMINS |
|||
|
|||
DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. |
|||
DATABASE_NAME = 'cts' # Or path to database file if using sqlite3. |
|||
DATABASE_USER = '' # 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 = 'x(x-q&zurdz(u)ab9gi%iefi)bt-ho*!&pv52-qd3f4*omurq-' |
|||
|
|||
# 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 = 'citysurvey.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', |
|||
'cs', |
|||
) |
@ -0,0 +1,4 @@ |
|||
{% extends "gis/admin/openlayers.html" %} |
|||
{% block openlayers %} |
|||
{% include "gis/admin/google.js" %} |
|||
{% endblock %} |
@ -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 %} |
|||
|
|||
|
@ -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'^citysurvey/', include('citysurvey.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)), |
|||
) |
Loading…
Reference in new issue