From cce9a5353994e08b41b8b14caa3436bd92ae6c8f Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 17 Aug 2012 13:03:41 +0530 Subject: [PATCH] admin changes --- openmumbai/base/models.py | 15 ++++++++++++++- openmumbai/places/admin.py | 4 ++-- openmumbai/places/models.py | 15 +-------------- openmumbai/places/static/js/edit.js | 5 ++++- openmumbai/templates/edit.html | 16 +++++++++++++++- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/openmumbai/base/models.py b/openmumbai/base/models.py index 8753015..4cc070d 100644 --- a/openmumbai/base/models.py +++ b/openmumbai/base/models.py @@ -7,6 +7,19 @@ class BaseModel(models.Model): created = models.DateTimeField(null=True, editable=False) is_openmumbai_model = True + def get_title(self): + + if self.name and self.name.strip() != '': + title = self.name + else: + title = self.address + if hasattr(self, 'pk_serial'): + title = str(self.pk_serial) + ": " + title + return title + + def __unicode__(self): + return self.get_title() + def save(self, *args, **kwargs): if not self.id: self.created = datetime.datetime.today() @@ -18,7 +31,7 @@ class BaseModel(models.Model): def get_dict(self, *args, **kwargs): return { 'id': self.id, - 'name': self.name + 'name': self.get_title() } def get_geojson(self, srid=4326): diff --git a/openmumbai/places/admin.py b/openmumbai/places/admin.py index e6fa1f9..47f5a59 100644 --- a/openmumbai/places/admin.py +++ b/openmumbai/places/admin.py @@ -18,7 +18,7 @@ class OpenSpaceAdmin(BaseGeoAdmin): # fields = ('preferred_name', 'feature_type', 'admin1', 'admin2', 'geometry', 'url', 'authority_record', 'time_frame', 'is_primary',) search_fields = ['name', 'address'] list_filter = ('ward', 'reservation', 'occupied',) - list_display = ('address', 'ward', 'reservation', 'occupied', 'cts', 'area',) + list_display = ('__unicode__', 'address', 'ward', 'reservation', 'occupied', 'cts', 'area',) # inlines = [FeatureNamesInline] # list_display = ('__unicode__', 'feature_type_name', 'admin1', 'admin2', 'time_start', 'time_end',) # list_per_page = 30 @@ -58,4 +58,4 @@ admin.site.register(CreekWetland, DevelopmentAdmin) admin.site.register(Nullah, DevelopmentAdmin) admin.site.register(MillLand, MillLandAdmin) admin.site.register(Beach, AreaAdmin) - +admin.site.register(PedestrianAvenue, PedestrianAvenueAdmin) diff --git a/openmumbai/places/models.py b/openmumbai/places/models.py index fa105be..37af223 100644 --- a/openmumbai/places/models.py +++ b/openmumbai/places/models.py @@ -15,9 +15,6 @@ class OpenSpace(BaseModel): area = models.DecimalField(max_digits=15, decimal_places=3) geometry = models.GeometryField(null=True, blank=True) - def __unicode__(self): - return "%s %s %s" % (self.ward, self.reservation, self.address,) - class AreaModel(BaseModel): pk_serial = models.IntegerField(null=True, blank=True) @@ -26,8 +23,7 @@ class AreaModel(BaseModel): area = models.DecimalField(max_digits=15, decimal_places=3) geometry = models.GeometryField(null=True, blank=True) - def __unicode__(self): - return self.address + class Forest(AreaModel): @@ -61,9 +57,6 @@ class DevelopmentModel(BaseModel): including_development_area = models.DecimalField(max_digits=15, decimal_places=3) geometry = models.GeometryField(null=True, blank=True) - def __unicode__(self): - return "%d: %s" % (self.pk_serial, self.name,) - class River(DevelopmentModel): pass @@ -95,9 +88,6 @@ class MillLand(BaseModel): owner = models.CharField(max_length=1024, blank=True) geometry = models.GeometryField(null=True, blank=True) - def __unicode__(self): - return self.name - class PedestrianAvenue(BaseModel): pk_serial = models.IntegerField(null=True, blank=True) @@ -105,8 +95,5 @@ class PedestrianAvenue(BaseModel): length = models.DecimalField(max_digits=5, decimal_places=2) geometry = models.LineStringField(null=True, blank=True) - def __unicode__(self): - return self.name - data_models = [OpenSpace, Forest, Fort, HillForest, Waterfront, Beach, River, CreekWetland, WaterBody, Nullah, MillLand, PedestrianAvenue] diff --git a/openmumbai/places/static/js/edit.js b/openmumbai/places/static/js/edit.js index 0b8f05f..bfbbfdc 100644 --- a/openmumbai/places/static/js/edit.js +++ b/openmumbai/places/static/js/edit.js @@ -159,7 +159,10 @@ var baseLayers = { 'Bing Satellite with Labels': bingSatelliteWithLabelsLayer }; -L.control.layers(baseLayers, wmsLayers).addTo(map); +var layersControl = L.control.layers(baseLayers, wmsLayers, { + 'position': 'topleft', + 'collapsed': false +}).addTo(map); loadGeoJsonFeatures("/geojson/" + CONTENT_TYPE_ID); diff --git a/openmumbai/templates/edit.html b/openmumbai/templates/edit.html index c9563bf..cac8deb 100644 --- a/openmumbai/templates/edit.html +++ b/openmumbai/templates/edit.html @@ -32,6 +32,17 @@ html, body { .selectedItem { background-color: green; } + +#opacityControl { + position: absolute; + width: 20%; + left: 40%; + bottom: 25px; +} + +#opacityRange { + width: 100%; +} @@ -45,6 +56,9 @@ CONTENT_TYPE_ID = {{ content_type_id }};
+
+ +

- Overlay Opacity: +