Skip to content

Commit

Permalink
[#170] Admin Toggle Draft/Pubished rotas
Browse files Browse the repository at this point in the history
Update message in ToggleSeatingPlanStatus Class
Add accepts section.id as kwargs in ToggleSeatingPlanStatus Class
Add conditional return logic in ToggleSeatingPlanStatus Class
Derive section form kwargs in ToggleSeatingPlanStatus Class
	modified:   string_rota/views.py

Add conditional routing for Draft/Published Button
	modified:   string_rota/templates/string_rota/rota.html

Add toggle_seating_plan_status_office path
	modified:   string_rota/urls.py

Add testing of Admin Toggle Draft/Pubished rotas to README
	modified:   README.md
	new file:   readme_assets/images/testing-issue170-3.png
  • Loading branch information
mikerae committed Oct 8, 2023
1 parent 98d182f commit 4781bab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ The following manual tests were made:
- [see issue #170 here](https://github.com/mikerae/string-rota/issues/170)
- [Admin Seating Position CRUD #170 Testing](/readme_assets/images/testing-issue170-2.png)
- [see issue #170 here](https://github.com/mikerae/string-rota/issues/170)
- [Admin Toggle Draft/Published Rotas #170 Testing](/readme_assets/images/testing-issue170-3.png)
- [see issue #170 here](https://github.com/mikerae/string-rota/issues/170)
#### 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-issue170-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion string_rota/templates/string_rota/rota.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h5 class="text-info">Please contact your Rota Manager</h5>
<span><a href="{% url 'add_sp_office' project.slug seating_plan.id section.id %}"><button
class="btn btn-primary">Add
Player to Seating Plan</button></a></span>
<a href="{% url 'toggle_seating_plan_status' project.slug seating_plan.id %}"><button
<a href="{% url 'toggle_seating_plan_status_office' project.slug seating_plan.id section.id %}"><button
class="btn btn-success">Draft/Published</button></a>
<a href="{% url 'reserve' project.slug %}"><button class="btn btn-primary">Allocate
Reserved
Expand Down
5 changes: 5 additions & 0 deletions string_rota/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@
views.ToggleSeatingPlanStatus.as_view(),
name="toggle_seating_plan_status",
),
path(
"toggle/<slug:slug>/<seating_plan_id>/<section_id>/",
views.ToggleSeatingPlanStatus.as_view(),
name="toggle_seating_plan_status_office",
),
]
30 changes: 23 additions & 7 deletions string_rota/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,18 @@ def get(self, request, slug, position_id, **kwargs):
class ToggleSeatingPlanStatus(Rota):
"""Toggle the status of a seating plan from draft to published"""

def get(self, request, slug, seating_plan_id):
print("ToggleSeatingPlanStatus called")
def get(self, request, slug, seating_plan_id, **kwargs):
"""Toggle the status of a seating plan from draft to published"""
office = request.user.groups.filter(name="Office")
sections = Section.objects.all()
project = get_project(slug)
if office:
section = get_object_or_404(Section, pk=kwargs["section_id"])
else:
player = get_player(request)
section = get_section(player)

project = get_project(slug)
player = get_player(request)
section = get_section(player)
seating_plan = get_seating_plan(project, section)

status = seating_plan.plan_status
Expand All @@ -567,9 +573,19 @@ def get(self, request, slug, seating_plan_id):
else:
seating_plan.plan_status = "D"
seating_plan.save()
messages.success(
messages.error(
request,
f"The {section} section Rota for {project} is set to Draft and is not viewable by players or office", # noqa E501
f"The {section} section Rota for {project} is set to DRAFT and is not viewable by players or office.", # noqa E501
) # noqa E501

messages.warning(
request,
"The Admin superuser can view and edit draft rotas", # noqa E501
)
if office:
return HttpResponseRedirect(
reverse(
"rota_office",
args=[slug, section.id],
), # noqa E501
)
return HttpResponseRedirect(reverse("rota", args=[slug]))

0 comments on commit 4781bab

Please sign in to comment.