feat: Add toggle for e-mail notifications
This commit is contained in:
parent
d0060ecf5e
commit
4b45b01e2a
@ -7,14 +7,19 @@
|
||||
<p><strong>{% translate "Username" %}:</strong> {{ user.username }}</p>
|
||||
<p><strong>{% translate "E-Mail" %}:</strong> {{ user.email }}</p>
|
||||
|
||||
{% if user.preferred_language %}
|
||||
<p><strong>{% translate "Sprache" %}:</strong> {{ user.preferred_language }}</p>
|
||||
{% else %}
|
||||
<p>{% translate "Keine bevorzugte Sprache gesetzt." %}</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="container-cards">
|
||||
{% if user.id is request.user.id %}
|
||||
<div class="container-cards">
|
||||
<div class="detail-animal-header"><h1>{% trans 'Einstellungen' %}</h1></div>
|
||||
<form class="card" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{% if user.email_notifications %}
|
||||
<input class="btn" type="submit" name="toggle_email_notifications"
|
||||
value="{% translate 'E-Mail Benachrichtigungen deaktivieren' %}">
|
||||
{% else %}
|
||||
<input class="btn" type="submit" name="toggle_email_notifications"
|
||||
value="{% translate 'E-Mail Benachrichtigungen aktivieren' %}">
|
||||
{% endif %}
|
||||
</form>
|
||||
<div class="card">
|
||||
{% if token %}
|
||||
<form action="" method="POST">
|
||||
@ -32,7 +37,8 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div><p>
|
||||
</div>
|
||||
|
||||
<div class="container-comment-form">
|
||||
<h2>{% trans 'Profil verwalten' %}</h2>
|
||||
<p>
|
||||
@ -40,7 +46,6 @@
|
||||
<a class="btn2" href="{% url 'user-me-export' %}">{% translate "Daten exportieren" %}</a>
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
<h2>{% translate 'Benachrichtigungen' %}</h2>
|
||||
{% include "fellchensammlung/lists/list-notifications.html" %}
|
||||
<h2>{% translate 'Meine Vermittlungen' %}</h2>
|
||||
|
@ -460,6 +460,10 @@ def my_profile(request):
|
||||
Token.objects.create(user=request.user)
|
||||
elif "delete_token" in request.POST:
|
||||
Token.objects.get(user=request.user).delete()
|
||||
elif "toggle_email_notifications" in request.POST:
|
||||
user = request.user
|
||||
user.email_notifications = not user.email_notifications
|
||||
user.save()
|
||||
|
||||
action = request.POST.get("action")
|
||||
if action == "notification_mark_read":
|
||||
@ -475,6 +479,7 @@ def my_profile(request):
|
||||
for notification in notifications:
|
||||
notification.read = True
|
||||
notification.save()
|
||||
|
||||
try:
|
||||
token = Token.objects.get(user=request.user)
|
||||
except Token.DoesNotExist:
|
||||
|
Loading…
x
Reference in New Issue
Block a user