diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 0fd9f77..7075826 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -134,6 +134,12 @@ class Location(models.Model): ) return location + @staticmethod + def add_location_to_object(instance): + """Search the location given in the location string and add it to the object""" + location = Location.get_location_from_string(instance.location_string) + instance.location = location + instance.save() class RescueOrganization(models.Model): def __str__(self): diff --git a/src/fellchensammlung/tasks.py b/src/fellchensammlung/tasks.py index 174aad6..05d6d51 100644 --- a/src/fellchensammlung/tasks.py +++ b/src/fellchensammlung/tasks.py @@ -1,6 +1,15 @@ from notfellchen.celery import app as celery_app from .tools.admin import clean_locations +from .models import Location, AdoptionNotice + @celery_app.task(name="admin.clean_locations") def task_clean_locations(): clean_locations() + + +@celery_app.task(name="commit.add_location") +def add_adoption_notice_location(pk): + instance = AdoptionNotice.objects.get(pk=pk) + Location.add_location_to_object(instance) + diff --git a/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html b/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html index ef32db8..0e2d16a 100644 --- a/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html +++ b/src/fellchensammlung/templates/fellchensammlung/details/detail_adoption_notice.html @@ -2,7 +2,7 @@ {% load custom_tags %} {% load i18n %} -{% block title %}