admin changes

This commit is contained in:
Sanj 2012-08-17 13:03:41 +05:30
parent 8ce41032c5
commit cce9a53539
5 changed files with 36 additions and 19 deletions

View File

@ -7,6 +7,19 @@ class BaseModel(models.Model):
created = models.DateTimeField(null=True, editable=False) created = models.DateTimeField(null=True, editable=False)
is_openmumbai_model = True 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): def save(self, *args, **kwargs):
if not self.id: if not self.id:
self.created = datetime.datetime.today() self.created = datetime.datetime.today()
@ -18,7 +31,7 @@ class BaseModel(models.Model):
def get_dict(self, *args, **kwargs): def get_dict(self, *args, **kwargs):
return { return {
'id': self.id, 'id': self.id,
'name': self.name 'name': self.get_title()
} }
def get_geojson(self, srid=4326): def get_geojson(self, srid=4326):

View File

@ -18,7 +18,7 @@ class OpenSpaceAdmin(BaseGeoAdmin):
# fields = ('preferred_name', 'feature_type', 'admin1', 'admin2', 'geometry', 'url', 'authority_record', 'time_frame', 'is_primary',) # fields = ('preferred_name', 'feature_type', 'admin1', 'admin2', 'geometry', 'url', 'authority_record', 'time_frame', 'is_primary',)
search_fields = ['name', 'address'] search_fields = ['name', 'address']
list_filter = ('ward', 'reservation', 'occupied',) list_filter = ('ward', 'reservation', 'occupied',)
list_display = ('address', 'ward', 'reservation', 'occupied', 'cts', 'area',) list_display = ('__unicode__', 'address', 'ward', 'reservation', 'occupied', 'cts', 'area',)
# inlines = [FeatureNamesInline] # inlines = [FeatureNamesInline]
# list_display = ('__unicode__', 'feature_type_name', 'admin1', 'admin2', 'time_start', 'time_end',) # list_display = ('__unicode__', 'feature_type_name', 'admin1', 'admin2', 'time_start', 'time_end',)
# list_per_page = 30 # list_per_page = 30
@ -58,4 +58,4 @@ admin.site.register(CreekWetland, DevelopmentAdmin)
admin.site.register(Nullah, DevelopmentAdmin) admin.site.register(Nullah, DevelopmentAdmin)
admin.site.register(MillLand, MillLandAdmin) admin.site.register(MillLand, MillLandAdmin)
admin.site.register(Beach, AreaAdmin) admin.site.register(Beach, AreaAdmin)
admin.site.register(PedestrianAvenue, PedestrianAvenueAdmin)

View File

@ -15,9 +15,6 @@ class OpenSpace(BaseModel):
area = models.DecimalField(max_digits=15, decimal_places=3) area = models.DecimalField(max_digits=15, decimal_places=3)
geometry = models.GeometryField(null=True, blank=True) geometry = models.GeometryField(null=True, blank=True)
def __unicode__(self):
return "%s %s %s" % (self.ward, self.reservation, self.address,)
class AreaModel(BaseModel): class AreaModel(BaseModel):
pk_serial = models.IntegerField(null=True, blank=True) pk_serial = models.IntegerField(null=True, blank=True)
@ -26,8 +23,7 @@ class AreaModel(BaseModel):
area = models.DecimalField(max_digits=15, decimal_places=3) area = models.DecimalField(max_digits=15, decimal_places=3)
geometry = models.GeometryField(null=True, blank=True) geometry = models.GeometryField(null=True, blank=True)
def __unicode__(self):
return self.address
class Forest(AreaModel): class Forest(AreaModel):
@ -61,9 +57,6 @@ class DevelopmentModel(BaseModel):
including_development_area = models.DecimalField(max_digits=15, decimal_places=3) including_development_area = models.DecimalField(max_digits=15, decimal_places=3)
geometry = models.GeometryField(null=True, blank=True) geometry = models.GeometryField(null=True, blank=True)
def __unicode__(self):
return "%d: %s" % (self.pk_serial, self.name,)
class River(DevelopmentModel): class River(DevelopmentModel):
pass pass
@ -95,9 +88,6 @@ class MillLand(BaseModel):
owner = models.CharField(max_length=1024, blank=True) owner = models.CharField(max_length=1024, blank=True)
geometry = models.GeometryField(null=True, blank=True) geometry = models.GeometryField(null=True, blank=True)
def __unicode__(self):
return self.name
class PedestrianAvenue(BaseModel): class PedestrianAvenue(BaseModel):
pk_serial = models.IntegerField(null=True, blank=True) pk_serial = models.IntegerField(null=True, blank=True)
@ -105,8 +95,5 @@ class PedestrianAvenue(BaseModel):
length = models.DecimalField(max_digits=5, decimal_places=2) length = models.DecimalField(max_digits=5, decimal_places=2)
geometry = models.LineStringField(null=True, blank=True) 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] data_models = [OpenSpace, Forest, Fort, HillForest, Waterfront, Beach, River, CreekWetland, WaterBody, Nullah, MillLand, PedestrianAvenue]

View File

@ -159,7 +159,10 @@ var baseLayers = {
'Bing Satellite with Labels': bingSatelliteWithLabelsLayer '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); loadGeoJsonFeatures("/geojson/" + CONTENT_TYPE_ID);

View File

@ -32,6 +32,17 @@ html, body {
.selectedItem { .selectedItem {
background-color: green; background-color: green;
} }
#opacityControl {
position: absolute;
width: 20%;
left: 40%;
bottom: 25px;
}
#opacityRange {
width: 100%;
}
</style> </style>
<script src="/static/leaflet/leaflet.js"></script> <script src="/static/leaflet/leaflet.js"></script>
<script src="/static/leaflet/leaflet.draw.js"></script> <script src="/static/leaflet/leaflet.draw.js"></script>
@ -45,6 +56,9 @@ CONTENT_TYPE_ID = {{ content_type_id }};
<body> <body>
<div id="map"></div> <div id="map"></div>
<div id="opacityControl">
<input type="range" min="0" max="1" step="0.1" value="1" id="opacityRange" />
</div>
<div id="overlayWrapper"> <div id="overlayWrapper">
<select id="ctypeList" name="ctypeList"> <select id="ctypeList" name="ctypeList">
{% for c in ctypes %} {% for c in ctypes %}
@ -53,7 +67,7 @@ CONTENT_TYPE_ID = {{ content_type_id }};
</option> </option>
{% endfor %} {% endfor %}
</select> <br /> </select> <br />
Overlay Opacity: <input type="range" min="0" max="1" step="0.1" value="1" id="opacityRange" />
<ul id="itemsList"> <ul id="itemsList">
</ul> </ul>
<div id="itemInfo"> <div id="itemInfo">