Add notification
This commit is contained in:
parent
ab59065c0b
commit
de704fc250
17 changed files with 279 additions and 56 deletions
|
@ -204,48 +204,64 @@
|
|||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<span id="user-links">
|
||||
<div style="float: right; display: inline;">
|
||||
{% if request.user.is_authenticated %}
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ url('user_page') }}">
|
||||
<span>
|
||||
<img src="{{ gravatar(request.user, 32) }}" height="24" width="24">{# -#}
|
||||
<span>
|
||||
{%- trans username=request.user.username -%}
|
||||
Hello, <b>{{ username }}</b>.
|
||||
{%- endtrans %}
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
<ul style="width: 150px">
|
||||
{% if request.user.is_staff or request.user.is_superuser %}
|
||||
<li><a href="{{ url('admin:index') }}">{{ _('Admin') }}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{{ url('user_edit_profile') }}">{{ _('Edit profile') }}</a></li>
|
||||
{% if request.user.is_impersonate %}
|
||||
<li><a href="{{ url('impersonate-stop') }}">Stop impersonating</a></li>
|
||||
{% else %}
|
||||
<li>
|
||||
<form action="{{ url('auth_logout') }}" method="POST">
|
||||
{% csrf_token %}
|
||||
<button type="submit">{{ _('Log out') }}</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<span class="anon">
|
||||
<a href="{{ url('auth_login') }}?next={{ LOGIN_RETURN_PATH|urlencode }}"><b>{{ _('Log in') }}</b></a>
|
||||
{{ _('or') }}
|
||||
<a href="{{ url('registration_register') }}"><b>{{ _('Sign up') }}</b></a>
|
||||
{% set unseen_cnt = request.profile.count_unseen_notifications %}
|
||||
<span class="{{ 'notification-open' if unseen_cnt > 0 }}">
|
||||
<a href="{{ url('notification') }}" class="fa fa-bell" id="notification" aria-hidden="true">
|
||||
{% if unseen_cnt > 0 %}
|
||||
<span>
|
||||
{{ unseen_cnt }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span id="user-links">
|
||||
{% if request.user.is_authenticated %}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ url('user_page') }}">
|
||||
<span>
|
||||
<img src="{{ gravatar(request.user, 32) }}" height="24" width="24">{# -#}
|
||||
<span>
|
||||
{%- trans username=request.user.username -%}
|
||||
Hello, <b>{{ username }}</b>.
|
||||
{%- endtrans %}
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
<ul style="width: 150px">
|
||||
{% if request.user.is_staff or request.user.is_superuser %}
|
||||
<li><a href="{{ url('admin:index') }}">{{ _('Admin') }}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{{ url('user_edit_profile') }}">{{ _('Edit profile') }}</a></li>
|
||||
{% if request.user.is_impersonate %}
|
||||
<li><a href="{{ url('impersonate-stop') }}">Stop impersonating</a></li>
|
||||
{% else %}
|
||||
<li>
|
||||
<form action="{{ url('auth_logout') }}" method="POST">
|
||||
{% csrf_token %}
|
||||
<button type="submit">{{ _('Log out') }}</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<span class="anon">
|
||||
<a href="{{ url('auth_login') }}?next={{ LOGIN_RETURN_PATH|urlencode }}"><b>{{ _('Log in') }}</b></a>
|
||||
{{ _('or') }}
|
||||
<a href="{{ url('registration_register') }}"><b>{{ _('Sign up') }}</b></a>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="nav-shadow"></div>
|
||||
</nav>
|
||||
{% if request.in_contest %}
|
||||
|
|
|
@ -37,11 +37,20 @@
|
|||
return '&#'+i.charCodeAt(0)+';';
|
||||
});
|
||||
}
|
||||
const datesAreOnSameDay = (first, second) =>
|
||||
first.getFullYear() === second.getFullYear() &&
|
||||
first.getMonth() === second.getMonth() &&
|
||||
first.getDate() === second.getDate();
|
||||
|
||||
function loadMessage(content, user, time, messid, image, css_class, isNew) {
|
||||
// if (isNew) content = encodeHTML(content)
|
||||
time = new Date(time);
|
||||
time = moment(time).format("HH:mm DD-MM-YYYY");
|
||||
if (datesAreOnSameDay(time, new Date())) {
|
||||
time = moment(time).format("HH:mm");
|
||||
}
|
||||
else {
|
||||
time = moment(time).format("HH:mm DD-MM-YYYY");
|
||||
}
|
||||
content = encodeHTML(content);
|
||||
li = `<li class="message">
|
||||
<img src="${image}" class="profile-pic">
|
||||
|
|
39
templates/notification/list.html
Normal file
39
templates/notification/list.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
{% if not has_notifications %}
|
||||
|
||||
<h2 style="text-align: center;">{{ _('You have no notifications') }}</h2>
|
||||
|
||||
{% else %}
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>{{ _('User') }}</th>
|
||||
<th>{{ _('Activity') }}</th>
|
||||
<th>{{ _('Comment') }}</th>
|
||||
<th>{{ _('Time') }}</th>
|
||||
</tr>
|
||||
{% for notification in notifications %}
|
||||
<tr class="{{ 'highlight' if not notification.seen }}">
|
||||
<td>
|
||||
{{ link_user(notification.comment.author) }}
|
||||
</td>
|
||||
<td>
|
||||
{{ notification.category }}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ notification.comment.link }}#comment-{{ notification.comment.id }}">{{ page_titles[notification.comment.page] }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ relative_time(notification.time) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
<!--
|
||||
-->
|
|
@ -7,13 +7,13 @@
|
|||
<input id="search" type="text" name="search" value="{{ search_query or '' }}"
|
||||
placeholder="{{ _('Search problems...') }}">
|
||||
</div>
|
||||
{% if has_fts %}
|
||||
<!-- {% if has_fts %}
|
||||
<div>
|
||||
<input id="full_text" type="checkbox" name="full_text" value="1"
|
||||
{% if full_text %}checked{% endif %}>
|
||||
<label for="full_text">{{ _('Full text search') }}</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %} -->
|
||||
{% if request.user.is_authenticated %}
|
||||
<div>
|
||||
<input id="hide_solved" type="checkbox" name="hide_solved" value="1"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue