diff --git a/src/fellchensammlung/static/fellchensammlung/css/styles.css b/src/fellchensammlung/static/fellchensammlung/css/styles.css index 8b2a05d..5a8a3a6 100644 --- a/src/fellchensammlung/static/fellchensammlung/css/styles.css +++ b/src/fellchensammlung/static/fellchensammlung/css/styles.css @@ -700,7 +700,7 @@ a.btn, a.btn2, a.nav-link { padding: 5px; } -.comment, .notification { +.comment, .notification, .search-subscription { flex: 1 100%; margin: 10px; border-radius: 8px; diff --git a/src/fellchensammlung/templates/fellchensammlung/details/detail-user.html b/src/fellchensammlung/templates/fellchensammlung/details/detail-user.html index 0128aeb..4ef4bce 100644 --- a/src/fellchensammlung/templates/fellchensammlung/details/detail-user.html +++ b/src/fellchensammlung/templates/fellchensammlung/details/detail-user.html @@ -69,6 +69,10 @@

{% translate 'Benachrichtigungen' %}

{% include "fellchensammlung/lists/list-notifications.html" %} + +

{% translate 'Abonnierte Suchen' %}

+ {% include "fellchensammlung/lists/list-search-subscriptions.html" %} +

{% translate 'Meine Vermittlungen' %}

{% include "fellchensammlung/lists/list-adoption-notices.html" %} diff --git a/src/fellchensammlung/templates/fellchensammlung/lists/list-search-subscriptions.html b/src/fellchensammlung/templates/fellchensammlung/lists/list-search-subscriptions.html new file mode 100644 index 0000000..787a300 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/lists/list-search-subscriptions.html @@ -0,0 +1,10 @@ +{% load i18n %} +
+ {% if search_subscriptions %} + {% for search_subscription in search_subscriptions %} + {% include "fellchensammlung/partials/partial-search-subscription.html" %} + {% endfor %} + {% else %} +

{% translate 'Keine abonnierten Suchen' %}

+ {% endif %} +
diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/partial-search-subscription.html b/src/fellchensammlung/templates/fellchensammlung/partials/partial-search-subscription.html new file mode 100644 index 0000000..66d2359 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/partials/partial-search-subscription.html @@ -0,0 +1,25 @@ +{% load i18n %} +{% load custom_tags %} +
+
+

{{ search_subscription }}

+
+ {% csrf_token %} + + + +
+
+ + + + + + + + + + + +
{% trans 'Geschlecht' %}{% trans 'Suchort' %}{% trans 'Suchradius' %}
{{ search_subscription.sex }}{{ search_subscription.location }}{{ search_subscription.max_distance }}km
+
diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 70448ac..3f78f6a 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -439,7 +439,8 @@ def report_detail_success(request, report_id): def user_detail(request, user, token=None): context = {"user": user, "adoption_notices": AdoptionNotice.objects.filter(owner=user), - "notifications": BaseNotification.objects.filter(user=user, read=False)} + "notifications": BaseNotification.objects.filter(user=user, read=False), + "search_subscriptions": SearchSubscription.objects.filter(owner=user),} if token is not None: context["token"] = token return render(request, 'fellchensammlung/details/detail-user.html', context=context) @@ -482,6 +483,10 @@ def my_profile(request): for notification in notifications: notification.read = True notification.save() + elif action == "search_subscription_delete": + search_subscription_id = request.POST.get("search_subscription_id") + SearchSubscription.objects.get(pk=search_subscription_id).delete() + logging.info(f"Deleted subscription {search_subscription_id}") try: token = Token.objects.get(user=request.user)