feat: Add basic redirect service
This commit is contained in:
parent
96c0c1218f
commit
0d52101f22
@ -50,7 +50,7 @@
|
|||||||
{% if adoption_notice.further_information %}
|
{% if adoption_notice.further_information %}
|
||||||
<td>
|
<td>
|
||||||
<form method="get" action="{% url 'external-site' %}">
|
<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">
|
<button class="btn" type="submit" id="submit">
|
||||||
{{ adoption_notice.further_information | domain }} <i class="fa-solid fa-arrow-up-right-from-square"></i>
|
{{ adoption_notice.further_information | domain }} <i class="fa-solid fa-arrow-up-right-from-square"></i>
|
||||||
</button>
|
</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')),
|
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 fellchensammlung import logger
|
||||||
from .models import AdoptionNotice, Text, Animal, Rule, Image, Report, ModerationAction, \
|
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, \
|
from .forms import AdoptionNoticeForm, AdoptionNoticeFormWithDateWidget, ImageForm, ReportAdoptionNoticeForm, \
|
||||||
CommentForm, ReportCommentForm, AnimalForm, \
|
CommentForm, ReportCommentForm, AnimalForm, \
|
||||||
AdoptionNoticeSearchForm, AnimalFormWithDateWidget, AdoptionNoticeFormWithDateWidgetAutoAnimal
|
AdoptionNoticeSearchForm, AnimalFormWithDateWidget, AdoptionNoticeFormWithDateWidgetAutoAnimal
|
||||||
@ -117,7 +118,7 @@ def adoption_notice_detail(request, adoption_notice_id):
|
|||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
else:
|
else:
|
||||||
comment_form = CommentForm(instance=adoption_notice)
|
comment_form = CommentForm(instance=adoption_notice)
|
||||||
context = {"adoption_notice": adoption_notice,"comment_form": comment_form, "user": request.user,
|
context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user,
|
||||||
"has_edit_permission": has_edit_permission, "is_subscribed": is_subscribed}
|
"has_edit_permission": has_edit_permission, "is_subscribed": is_subscribed}
|
||||||
return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)
|
return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)
|
||||||
|
|
||||||
@ -168,7 +169,8 @@ def search(request):
|
|||||||
else:
|
else:
|
||||||
adoption_notices_in_distance = [a for a in active_adoptions if a.in_distance(search_position, max_distance)]
|
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:
|
else:
|
||||||
latest_adoption_list = AdoptionNotice.objects.order_by("-created_at")
|
latest_adoption_list = AdoptionNotice.objects.order_by("-created_at")
|
||||||
active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active]
|
active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active]
|
||||||
@ -180,7 +182,8 @@ def search(request):
|
|||||||
@login_required
|
@login_required
|
||||||
def add_adoption_notice(request):
|
def add_adoption_notice(request):
|
||||||
if request.method == 'POST':
|
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():
|
if form.is_valid():
|
||||||
instance = form.save(commit=False)
|
instance = form.save(commit=False)
|
||||||
@ -195,8 +198,9 @@ def add_adoption_notice(request):
|
|||||||
major_status = AdoptionNoticeStatus.ACTIVE
|
major_status = AdoptionNoticeStatus.ACTIVE
|
||||||
minor_status = AdoptionNoticeStatus.MINOR_STATUS_CHOICES[AdoptionNoticeStatus.ACTIVE]["searching"]
|
minor_status = AdoptionNoticeStatus.MINOR_STATUS_CHOICES[AdoptionNoticeStatus.ACTIVE]["searching"]
|
||||||
else:
|
else:
|
||||||
major_status=AdoptionNoticeStatus.AWAITING_ACTION
|
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,
|
status = AdoptionNoticeStatus.objects.create(major_status=major_status,
|
||||||
minor_status=minor_status,
|
minor_status=minor_status,
|
||||||
adoption_notice=instance)
|
adoption_notice=instance)
|
||||||
@ -209,7 +213,8 @@ def add_adoption_notice(request):
|
|||||||
date_of_birth = form.cleaned_data["date_of_birth"]
|
date_of_birth = form.cleaned_data["date_of_birth"]
|
||||||
for i in range(0, num_animals):
|
for i in range(0, num_animals):
|
||||||
Animal.objects.create(owner=request.user,
|
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]))
|
return redirect(reverse("adoption-notice-detail", args=[instance.pk]))
|
||||||
else:
|
else:
|
||||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(in_adoption_notice_creation_flow=True)
|
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(in_adoption_notice_creation_flow=True)
|
||||||
@ -420,6 +425,7 @@ def modqueue(request):
|
|||||||
context = {"reports": open_reports}
|
context = {"reports": open_reports}
|
||||||
return render(request, 'fellchensammlung/modqueue.html', context=context)
|
return render(request, 'fellchensammlung/modqueue.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def updatequeue(request):
|
def updatequeue(request):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
@ -453,6 +459,7 @@ def metrics(request):
|
|||||||
data = gather_metrics_data()
|
data = gather_metrics_data()
|
||||||
return JsonResponse(data)
|
return JsonResponse(data)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def instance_health_check(request):
|
def instance_health_check(request):
|
||||||
"""
|
"""
|
||||||
@ -467,7 +474,6 @@ def instance_health_check(request):
|
|||||||
none_geocoded_adoption_notices = AdoptionNotice.objects.filter(location__isnull=True)
|
none_geocoded_adoption_notices = AdoptionNotice.objects.filter(location__isnull=True)
|
||||||
number_not_geocoded_adoption_notices = len(none_geocoded_adoption_notices)
|
number_not_geocoded_adoption_notices = len(none_geocoded_adoption_notices)
|
||||||
|
|
||||||
|
|
||||||
number_of_rescue_orgs = RescueOrganization.objects.all().count()
|
number_of_rescue_orgs = RescueOrganization.objects.all().count()
|
||||||
none_geocoded_rescue_orgs = RescueOrganization.objects.filter(location__isnull=True)
|
none_geocoded_rescue_orgs = RescueOrganization.objects.filter(location__isnull=True)
|
||||||
number_not_geocoded_rescue_orgs = len(none_geocoded_rescue_orgs)
|
number_not_geocoded_rescue_orgs = len(none_geocoded_rescue_orgs)
|
||||||
@ -494,7 +500,14 @@ def instance_health_check(request):
|
|||||||
"missing_texts": missing_texts
|
"missing_texts": missing_texts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return render(request, 'fellchensammlung/instance-health-check.html', context=context)
|
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