Skip to content

Commit

Permalink
Add "Show Deck" API Endpoint
Browse files Browse the repository at this point in the history
Fixes #36
  • Loading branch information
sheepman4267 committed Nov 20, 2024
1 parent ea13975 commit a20ac36
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion OpenShow/slides/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ninja import Router, Schema
from .models import Slide, Show, Display
from .models import Slide, Show, Display, Deck
from django.shortcuts import get_object_or_404

router = Router()
Expand All @@ -15,6 +15,11 @@ class SlideAdvanceSchema(Schema):
direction: str


class ShowDeckSchema(Schema):
display_pk: int
deck_pk: int


@router.post("show_slide")
def show_slide(request, slide_and_show: SlideAndShowSchema):
slide = get_object_or_404(Slide, pk=slide_and_show.slide_pk)
Expand All @@ -23,6 +28,15 @@ def show_slide(request, slide_and_show: SlideAndShowSchema):
return {"message": "OK"}


@router.post("show_deck")
def show_deck(request, data: ShowDeckSchema):
display = get_object_or_404(Display, pk=data.display_pk)
deck = get_object_or_404(Deck, pk=data.deck_pk)
initial_slide = deck.slides.first()
initial_slide.send_to_display([display, ])
return {"message": "OK"}


@router.post("next_slide")
def next_slide(request, slide_advance: SlideAdvanceSchema):
display = get_object_or_404(Display, pk=slide_advance.display_pk)
Expand Down

0 comments on commit a20ac36

Please sign in to comment.