From ac2913cd0815a59dff740d3a0ec35ac4eef13649 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Tue, 14 May 2024 10:55:52 +0200 Subject: [PATCH] fixmissing station on contribution admin --- georiviere/contribution/admin.py | 4 ---- .../migrations/0024_auto_20240514_0849.py | 17 +++++++++++++++++ georiviere/observations/models.py | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 georiviere/observations/migrations/0024_auto_20240514_0849.py diff --git a/georiviere/contribution/admin.py b/georiviere/contribution/admin.py index e87d503e..eaaf2ccb 100644 --- a/georiviere/contribution/admin.py +++ b/georiviere/contribution/admin.py @@ -121,10 +121,6 @@ class CustomContributionAdmin(LeafletGeoAdmin, admin.ModelAdmin): form = forms.CustomContributionForm inlines = [CustomContribAttachmentInline] - def station(self, obj): - return obj.station.label - station.admin_order_field = 'label' - def get_readonly_fields(self, request, obj=None): if not obj or not obj.pk: return ("data",) diff --git a/georiviere/observations/migrations/0024_auto_20240514_0849.py b/georiviere/observations/migrations/0024_auto_20240514_0849.py new file mode 100644 index 00000000..628231e9 --- /dev/null +++ b/georiviere/observations/migrations/0024_auto_20240514_0849.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.14 on 2024-05-14 08:49 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('observations', '0023_auto_20230220_1703'), + ] + + operations = [ + migrations.AlterModelOptions( + name='station', + options={'ordering': ('label', 'pk'), 'verbose_name': 'Station', 'verbose_name_plural': 'Stations'}, + ), + ] diff --git a/georiviere/observations/models.py b/georiviere/observations/models.py index 2302582a..c08d336e 100644 --- a/georiviere/observations/models.py +++ b/georiviere/observations/models.py @@ -89,6 +89,7 @@ class LocalInfluenceChoices(models.IntegerChoices): class Meta: verbose_name = _("Station") verbose_name_plural = _("Stations") + ordering = ('label', 'pk') def __str__(self): return "{1} ({0})".format(self.code, self.label)