From f2f526c9ded5470cff15e527e0a98234e1ade1f5 Mon Sep 17 00:00:00 2001 From: moanos Date: Tue, 17 Jun 2025 06:53:06 +0200 Subject: [PATCH] refactor: Remove non-bulma add-adoption --- .../fellchensammlung/bulma-header.html | 2 +- src/fellchensammlung/urls.py | 3 +- src/fellchensammlung/views.py | 43 +------------------ 3 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/fellchensammlung/templates/fellchensammlung/bulma-header.html b/src/fellchensammlung/templates/fellchensammlung/bulma-header.html index c435c1a..b5b14b7 100644 --- a/src/fellchensammlung/templates/fellchensammlung/bulma-header.html +++ b/src/fellchensammlung/templates/fellchensammlung/bulma-header.html @@ -22,7 +22,7 @@ {% translate 'Suchen' %} - + {% translate 'Vermittlung hinzufügen' %} diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index a033220..44afe8b 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -57,8 +57,7 @@ urlpatterns = [ # ex: /map/ path("bulma/map/", views.map_bulma, name="map-bulma"), # ex: /vermitteln/ - path("vermitteln/", views.add_adoption_notice, name="add-adoption"), - path("bulma/vermitteln/", views.add_adoption_notice_bulma, name="add-adoption-bulma"), + path("vermitteln/", views.add_adoption_notice_bulma, name="add-adoption"), path("ueber-uns/", views.about, name="about"), path("bulma/ueber-uns/", views.about_bulma, name="about-bulma"), diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index d19e540..d0285f5 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -47,6 +47,7 @@ def fail_if_user_not_owner_or_trust_level(user, django_object, trust_level=Trust if not user_is_owner_or_trust_level(user, django_object, trust_level): raise PermissionDenied + def index(request): """View function for home page of site.""" latest_adoption_list = AdoptionNotice.objects.filter( @@ -246,48 +247,6 @@ def search(request, templatename="fellchensammlung/bulma-search.html"): return render(request, templatename, context=context) -@login_required -def add_adoption_notice(request): - if request.method == 'POST': - form = AdoptionNoticeFormAutoAnimal(request.POST, request.FILES, - in_adoption_notice_creation_flow=True) - - if form.is_valid(): - an_instance = form.save(commit=False) - an_instance.owner = request.user - - if request.user.trust_level >= TrustLevel.MODERATOR: - an_instance.set_active() - else: - an_instance.set_unchecked() - - # Get the species and number of animals from the form - species = form.cleaned_data["species"] - sex = form.cleaned_data["sex"] - num_animals = form.cleaned_data["num_animals"] - date_of_birth = form.cleaned_data["date_of_birth"] - for i in range(0, num_animals): - Animal.objects.create(owner=request.user, - name=f"{species} {i + 1}", adoption_notice=an_instance, species=species, sex=sex, - date_of_birth=date_of_birth) - - """Log""" - Log.objects.create(user=request.user, action="add_adoption_notice", - text=f"{request.user} hat Vermittlung {an_instance.pk} hinzugefügt") - - """Spin up a task that adds the location and notifies search subscribers""" - post_adoption_notice_save.delay(an_instance.id) - - """Subscriptions""" - # Automatically subscribe user that created AN to AN - Subscriptions.objects.create(owner=request.user, adoption_notice=an_instance) - - return redirect(reverse("adoption-notice-detail", args=[an_instance.pk])) - else: - form = AdoptionNoticeFormAutoAnimal(in_adoption_notice_creation_flow=True) - return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form}) - - @login_required def add_adoption_notice_bulma(request): if request.method == 'POST':