diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-02-06 16:44:38 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacfrogs.net> | 2013-02-06 16:46:27 +0100 |
commit | 02004f090c5a98bbeda6f6cdad708b95ea717ab1 (patch) | |
tree | cc82efea548caf0ddcb36c0c9ba77fc56e5b6be2 | |
parent | 32dc52d8194afd9454990ab3ec21ab2f152121d2 (diff) | |
download | Chimère-02004f090c5a98bbeda6f6cdad708b95ea717ab1.tar.bz2 Chimère-02004f090c5a98bbeda6f6cdad708b95ea717ab1.zip |
Admin: fix route admin when a property is newly set
-rw-r--r-- | chimere/admin.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chimere/admin.py b/chimere/admin.py index 4b83878..996dfd5 100644 --- a/chimere/admin.py +++ b/chimere/admin.py @@ -210,17 +210,19 @@ class MarkerAdmin(admin.ModelAdmin): }), ) inlines = [MultimediaInline, PictureInline] + has_properties = True def __init__(self, *args, **kwargs): """ Manage properties in fieldsets. """ - main_fields = self.fieldsets[0][1]['fields'] - for pm in PropertyModel.objects.filter(available=True).order_by('order' + if self.has_properties: + main_fields = self.fieldsets[0][1]['fields'] + for pm in PropertyModel.objects.filter(available=True).order_by('order' ).all(): - pm_name = pm.getNamedId() - if pm_name not in main_fields: - main_fields.append(pm_name) + pm_name = pm.getNamedId() + if pm_name not in main_fields: + main_fields.append(pm_name) super(MarkerAdmin, self).__init__(*args, **kwargs) def queryset(self, request): @@ -286,6 +288,7 @@ class RouteAdmin(MarkerAdmin): }), ) inlines = [] + has_properties = False def queryset(self, request): qs = self.model._default_manager.get_query_set() |