Add notifications for unvetted observations in user dropdown
parent
2ca5cba080
commit
74039b5b2d
|
@ -1,6 +1,8 @@
|
|||
from django.conf import settings
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from network.base.models import (Station, Observation)
|
||||
|
||||
|
||||
def analytics(request):
|
||||
"""Returns analytics code."""
|
||||
|
@ -16,3 +18,11 @@ def stage_notice(request):
|
|||
return {'stage_notice': render_to_string('includes/stage_notice.html')}
|
||||
else:
|
||||
return {'stage_notice': ''}
|
||||
|
||||
|
||||
def user_processor(request):
|
||||
owner_stations = Station.objects.filter(owner=request.user)
|
||||
owner_vetting_count = Observation.objects.filter(author=request.user,
|
||||
vetted_status='unknown').count()
|
||||
return {'owner_stations': owner_stations,
|
||||
'owner_vetting_count': owner_vetting_count}
|
||||
|
|
|
@ -114,6 +114,7 @@ TEMPLATES = [
|
|||
'django.template.context_processors.request',
|
||||
'network.base.context_processors.analytics',
|
||||
'network.base.context_processors.stage_notice',
|
||||
'network.base.context_processors.user_processor',
|
||||
],
|
||||
'loaders': [
|
||||
('django.template.loaders.cached.Loader', [
|
||||
|
|
|
@ -293,6 +293,15 @@ span.datetime-time {
|
|||
background-color: #5bc0de;
|
||||
}
|
||||
|
||||
.badge-unvetted {
|
||||
background-color: #ff8c00;
|
||||
}
|
||||
|
||||
.owner_stations {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
|
||||
/* Stations
|
||||
==================== */
|
||||
|
||||
|
|
|
@ -54,11 +54,56 @@
|
|||
<li class="dropdown">
|
||||
<a href="#"
|
||||
class="dropdown-toggle"
|
||||
data-toggle="dropdown">{% avatar request.user 35 %} {{ request.user.username }}
|
||||
<span class="caret"></span>
|
||||
data-toggle="dropdown">
|
||||
{% avatar request.user 35 %}
|
||||
{{ request.user.username }}
|
||||
{% if owner_vetting_count %}
|
||||
<span class="badge badge-unvetted">{{ owner_vetting_count }}</span>
|
||||
{% endif %}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="{% url 'users:view_user' username=request.user.username %}">My Profile</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
{% if owner_stations %}
|
||||
{% for station in owner_stations %}
|
||||
<li>
|
||||
<a href="{% url 'base:station_view' id=station.id %}">
|
||||
<span class="label
|
||||
{% if station.online %}
|
||||
label-success
|
||||
{% else %}
|
||||
label-danger
|
||||
{% endif %}
|
||||
owner_stations"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="{% if station.last_seen %}
|
||||
Seen {{ station.last_seen|timesince }} ago
|
||||
{% else %}
|
||||
Never seen
|
||||
{% endif %}">
|
||||
{{ station.id }}
|
||||
</span>
|
||||
{{ station.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li role="separator" class="divider"></li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="{% url 'base:observations_list' %}?observer={{ request.user.id }}">
|
||||
My Observations
|
||||
</a>
|
||||
</li>
|
||||
{% if owner_vetting_count %}
|
||||
<li>
|
||||
<a href="{% url 'base:observations_list' %}?observer={{ request.user.id }}&future=0&good=0&bad=0&unvetted=1">
|
||||
<span class="badge badge-unvetted">{{ owner_vetting_count }}</span> Unvetted
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li role="separator" class="divider"></li>
|
||||
{% if request.user.is_superuser %}
|
||||
<li><a href="{% url 'base:settings_site' %}">Site Settings</a></li>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue