forked from mirrors/bookwyrm
Highlight unread notifications
This commit is contained in:
parent
3ddd4a0490
commit
e8cfa99cd9
3 changed files with 8 additions and 1 deletions
|
@ -221,3 +221,7 @@ th, td {
|
||||||
.post.depth-4 {
|
.post.depth-4 {
|
||||||
margin-left: 3em;
|
margin-left: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.unread {
|
||||||
|
background-color: #F3FFBD;
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<button type="submit">Delete notifications</button>
|
<button type="submit">Delete notifications</button>
|
||||||
</form>
|
</form>
|
||||||
{% for notification in notifications %}
|
{% for notification in notifications %}
|
||||||
<div class="notification{% if not notification.read %}unread{% endif %}">
|
<div class="notification{% if notification.id in unread %} unread{% endif %}">
|
||||||
<p>
|
<p>
|
||||||
{% if notification.notification_type == 'FAVORITE' %}
|
{% if notification.notification_type == 'FAVORITE' %}
|
||||||
{% include 'snippets/username.html' with user=notification.related_user %}
|
{% include 'snippets/username.html' with user=notification.related_user %}
|
||||||
|
|
|
@ -139,12 +139,15 @@ def register(request):
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
def notifications_page(request):
|
def notifications_page(request):
|
||||||
''' list notitications '''
|
''' list notitications '''
|
||||||
notifications = request.user.notification_set.all() \
|
notifications = request.user.notification_set.all() \
|
||||||
.order_by('-created_date')
|
.order_by('-created_date')
|
||||||
|
unread = [n.id for n in notifications.filter(read=False)]
|
||||||
data = {
|
data = {
|
||||||
'notifications': notifications,
|
'notifications': notifications,
|
||||||
|
'unread': unread,
|
||||||
}
|
}
|
||||||
notifications.update(read=True)
|
notifications.update(read=True)
|
||||||
return TemplateResponse(request, 'notifications.html', data)
|
return TemplateResponse(request, 'notifications.html', data)
|
||||||
|
|
Loading…
Reference in a new issue