@@ -109,6 +109,11 @@ class MatchesPolicyParams(
109109): ...
110110
111111
112+ class SettingsQueryParams (BaseModel ):
113+ include_feeds : bool = True
114+ kiosk_mode : bool = False
115+
116+
112117def get_squoredevqueryparams (
113118 squoredev : Annotated [SquoreDevQueryParams , Query ()],
114119) -> SquoreDevQueryParams :
@@ -166,6 +171,23 @@ def get_nummatchesparams(
166171 return NumMatchesParams .make_from_parameter_superset (policyparams )
167172
168173
174+ def get_settingsqueryparams (
175+ request : Request , params : Annotated [SettingsQueryParams , Query ()]
176+ ) -> SettingsQueryParams :
177+ try :
178+ from_config = cast (
179+ SettingsQueryParams , request .app .state .squore ["settingsqueryparams" ]
180+ )
181+ from_query = params .model_dump (exclude_defaults = True )
182+ return from_config .model_copy (update = from_query )
183+
184+ except (AttributeError , KeyError ) as err :
185+ raise HTTPException (
186+ status_code = HTTP_500_INTERNAL_SERVER_ERROR ,
187+ detail = "App state does not include squore.settingsqueryparams" ,
188+ ) from err
189+
190+
169191def get_matchfeedqueryparams (
170192 request : Request , params : Annotated [MatchFeedQueryParams , Query ()]
171193) -> MatchFeedQueryParams :
@@ -646,19 +668,22 @@ async def feeds(
646668 return court_feeds
647669
648670
649- class SettingsQueryParams (BaseModel ):
650- include_feeds : bool = True
651-
652-
653671@squoreapp .get ("/init" )
654672async def init (
655673 myurl : Annotated [URL , Depends (get_url )],
656674 matchfeedqueryparams : Annotated [
657675 MatchFeedQueryParams , Depends (get_matchfeedqueryparams )
658676 ],
677+ settingsqueryparams : Annotated [
678+ SettingsQueryParams , Depends (get_settingsqueryparams )
679+ ],
659680 squoredev : Annotated [SquoreDevQueryParams , Depends (get_squoredevqueryparams )],
660681) -> RedirectResponse :
661- params = matchfeedqueryparams .model_dump () | squoredev .model_dump ()
682+ params = (
683+ matchfeedqueryparams .model_dump ()
684+ | squoredev .model_dump ()
685+ | settingsqueryparams .model_dump ()
686+ )
662687 redirect_url = (
663688 myurl / ".." / "settings" % normalise_dict_values_for_query_string (params )
664689 )
@@ -716,6 +741,7 @@ async def settings(
716741 courtorder [courtfeed .CourtID ] = idx , courtfeed .Name
717742
718743 settings ["feedPostUrls" ] = ("\n " .join (feeds )).strip ()
744+ settings ["kioskMode" ] = params .kiosk_mode
719745
720746 if court_for_dev is not None :
721747 try :
@@ -762,6 +788,7 @@ def deprecated_feeds(request: Request) -> RedirectResponse:
762788@asynccontextmanager
763789async def setup_for_squore (
764790 clictx : CliContext ,
791+ kiosk_mode : bool = False ,
765792 only_this_court : bool = False ,
766793 max_matches_per_court : int | None = None ,
767794 api_mount_point : str = API_MOUNTPOINT ,
@@ -786,6 +813,7 @@ async def setup_for_squore(
786813 only_this_court = only_this_court ,
787814 max_matches_per_court = max_matches_per_court ,
788815 ),
816+ "settingsqueryparams" : SettingsQueryParams (kiosk_mode = kiosk_mode ),
789817 }
790818 squoreapp .mount (
791819 "/flags" ,
@@ -809,6 +837,12 @@ async def callback(tournament: Tournament) -> None:
809837
810838
811839@plugin
840+ @click .option (
841+ "--kiosk-mode" ,
842+ "-k" ,
843+ is_flag = True ,
844+ help = "Configure clients to use kiosk-mode and restrict the UI" ,
845+ )
812846@click .option (
813847 "--only-this-court" ,
814848 "-o" ,
@@ -856,6 +890,7 @@ async def callback(tournament: Tournament) -> None:
856890@pass_clictx
857891async def squoresrv (
858892 clictx : CliContext ,
893+ kiosk_mode : bool ,
859894 only_this_court : bool ,
860895 max_matches_per_court : int | None ,
861896 api_mount_point : str ,
@@ -867,6 +902,7 @@ async def squoresrv(
867902
868903 async with setup_for_squore (
869904 clictx ,
905+ kiosk_mode ,
870906 only_this_court ,
871907 max_matches_per_court ,
872908 api_mount_point ,
0 commit comments