Skip to content

Commit 0bf7fae

Browse files
Notificaties zien zonder login #921
1 parent fbb4639 commit 0bf7fae

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

docs/changelog.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Changelog
55
v3.7.0 - 2020-xx-xx
66

77
- [`#919 <https://github.com/dennissiemensma/dsmr-reader/issues/919>`_] Parsing telegram 3-fasige Fluvius meter faalt
8-
- [`#xxxxxxxxxx <https://github.com/dennissiemensma/dsmr-reader/issues/xxxxxxxxxx>`_] xxxxxxxxxx
8+
- [`#921 <https://github.com/dennissiemensma/dsmr-reader/issues/921>`_] Notificaties bekijken zonder login #921
99

1010

1111
----

dsmr_frontend/templates/dsmr_frontend/notifications.html

+11-6
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,30 @@
1717
<header class="panel-heading">
1818
{% trans "Unread Notifications" %}
1919
&nbsp;
20-
{% if notifications %}
21-
<div class="pull-right">
20+
<div class="pull-right">
21+
{% if notifications and user.is_authenticated %}
2222
<button class="btn btn-sm btn-success mark-all-notifications-read" data-notification-id="{{ current_notification.pk }}" title="{% trans 'Mark all notifications as read' %}">
2323
<i class="fas fa-check-double"></i> {% trans 'Mark all as read' %}
2424
</button>
25-
</div>
26-
{% endif %}
25+
{% else %}
26+
<a class="btn btn-sm btn-primary" href="{% url 'admin:login' %}?next={% url 'frontend:notifications' %}">
27+
<i class="fas fa-lock"></i> &nbsp; {% trans 'Login to mark as read' %}
28+
</a>
29+
{% endif %}
30+
</div>
2731
</header>
2832
<div class="panel-body">
2933
{% if notifications %}
3034
{% for current_notification in notifications %}
3135
<div class="alert alert-info" role="alert">
36+
{% if user.is_authenticated %}
3237
<button class="btn btn-sm btn-success mark-notification-read" data-notification-id="{{ current_notification.pk }}" title="{% trans 'Mark as read' %}">
3338
<i class="fas fa-check"></i>
3439
</button>
35-
&nbsp;
40+
&nbsp{% endif %}
3641

3742
{% if current_notification.redirect_to %}
38-
<a class="btn btn-sm btn-primary" href="{% url current_notification.redirect_to %}" title="{% trans "View page" %}"><i class="fas fa-external-link-alt"></i></a>
43+
<a class="btn btn-sm btn-primary" href="{% url current_notification.redirect_to %}" title="{% trans "View page" %}"><i class="fas fa-external-link-alt"></i></a> &nbsp;
3944
{% endif %}
4045

4146
{{ current_notification.message }}

dsmr_frontend/tests/webinterface/test_notifications.py

-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ def setUp(self):
1818
def test_notifications(self):
1919
view_url = reverse('{}:notifications'.format(self.namespace))
2020

21-
# Check login required.
22-
response = self.client.get(view_url)
23-
self.assertEqual(response.status_code, 302)
24-
self.assertEqual(
25-
response['Location'], '/admin/login/?next={}'.format(view_url)
26-
)
27-
28-
# Logged in.
29-
self.client.login(username='testuser', password='passwd')
3021
response = self.client.get(view_url)
3122
self.assertEqual(response.status_code, 200, response.content)
3223
self.assertIn('notifications', response.context)

dsmr_frontend/urls.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
path('status', Status.as_view(), name='status'),
4646
path('status/xhr/check-for-updates', XhrUpdateChecker.as_view(), name='status-xhr-check-for-updates'),
4747

48+
path('notifications', Notifications.as_view(), name='notifications'),
49+
4850
# Docs.
4951
path('docs/api', ApiDocs.as_view(), name='api-docs'),
5052

@@ -58,7 +60,6 @@
5860
path('configuration', Configuration.as_view(), name='configuration'),
5961
path('export', Export.as_view(), name='export'),
6062
path('export/csv', ExportAsCsv.as_view(), name='export-as-csv'),
61-
path('notifications', Notifications.as_view(), name='notifications'),
6263
path('notifications/xhr/mark-read', XhrMarkNotificationRead.as_view(), name='notification-xhr-mark-read'),
6364
path(
6465
'notifications/xhr/mark-all-read',

dsmr_frontend/views/notifications.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from dsmr_frontend.models.message import Notification
1010

1111

12-
class Notifications(LoginRequiredMixin, TemplateView):
12+
class Notifications(TemplateView):
1313
template_name = 'dsmr_frontend/notifications.html'
1414

1515
def get_context_data(self, **kwargs):
91 Bytes
Binary file not shown.

dsmrreader/locales/nl/LC_MESSAGES/django.po

+3
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,9 @@ msgstr "Markeer alle notificaties als gelezen"
13301330
msgid "Mark all as read"
13311331
msgstr "Markeer allemaal als gelezen"
13321332

1333+
msgid "Login to mark as read"
1334+
msgstr "Log in om te markeren als gelezen"
1335+
13331336
msgid "Mark as read"
13341337
msgstr "Markeer als gelezen"
13351338

0 commit comments

Comments
 (0)