Skip to content

Commit

Permalink
[#156] Add View Rotas for Admin/Orch Manager
Browse files Browse the repository at this point in the history
Add sidebar Links logic dependant on Group Office/Rota Manager
	modified:   templates/base.html

Update logic in Rota View to receive a section argument as **kwargs
	modified:   string_rota/views.py

Update path for toggle published/draft
Add url for Rota_admin
	modified:   string_rota/urls.py

Add testing for 'Add View Rotas for Admin/Orch Manager' to README
- NB. basic functionality works, but CRUD links do not work in this
    commit. The resolution of the CRUD server errors is the same as for
    Rota class view ie pass in the Section as **kwargs and isolate
    calls to request.user - player and section
	modified:   README.md
	new file:   readme_assets/images/testing-issue156-3.png
  • Loading branch information
mikerae committed Oct 8, 2023
1 parent b8701fc commit 679aafc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ The following manual tests were made:
- [see issue #156 here](https://github.com/mikerae/string-rota/issues/156)
- [Show sections in sidebar #156 Testing](/readme_assets/images/testing-issue156-2.png)
- [see issue #156 here](https://github.com/mikerae/string-rota/issues/156)
- [Admin/Orch Manager View Rotas #156 Testing](/readme_assets/images/testing-issue156-3.png)
- [see issue #156 here](https://github.com/mikerae/string-rota/issues/156)
#### Human Testing
No human testing was done for this MVP, but once office manager functionality, and the hiding of draft rotas is implemented, user feedback will be sort.

Expand Down
Binary file added readme_assets/images/testing-issue156-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion string_rota/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
""" Urls for string-rota app """
from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = [
path("", views.Home.as_view(), name="home"),
path("<slug:slug>/", views.Rota.as_view(), name="rota"),
path(
"<slug:slug>/<section_id>/", views.Rota.as_view(), name="rota_office"
), # noqa E501
path(
"add_sp/<slug:slug>/<seating_plan_id>/",
views.AddSeatingPosition.as_view(),
Expand All @@ -26,7 +30,7 @@
name="delete_sp",
),
path(
"<slug:slug>/<seating_plan_id>/",
"toggle/<slug:slug>/<seating_plan_id>/",
views.ToggleSeatingPlanStatus.as_view(),
name="toggle_seating_plan_status",
),
Expand Down
25 changes: 16 additions & 9 deletions string_rota/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,23 @@ class Rota(View):
def dispatch(self, *args, **kwargs):
return super(Rota, self).dispatch(*args, **kwargs)

def get(self, request, slug):
def get(self, request, slug, **kwargs):
"""Creates rota view for selected project"""

try:
player = get_object_or_404(Player, users_django=request.user.id)
except player.DoesNotExist:
messages.warning(request, "You are not logged in as a player.")
return redirect(reverse("home"))
projects = Project.objects.all()
office = request.user.groups.filter(name="Office")
sections = Section.objects.all()
project = get_project(slug)
section = get_section(player)
if office:
section = get_object_or_404(Section, pk=kwargs["section_id"])
else:
try:
player = get_object_or_404(
Player, users_django=request.user.id
) # noqa E501
except player.DoesNotExist:
messages.warning(request, "You are not logged in as a player.")
return redirect(reverse("home"))
section = get_section(player)
projects = Project.objects.all()

# no seating_plan record?
try:
Expand Down Expand Up @@ -157,6 +163,7 @@ def get(self, request, slug):

context = {
"projects": projects,
"sections": sections,
"project": project,
"seating_plan": seating_plan,
"seating_positions": seating_positions,
Expand Down
4 changes: 2 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h6>{{user.first_name}} {{user.last_name}}</h6>
<ul id="section-nav" class="nav-content collapse" data-bs-parent="#sections-nav">
<li>
{% for section in sections %}
<a id="section" href="">
<a id="section" href="{% url 'rota_office' project.slug section.id %}">
<i class="bi bi-circle"></i><span>{{section.name}}</span>
</a>
{% endfor %}
Expand Down Expand Up @@ -174,7 +174,7 @@ <h6>{{user.first_name}} {{user.last_name}}</h6>
{% endif %}
{% if request.user.is_superuser %}
<li class="nav-item">
<a class="nav-link collapsed" href="../admin/">
<a class="nav-link collapsed" href="/admin">
<i class="bi bi-menu-button-wide"></i><span>Admin</span>
</a>
</li>
Expand Down

0 comments on commit 679aafc

Please sign in to comment.