summaryrefslogtreecommitdiff
path: root/chimere/admin.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-04 17:47:41 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-04 17:47:41 +0100
commit8ac3f9172ad9caad17857ad89f1986b335e22d3d (patch)
treec3627b95794f5480bf8da0919d0a152f5f55e208 /chimere/admin.py
parentaa2f0af0e4d5305b06d58d2819b59baaa022ef53 (diff)
downloadChimère-8ac3f9172ad9caad17857ad89f1986b335e22d3d.tar.bz2
Chimère-8ac3f9172ad9caad17857ad89f1986b335e22d3d.zip
Admin: fix merge form for polygons and routes
Diffstat (limited to 'chimere/admin.py')
-rw-r--r--chimere/admin.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/chimere/admin.py b/chimere/admin.py
index 333db6d..03ed60d 100644
--- a/chimere/admin.py
+++ b/chimere/admin.py
@@ -107,7 +107,7 @@ export_to_csv.short_description = _("Export to CSV")
def managed_modified(modeladmin, request, queryset):
# not very clean... There is must be a better way to do that
- redirect_url = request.get_full_path().split('admin_modification')[0]
+ redirect_url = request.get_full_path().split('admin-')[0]
if queryset.count() != 1 and len(set([i.ref_item or i
for i in queryset.all()])) != 1:
messages.error(request, _("Only one item can be managed at a "
@@ -311,7 +311,6 @@ POLYGON_FIELDSETS = deepcopy(MARKER_FIELDSETS)
POLYGON_FIELDSETS[0][1]['fields'][0] = 'polygon'
POLYGON_FIELDSETS[0][1]['fields'].pop(POLYGON_FIELDSETS[0][1]['fields'].index(
'description'))
-POLYGON_FIELDSETS.pop(3)
class MarkerAdmin(admin.ModelAdmin):
@@ -371,11 +370,12 @@ class MarkerAdmin(admin.ModelAdmin):
def get_urls(self):
from django.conf.urls import patterns, url
urls = super(MarkerAdmin, self).get_urls()
+ model_name = self.model.__name__.lower()
my_urls = patterns(
'',
- url(r'^admin_modification/(?P<item_id>\d+)/$',
+ url(r'^admin-{}-modification/(?P<item_id>\d+)/$'.format(model_name),
self.admin_site.admin_view(self.admin_modification),
- name='admin-modification'),
+ name='admin-{}-modification'.format(model_name)),
)
return my_urls + urls
@@ -464,6 +464,13 @@ class PolygonAdmin(MarkerAdmin):
fieldsets = POLYGON_FIELDSETS
geo_type = 'polygon'
+ def admin_modification(self, request, item_id):
+ """
+ Redirect to the polygon modification form
+ """
+ return managed_modified(self, request,
+ models.Polygon.objects.filter(pk=item_id))
+
class LayerInline(admin.TabularInline):
model = AreaLayers