feat: Add rescue organization check
This commit is contained in:
		@@ -0,0 +1,20 @@
 | 
			
		||||
# Generated by Django 5.1.4 on 2025-03-09 08:31
 | 
			
		||||
 | 
			
		||||
import django.utils.timezone
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('fellchensammlung', '0037_alter_basenotification_title'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='rescueorganization',
 | 
			
		||||
            name='last_checked',
 | 
			
		||||
            field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Datum der letzten Prüfung'),
 | 
			
		||||
            preserve_default=False,
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -122,6 +122,7 @@ class RescueOrganization(models.Model):
 | 
			
		||||
    website = models.URLField(null=True, blank=True, verbose_name=_('Website'))
 | 
			
		||||
    updated_at = models.DateTimeField(auto_now=True)
 | 
			
		||||
    created_at = models.DateTimeField(auto_now_add=True)
 | 
			
		||||
    last_checked = models.DateTimeField(verbose_name=_('Datum der letzten Prüfung'))
 | 
			
		||||
    internal_comment = models.TextField(verbose_name=_("Interner Kommentar"), null=True, blank=True, )
 | 
			
		||||
    description = models.TextField(null=True, blank=True, verbose_name=_('Beschreibung'))  # Markdown allowed
 | 
			
		||||
    external_object_identifier = models.CharField(max_length=200, null=True, blank=True,
 | 
			
		||||
@@ -151,6 +152,15 @@ class RescueOrganization(models.Model):
 | 
			
		||||
        if len(self.description) > 200:
 | 
			
		||||
            return self.description[:200] + _(f" ... [weiterlesen]({self.get_absolute_url()})")
 | 
			
		||||
 | 
			
		||||
    def set_checked(self):
 | 
			
		||||
        self.last_checked = timezone.now()
 | 
			
		||||
        self.save()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def last_checked_hr(self):
 | 
			
		||||
        time_since_last_checked = timezone.now() - self.last_checked
 | 
			
		||||
        return time_since_as_hr_string(time_since_last_checked)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Admins can perform all actions and have the highest trust associated with them
 | 
			
		||||
# Moderators can make moderation decisions regarding the deletion of content
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load custom_tags %}
 | 
			
		||||
<div class="card">
 | 
			
		||||
    <h1>
 | 
			
		||||
        <a href="{{ rescue_org.get_absolute_url }}">{{ rescue_org.name }}</a>
 | 
			
		||||
    </h1>
 | 
			
		||||
    <i>{% translate 'Zuletzt geprüft:' %} {{ rescue_org.last_checked_hr }}</i>
 | 
			
		||||
    {% if rescue_org.website %}
 | 
			
		||||
        <p>{% translate "Website" %}: {{ rescue_org.website | safe }}</p>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    <div class="container-edit-buttons">
 | 
			
		||||
        <form method="post">
 | 
			
		||||
            {% csrf_token %}
 | 
			
		||||
            <input type="hidden"
 | 
			
		||||
                   name="rescue_organization_id"
 | 
			
		||||
                   value="{{ rescue_org.pk }}">
 | 
			
		||||
            <input type="hidden" name="action" value="checked">
 | 
			
		||||
            <button class="btn" type="submit">{% translate "Organisation geprüft" %}</button>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
{% extends "fellchensammlung/base_generic.html" %}
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <h1>{% translate "Aktualitätscheck" %}</h1>
 | 
			
		||||
    <p>{% translate "Überprüfe ob im Tierheim neue Vermittlungen ein Zuhause suchen" %}</p>
 | 
			
		||||
    <div class="container-cards spaced">
 | 
			
		||||
        <h1>{% translate 'Organisation zur Überprüfung' %}</h1>
 | 
			
		||||
        {% for rescue_org in rescue_orgs %}
 | 
			
		||||
            {% include "fellchensammlung/partials/partial-check-rescue-org.html" %}
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
    </div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -31,9 +31,11 @@ urlpatterns = [
 | 
			
		||||
    # ex: /adoption_notice/7/edit
 | 
			
		||||
    path("vermittlung/<int:adoption_notice_id>/edit", views.adoption_notice_edit, name="adoption-notice-edit"),
 | 
			
		||||
    # ex: /vermittlung/5/add-photo
 | 
			
		||||
    path("vermittlung/<int:adoption_notice_id>/add-photo", views.add_photo_to_adoption_notice, name="adoption-notice-add-photo"),
 | 
			
		||||
    path("vermittlung/<int:adoption_notice_id>/add-photo", views.add_photo_to_adoption_notice,
 | 
			
		||||
         name="adoption-notice-add-photo"),
 | 
			
		||||
    # ex: /adoption_notice/2/add-animal
 | 
			
		||||
    path("vermittlung/<int:adoption_notice_id>/add-animal", views.adoption_notice_add_animal, name="adoption-notice-add-animal"),
 | 
			
		||||
    path("vermittlung/<int:adoption_notice_id>/add-animal", views.adoption_notice_add_animal,
 | 
			
		||||
         name="adoption-notice-add-animal"),
 | 
			
		||||
 | 
			
		||||
    path("tierschutzorganisationen/", views.list_rescue_organizations, name="rescue-organizations"),
 | 
			
		||||
    path("organisation/<int:rescue_organization_id>/", views.detail_view_rescue_organization,
 | 
			
		||||
@@ -57,9 +59,11 @@ urlpatterns = [
 | 
			
		||||
    path("meldung/<uuid:report_id>/", views.report_detail, name="report-detail"),
 | 
			
		||||
    path("meldung/<uuid:report_id>/sucess", views.report_detail_success, name="report-detail-success"),
 | 
			
		||||
    path("modqueue/", views.modqueue, name="modqueue"),
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    path("updatequeue/", views.updatequeue, name="updatequeue"),
 | 
			
		||||
 | 
			
		||||
    path("organization-check/", views.rescue_organization_check, name="organization-check"),
 | 
			
		||||
 | 
			
		||||
    ###########
 | 
			
		||||
    ## USERS ##
 | 
			
		||||
    ###########
 | 
			
		||||
 
 | 
			
		||||
@@ -639,3 +639,18 @@ def styleguide(request):
 | 
			
		||||
 | 
			
		||||
    context = {"geocoding_api_url": settings.GEOCODING_API_URL, }
 | 
			
		||||
    return render(request, 'fellchensammlung/styleguide.html', context=context)
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
def rescue_organization_check(request):
 | 
			
		||||
    if request.method == "POST":
 | 
			
		||||
        rescue_org = RescueOrganization.objects.get(id=request.POST.get("rescue_organization_id"))
 | 
			
		||||
        edit_permission = user_is_trust_level_or_above(request.user, TrustLevel.MODERATOR)
 | 
			
		||||
        if not edit_permission:
 | 
			
		||||
            return render(request, "fellchensammlung/errors/403.html", status=403)
 | 
			
		||||
        action = request.POST.get("action")
 | 
			
		||||
        if action == "checked":
 | 
			
		||||
            rescue_org.set_checked()
 | 
			
		||||
 | 
			
		||||
    last_checked_rescue_orgs = RescueOrganization.objects.order_by("last_checked")
 | 
			
		||||
    context = {"rescue_orgs": last_checked_rescue_orgs,}
 | 
			
		||||
    return render(request, 'fellchensammlung/rescue-organization-check.html', context=context)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user