Add initial navbar

This includes all boards, as well as report counts if the user is an
admin.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-19 19:45:36 -07:00
parent 2fd9b17b37
commit 60441aa5d9
6 changed files with 60 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
from django.conf import settings as django_settings
from board.models import Board
from board.models import Board, ReportRecord
def settings(request):
@@ -8,3 +8,24 @@ def settings(request):
def boards(request):
return {"boards": Board.objects.filter(readonly=False)}
def reports(request):
user = request.user
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
print("reports!")
if user and user.has_perm("board.view_reportrecord"):
return {
"reports": ReportRecord.objects.all(),
"reports_urgent": ReportRecord.objects.filter(urgent=True),
}
else:
return {}

View File

@@ -0,0 +1,8 @@
/* Nav */
.nav_admin {
float: right;
}
.nav_report_urgent {
color: var(--error);
}

View File

@@ -6,6 +6,7 @@
--activated: #888;
--post-background: #d9d9d9;
--reply-background: #eee;
--error: #f00;
}
body {
@@ -169,6 +170,11 @@ th {
font-size: smaller;
}
/* Nav */
nav {
font-size: small;
}
/* Misc */
a:link {

View File

@@ -19,6 +19,7 @@
{% block extrajs %}{% endblock %}
</head>
<body>
<nav>{% include "board/nav_snippet.html" %}</nav>
<main>
{% block content %}{% endblock content %}
</main>

View File

@@ -0,0 +1,22 @@
<div class="nav">
<span class="nav_boards">
[
{% for board in boards %}
<span class="nav_board">
<a href="{% url 'board:board_detail' board.url %}">{{board.url}}</a>
{% if not forloop.last %} / {% endif %}
</span>
{% endfor %}
]
</span>
{% if user and user.is_staff %}
<span class="nav_admin">
[
<a href="{% url 'admin:board_reportrecord_changelist' %}">Reports</a>:
{{reports.count}}
(<span class="nav_report_urgent">{{reports_urgent.count}}</span>)
]
</span>
{% endif %}
</div>