From 5f13736753225b09f587aae5ddc98f8bc3a986d1 Mon Sep 17 00:00:00 2001 From: moanos Date: Fri, 31 May 2024 13:51:14 +0200 Subject: [PATCH] feat: Remove unused title from image --- src/fellchensammlung/forms.py | 2 +- src/fellchensammlung/models.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py index a522dbd..66ceee2 100644 --- a/src/fellchensammlung/forms.py +++ b/src/fellchensammlung/forms.py @@ -90,7 +90,7 @@ class ImageForm(forms.ModelForm): class Meta: model = Image - fields = ('title', 'image', 'alt_text') + fields = ('image', 'alt_text') class ReportAdoptionNoticeForm(forms.ModelForm): diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 42c9217..1d397be 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -36,12 +36,11 @@ class Language(models.Model): class Image(models.Model): - title = models.CharField(max_length=200) image = models.ImageField(upload_to='images') alt_text = models.TextField(max_length=2000) def __str__(self): - return self.title + return self.alt_text @property def as_html(self): @@ -75,8 +74,10 @@ class Location(models.Model): @staticmethod def get_location_from_string(location_string): geo_api = geo.GeoAPI() - get_geojson = geo_api.get_geojson_for_query(location_string) - result = get_geojson[0] + geojson = geo_api.get_geojson_for_query(location_string) + if geojson is None: + return None + result = geojson[0] if "name" in result: name = result["name"] else: