feat: add list of search subscriptions to user profile
This commit is contained in:
parent
d17fcc1da2
commit
0afb2bb0ce
@ -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;
|
||||
|
@ -69,6 +69,10 @@
|
||||
|
||||
<h2>{% translate 'Benachrichtigungen' %}</h2>
|
||||
{% include "fellchensammlung/lists/list-notifications.html" %}
|
||||
|
||||
<h2>{% translate 'Abonnierte Suchen' %}</h2>
|
||||
{% include "fellchensammlung/lists/list-search-subscriptions.html" %}
|
||||
|
||||
<h2>{% translate 'Meine Vermittlungen' %}</h2>
|
||||
{% include "fellchensammlung/lists/list-adoption-notices.html" %}
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
{% load i18n %}
|
||||
<div class="container-cards">
|
||||
{% if search_subscriptions %}
|
||||
{% for search_subscription in search_subscriptions %}
|
||||
{% include "fellchensammlung/partials/partial-search-subscription.html" %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>{% translate 'Keine abonnierten Suchen' %}</p>
|
||||
{% endif %}
|
||||
</div>
|
@ -0,0 +1,25 @@
|
||||
{% load i18n %}
|
||||
{% load custom_tags %}
|
||||
<div class="search-subscription">
|
||||
<div class="search-subscription-header">
|
||||
<h3>{{ search_subscription }}</h3>
|
||||
<form class="notification-card-mark-read" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="search_subscription_delete">
|
||||
<input type="hidden" name="search_subscription_id" value="{{ search_subscription.pk }}">
|
||||
<button class="btn2" type="submit" id="submit"><i class="fa-solid fa-close"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>{% trans 'Geschlecht' %}</th>
|
||||
<th>{% trans 'Suchort' %}</th>
|
||||
<th>{% trans 'Suchradius' %}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ search_subscription.sex }}</td>
|
||||
<td>{{ search_subscription.location }}</td>
|
||||
<td>{{ search_subscription.max_distance }}km</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user