Adds notifications

Fixes #70
This commit is contained in:
Mouse Reeve
2020-03-07 14:50:29 -08:00
parent 95c8dc1d67
commit f4008eb8c8
13 changed files with 176 additions and 5 deletions

View File

@ -1,3 +1,4 @@
{% load fr_display %}
<!DOCTYPE html>
<html lang="en">
<head>
@ -47,6 +48,13 @@
<input type="submit" value="🔍"></input>
</form>
</div>
{% if request.user.is_authenticated %}
<div id="notification">
<a href="/notifications">
🔔 ({{ request.user | notification_count }})
</a>
</div>
{% endif %}
</div>
</div>
</header>

View File

@ -0,0 +1,37 @@
{% extends 'layout.html' %}
{% load humanize %}l
{% block content %}
<div id="content">
<div>
<h2>Notifications</h2>
<form name="clear" action="/clear-notifications" method="POST">
{% csrf_token %}
<button type="submit">Delete notifications</button>
</form>
{% for notification in notifications %}
<div>
<p>
{% if notification.notification_type == 'FAVORITE' %}
{% include 'snippets/username.html' with user=notification.related_user %}
favorited your
<a href="{{ notification.related_status.absolute_id}}">status</a>
{% elif notification.notification_type == 'REPLY' %}
{% include 'snippets/username.html' with user=notification.related_user %}
<a href="{{ notification.related_status.absolute_id}}">replied</a>
to your
<a href="{{ notification.related_status.reply_parent.absolute_id}}">status</a>
{% elif notification.notification_type == 'FOLLOW' %}
{% include 'snippets/username.html' with user=notification.related_user %}
followed you
{% endif %}
<small>{{ notification.created_date | naturaltime }}</small>
</p>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
<div>
<div>
{% include 'snippets/avatar.html' with user=user %}
{% include 'snippets/username.html' with user=user %}
<small>{{ user.username }}</small>
</div>
{% if not is_self %}
{% include 'snippets/follow_button.html' with user=user %}
{% endif %}
</div>