feat: Add basic redirect service
This commit is contained in:
parent
96c0c1218f
commit
0d52101f22
@ -50,7 +50,7 @@
|
||||
{% if adoption_notice.further_information %}
|
||||
<td>
|
||||
<form method="get" action="{% url 'external-site' %}">
|
||||
<input type="hidden" name="url" value="adoption_notice.further_information">
|
||||
<input type="hidden" name="url" value="{{ adoption_notice.further_information }}">
|
||||
<button class="btn" type="submit" id="submit">
|
||||
{{ adoption_notice.further_information | domain }} <i class="fa-solid fa-arrow-up-right-from-square"></i>
|
||||
</button>
|
||||
|
@ -0,0 +1,10 @@
|
||||
{% extends "fellchensammlung/base_generic.html" %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<div class="card">
|
||||
{% blocktranslate %}
|
||||
<p>Achtung du verlässt notfellchen.org</p>
|
||||
{% endblocktranslate %}
|
||||
<a href="{{ url }}" class="btn" >{% translate "Weiter" %}</a>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -79,5 +79,9 @@ urlpatterns = [
|
||||
#########
|
||||
path('api/', include('fellchensammlung.api.urls')),
|
||||
|
||||
###################
|
||||
## External Site ##
|
||||
###################
|
||||
path('external-site/', views.external_site_warning, name="external-site"),
|
||||
|
||||
]
|
||||
|
@ -13,7 +13,8 @@ from notfellchen import settings
|
||||
|
||||
from fellchensammlung import logger
|
||||
from .models import AdoptionNotice, Text, Animal, Rule, Image, Report, ModerationAction, \
|
||||
User, Location, AdoptionNoticeStatus, Subscriptions, CommentNotification, BaseNotification, RescueOrganization, Species
|
||||
User, Location, AdoptionNoticeStatus, Subscriptions, CommentNotification, BaseNotification, RescueOrganization, \
|
||||
Species
|
||||
from .forms import AdoptionNoticeForm, AdoptionNoticeFormWithDateWidget, ImageForm, ReportAdoptionNoticeForm, \
|
||||
CommentForm, ReportCommentForm, AnimalForm, \
|
||||
AdoptionNoticeSearchForm, AnimalFormWithDateWidget, AdoptionNoticeFormWithDateWidgetAutoAnimal
|
||||
@ -168,7 +169,8 @@ def search(request):
|
||||
else:
|
||||
adoption_notices_in_distance = [a for a in active_adoptions if a.in_distance(search_position, max_distance)]
|
||||
|
||||
context = {"adoption_notices": adoption_notices_in_distance, "search_form": search_form, "place_not_found": place_not_found}
|
||||
context = {"adoption_notices": adoption_notices_in_distance, "search_form": search_form,
|
||||
"place_not_found": place_not_found}
|
||||
else:
|
||||
latest_adoption_list = AdoptionNotice.objects.order_by("-created_at")
|
||||
active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active]
|
||||
@ -180,7 +182,8 @@ def search(request):
|
||||
@login_required
|
||||
def add_adoption_notice(request):
|
||||
if request.method == 'POST':
|
||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(request.POST, request.FILES, in_adoption_notice_creation_flow=True)
|
||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(request.POST, request.FILES,
|
||||
in_adoption_notice_creation_flow=True)
|
||||
|
||||
if form.is_valid():
|
||||
instance = form.save(commit=False)
|
||||
@ -196,7 +199,8 @@ def add_adoption_notice(request):
|
||||
minor_status = AdoptionNoticeStatus.MINOR_STATUS_CHOICES[AdoptionNoticeStatus.ACTIVE]["searching"]
|
||||
else:
|
||||
major_status = AdoptionNoticeStatus.AWAITING_ACTION
|
||||
minor_status=AdoptionNoticeStatus.MINOR_STATUS_CHOICES[AdoptionNoticeStatus.AWAITING_ACTION]["waiting_for_review"]
|
||||
minor_status = AdoptionNoticeStatus.MINOR_STATUS_CHOICES[AdoptionNoticeStatus.AWAITING_ACTION][
|
||||
"waiting_for_review"]
|
||||
status = AdoptionNoticeStatus.objects.create(major_status=major_status,
|
||||
minor_status=minor_status,
|
||||
adoption_notice=instance)
|
||||
@ -209,7 +213,8 @@ def add_adoption_notice(request):
|
||||
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=instance, species=species, sex=sex, date_of_birth=date_of_birth)
|
||||
name=f"{species} {i + 1}", adoption_notice=instance, species=species, sex=sex,
|
||||
date_of_birth=date_of_birth)
|
||||
return redirect(reverse("adoption-notice-detail", args=[instance.pk]))
|
||||
else:
|
||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(in_adoption_notice_creation_flow=True)
|
||||
@ -420,6 +425,7 @@ def modqueue(request):
|
||||
context = {"reports": open_reports}
|
||||
return render(request, 'fellchensammlung/modqueue.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
def updatequeue(request):
|
||||
if request.method == "POST":
|
||||
@ -453,6 +459,7 @@ def metrics(request):
|
||||
data = gather_metrics_data()
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
@login_required
|
||||
def instance_health_check(request):
|
||||
"""
|
||||
@ -467,7 +474,6 @@ def instance_health_check(request):
|
||||
none_geocoded_adoption_notices = AdoptionNotice.objects.filter(location__isnull=True)
|
||||
number_not_geocoded_adoption_notices = len(none_geocoded_adoption_notices)
|
||||
|
||||
|
||||
number_of_rescue_orgs = RescueOrganization.objects.all().count()
|
||||
none_geocoded_rescue_orgs = RescueOrganization.objects.filter(location__isnull=True)
|
||||
number_not_geocoded_rescue_orgs = len(none_geocoded_rescue_orgs)
|
||||
@ -494,7 +500,14 @@ def instance_health_check(request):
|
||||
"missing_texts": missing_texts
|
||||
}
|
||||
|
||||
|
||||
return render(request, 'fellchensammlung/instance-health-check.html', context=context)
|
||||
|
||||
|
||||
def external_site_warning(request):
|
||||
url = request.GET.get("url")
|
||||
context = {"url": url}
|
||||
language_code = translation.get_language()
|
||||
lang = Language.objects.get(languagecode=language_code)
|
||||
Text.get_texts(["external_site_warning", "good_adoption_practices"], language=lang)
|
||||
|
||||
return render(request, 'fellchensammlung/external_site_warning.html', context=context)
|
||||
|
Loading…
Reference in New Issue
Block a user