Skip to content

Commit 40624be

Browse files
committed
add session switcher to nav for admin users
1 parent 8de8429 commit 40624be

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

crowdsourcer/templates/crowdsourcer/base.html

+14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
<div class="collapse navbar-collapse" id="navbarSupportedContent">
2424
<ul class="navbar-nav ms-sm-auto pt-2 pt-sm-0">
2525
{% if user.is_superuser %}
26+
<li class="nav-item">
27+
<div class="dropdown">
28+
<button class="btn dropdown-toggle" id="navbarDropdown" data-bs-toggle="dropdown" aria-expanded="false">
29+
{{ marking_session.label }}
30+
</button>
31+
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
32+
{% for session in sessions %}
33+
<li>
34+
<a class="dropdown-item d-flex" href="/{{ session.label }}/">{{ session.label }}</a>
35+
</li>
36+
{% endfor %}
37+
</ul>
38+
</div>
39+
</li>
2640
<li class="nav-item">
2741
<div class="dropdown">
2842
<button class="btn dropdown-toggle" id="navbarDropdown" data-bs-toggle="dropdown" aria-expanded="false">

crowdsourcer/views/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from crowdsourcer.mixins import CurrentMarkingSessionMixin, CurrentStageMixin
1010
from crowdsourcer.models import (
1111
Assigned,
12+
MarkingSession,
1213
PublicAuthority,
1314
Question,
1415
Response,
@@ -93,6 +94,7 @@ def post(self, *args, **kwargs):
9394

9495
def get_context_data(self, **kwargs):
9596
context = super().get_context_data(**kwargs)
97+
context["sessions"] = MarkingSession.objects.filter(active=True)
9698
context["form"] = self.get_form()
9799
context["section_title"] = self.kwargs.get("section_title", "")
98100
context["authority"] = PublicAuthority.objects.get(
@@ -155,6 +157,7 @@ def get_queryset(self):
155157

156158
def get_context_data(self, **kwargs):
157159
context = super().get_context_data(**kwargs)
160+
context["sessions"] = MarkingSession.objects.filter(active=True)
158161
context["section_title"] = self.kwargs["section_title"]
159162
context["page_title"] = context["section_title"]
160163
context["question_page"] = self.question_page
@@ -225,6 +228,7 @@ def get_context_data(self, **kwargs):
225228
for section in assigned:
226229
progress[section.title]["assigned"] = section.num_authorities
227230

231+
context["sessions"] = MarkingSession.objects.filter(active=True)
228232
context["page_title"] = "Section Progress"
229233
context["progress"] = progress
230234
context["url_pattern"] = self.url_pattern
@@ -290,6 +294,7 @@ def get_context_data(self, **kwargs):
290294
):
291295
complete = complete + 1
292296

297+
context["sessions"] = MarkingSession.objects.filter(active=True)
293298
context["page_title"] = f"{section.title} Section Progress"
294299
context["section"] = section
295300
context["totals"] = {"total": total, "complete": complete}
@@ -343,6 +348,7 @@ def get_context_data(self, **kwargs):
343348
F("num_sections").asc(nulls_first=True), "name"
344349
)
345350

351+
context["sessions"] = MarkingSession.objects.filter(active=True)
346352
context["authorities"] = authorities
347353
context["do_not_mark_only"] = do_not_mark_only
348354

crowdsourcer/views/marking.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from crowdsourcer.mixins import CurrentMarkingSessionMixin, CurrentStageMixin
1212
from crowdsourcer.models import (
1313
Assigned,
14+
MarkingSession,
1415
Option,
1516
PublicAuthority,
1617
Question,
@@ -184,6 +185,7 @@ def get_context_data(self, **kwargs):
184185
}
185186
)
186187

188+
context["sessions"] = MarkingSession.objects.filter(active=True)
187189
context["progress"] = progress
188190

189191
context["page_title"] = "Assignments"

crowdsourcer/views/progress.py

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from crowdsourcer.models import (
1313
Assigned,
1414
Marker,
15+
MarkingSession,
1516
PublicAuthority,
1617
Question,
1718
Response,
@@ -122,6 +123,7 @@ def get_context_data(self, **kwargs):
122123
if a.num_questions == a.num_responses:
123124
council_totals["complete"] = council_totals["complete"] + 1
124125

126+
context["sessions"] = MarkingSession.objects.filter(active=True)
125127
context["councils"] = council_totals
126128
context["authorities"] = authorities
127129
context["page_title"] = self.page_title
@@ -198,6 +200,7 @@ def get_context_data(self, **kwargs):
198200
"total": authority.num_questions,
199201
}
200202

203+
context["sessions"] = MarkingSession.objects.filter(active=True)
201204
context["sections"] = progress
202205
context["authority_name"] = name
203206
context["page_title"] = f"{name} Progress"
@@ -312,6 +315,7 @@ def get_context_data(self, **kwargs):
312315
elif self.current_stage.type == "Audit":
313316
authority_url_name = "authority_audit"
314317

318+
context["sessions"] = MarkingSession.objects.filter(active=True)
315319
context["user"] = user
316320
context["sections"] = progress
317321
context["page_title"] = "Volunteer Progress"

0 commit comments

Comments
 (0)