feat: implement mobile notification inbox and settings interface
This commit is contained in:
parent
750abb703e
commit
2ca72aa4da
4 changed files with 29 additions and 8 deletions
|
|
@ -7,7 +7,7 @@ from projects.views import projects_index, projects_detail
|
|||
from observations.views import observations_index_mobile, observation_detail, observation_add
|
||||
from assets.views.core import mobile_asset_detail
|
||||
from inspections import views as inspections
|
||||
from notifications.views import inbox_mobile
|
||||
from notifications.views import inbox_mobile, notification_settings
|
||||
|
||||
app_name = "mobile"
|
||||
urlpatterns = [
|
||||
|
|
@ -33,6 +33,7 @@ urlpatterns = [
|
|||
path('observations/<int:observation_id>/', observation_detail, name='observation_detail_mobile'),
|
||||
path('observations/<int:observation_id>/edit/', observation_add, name='observation_edit_mobile'),
|
||||
path("notifications/", inbox_mobile, name='notifications_mobile'),
|
||||
path("notifications/settings/", notification_settings, name='notifications_settings_mobile'),
|
||||
path("nature/green-surfaces/", views.green_surfaces_edit_mobile, name='green_surfaces_edit_mobile'),
|
||||
path("nature/green-surfaces-custom-draw/", views.green_surfaces_edit_custom_draw, name='green_surfaces_edit_custom_draw'),
|
||||
path("nature/green-surfaces-standalone/", views.green_surfaces_edit_standalone, name='green_surfaces_edit_standalone'),
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
<i class="bi bi-bell me-1 text-primary"></i>{% translate "Notifications" %}
|
||||
</h1>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{% url 'notifications:settings' %}" class="btn btn-outline-secondary btn-sm" title="{% translate 'Paramètres' %}">
|
||||
<a href="{% url 'mobile:notifications_settings_mobile' %}" class="btn btn-outline-secondary btn-sm" title="{% translate 'Paramètres' %}">
|
||||
<i class="bi bi-gear"></i>
|
||||
</a>
|
||||
<a href="{% url 'mobile:mobile_index' %}" class="btn btn-outline-secondary btn-sm">
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends base_template|default:"base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% translate "Paramètres" %}{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container py-4" style="max-width: 760px;">
|
||||
<div class="container py-3" style="max-width: 760px;">
|
||||
|
||||
<!-- Breadcrumb / Header -->
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<a href="{% url 'notifications:inbox' %}" class="btn btn-sm btn-outline-secondary rounded-circle p-2 d-flex align-items-center justify-content-center" style="width:38px; height:38px;">
|
||||
<a href="{{ back_url }}" class="btn btn-sm btn-outline-secondary rounded-circle p-2 d-flex align-items-center justify-content-center" style="width:38px; height:38px;" title="{% translate 'Retour aux notifications' %}">
|
||||
<i class="bi bi-arrow-left fs-6"></i>
|
||||
</a>
|
||||
<div>
|
||||
<h1 class="h3 mb-0 fw-bold">
|
||||
<h1 class="h4 mb-0 fw-bold">
|
||||
<i class="bi bi-gear-fill text-primary me-2"></i>{% translate "Paramètres des notifications" %}
|
||||
</h1>
|
||||
<p class="text-muted small mb-0">{% translate "Gérez vos préférences de rappel par e-mail pour les notifications non lues." %}</p>
|
||||
|
|
@ -26,9 +28,12 @@
|
|||
<i class="bi bi-envelope-at text-primary me-2"></i>{% translate "Rappels par e-mail" %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<div class="card-body p-3 p-md-4">
|
||||
<form method="post" action="">
|
||||
{% csrf_token %}
|
||||
{% if is_mobile %}
|
||||
<input type="hidden" name="from" value="mobile">
|
||||
{% endif %}
|
||||
|
||||
<!-- Preferred Language -->
|
||||
<div class="mb-4">
|
||||
|
|
@ -95,7 +100,7 @@
|
|||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-2 pt-2 border-top">
|
||||
<a href="{% url 'notifications:inbox' %}" class="btn btn-light rounded-pill px-4">
|
||||
<a href="{{ back_url }}" class="btn btn-light rounded-pill px-4">
|
||||
{% translate "Annuler" %}
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary rounded-pill px-4">
|
||||
|
|
|
|||
|
|
@ -626,18 +626,33 @@ def notification_settings(request):
|
|||
|
||||
config, _created = UserConfig.objects.get_or_create(user=request.user)
|
||||
|
||||
is_mobile = (
|
||||
request.GET.get('from') == 'mobile' or
|
||||
request.POST.get('from') == 'mobile' or
|
||||
request.path.startswith('/mobile/') or
|
||||
(request.META.get('HTTP_REFERER') and '/mobile/' in request.META.get('HTTP_REFERER'))
|
||||
)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = NotificationReminderSettingsForm(request.POST, instance=config)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, _("Vos préférences de rappel par e-mail ont été enregistrées."))
|
||||
if is_mobile:
|
||||
return redirect(f"{reverse('mobile:notifications_mobile')}?tab=notifications")
|
||||
return redirect('notifications:settings')
|
||||
else:
|
||||
form = NotificationReminderSettingsForm(instance=config)
|
||||
|
||||
base_template = "mobile/mobile_base.html" if is_mobile else "base.html"
|
||||
back_url = f"{reverse('mobile:notifications_mobile')}?tab=notifications" if is_mobile else f"{reverse('notifications:inbox')}?tab=notifications"
|
||||
|
||||
return render(request, 'notifications/notification_settings.html', {
|
||||
'form': form,
|
||||
'config': config,
|
||||
'is_mobile': is_mobile,
|
||||
'base_template': base_template,
|
||||
'back_url': back_url,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue