refactor: Remove non-bulma add-adoption
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
<i class="fas fa-search"></i> {% translate 'Suchen' %}
|
<i class="fas fa-search"></i> {% translate 'Suchen' %}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="navbar-item" href="{% url "add-adoption-bulma" %}">
|
<a class="navbar-item" href="{% url "add-adoption" %}">
|
||||||
<i class="fas fa-feather"></i> {% translate 'Vermittlung hinzufügen' %}
|
<i class="fas fa-feather"></i> {% translate 'Vermittlung hinzufügen' %}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
@@ -57,8 +57,7 @@ urlpatterns = [
|
|||||||
# ex: /map/
|
# ex: /map/
|
||||||
path("bulma/map/", views.map_bulma, name="map-bulma"),
|
path("bulma/map/", views.map_bulma, name="map-bulma"),
|
||||||
# ex: /vermitteln/
|
# ex: /vermitteln/
|
||||||
path("vermitteln/", views.add_adoption_notice, name="add-adoption"),
|
path("vermitteln/", views.add_adoption_notice_bulma, name="add-adoption"),
|
||||||
path("bulma/vermitteln/", views.add_adoption_notice_bulma, name="add-adoption-bulma"),
|
|
||||||
|
|
||||||
path("ueber-uns/", views.about, name="about"),
|
path("ueber-uns/", views.about, name="about"),
|
||||||
path("bulma/ueber-uns/", views.about_bulma, name="about-bulma"),
|
path("bulma/ueber-uns/", views.about_bulma, name="about-bulma"),
|
||||||
|
@@ -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):
|
if not user_is_owner_or_trust_level(user, django_object, trust_level):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""View function for home page of site."""
|
"""View function for home page of site."""
|
||||||
latest_adoption_list = AdoptionNotice.objects.filter(
|
latest_adoption_list = AdoptionNotice.objects.filter(
|
||||||
@@ -246,48 +247,6 @@ def search(request, templatename="fellchensammlung/bulma-search.html"):
|
|||||||
return render(request, templatename, context=context)
|
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
|
@login_required
|
||||||
def add_adoption_notice_bulma(request):
|
def add_adoption_notice_bulma(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
Reference in New Issue
Block a user