Skip to content

Commit

Permalink
Add redirect view to redirect to current status screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars van Rhijn authored and KiOui committed Jun 3, 2024
1 parent 566d3ac commit abda1ec
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 0 additions & 2 deletions website/borrel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from borrel import views
from venues.converters import VenueConverter

register_converter(VenueConverter, "venue")


urlpatterns = [
path("reservations/", views.ListReservationsView.as_view(), name="list_reservations"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h2>Ready</h2>
clearTimeout(this.refreshTimer);
this.refreshing = true;
return fetch(
`/api/v1/shifts/{{ shift.id }}/orders/?type=0&picked_up=false&ordering=ready_at`,
"{% url 'v1:orders_listcreate' shift=shift %}?type=0&picked_up=false&ordering=ready_at",
{
method: 'GET',
headers: {
Expand Down
1 change: 1 addition & 0 deletions website/status_screen/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
from status_screen import views

urlpatterns = [
path("redirect/<order_venue:venue>/", views.VenueRedirectView.as_view(), name="venue-redirect"),
path("<shift:shift>/", views.StatusScreen.as_view(), name="status"),
]
20 changes: 19 additions & 1 deletion website/status_screen/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from django.shortcuts import render
from django.http import Http404
from django.shortcuts import render, redirect
from django.urls import reverse
from django.views import View
from django.views.generic import TemplateView

from orders.templatetags.start_shift import currently_active_shift_for_venue


class StatusScreen(TemplateView):
"""Status screen for a Shift."""
Expand All @@ -11,3 +16,16 @@ def get(self, request, **kwargs):
"""GET request for status screen view."""
shift = kwargs.get("shift")
return render(request, self.template_name, {"shift": shift})


class VenueRedirectView(View):
"""Redirect to the current shift of a venue."""

def get(self, request, **kwargs):
"""Redirect a user to the active status screen of a shift."""
venue = kwargs.get("venue")
shift = currently_active_shift_for_venue(venue)
if shift is None:
raise Http404()
else:
return redirect(reverse("status_screen:status", kwargs={"shift": shift}))
6 changes: 3 additions & 3 deletions website/thaliedje/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def __init__(self, *args, **kwargs):
"{} (currently offline)".format(instance.playback_device_name),
)
)
self.fields["playback_device_id"].help_text = (
"The currently selected device appears to be offline."
)
self.fields[
"playback_device_id"
].help_text = "The currently selected device appears to be offline."
if len(choices) == 0 and instance.playback_device_id == "":
self.fields["playback_device_id"].help_text = "No online Spotify clients were found."
choices = [("", "----------")] + choices
Expand Down

0 comments on commit abda1ec

Please sign in to comment.