Coverage for /Users/davegaeddert/Developer/dropseed/plain/plain-staff/plain/staff/views/default.py: 80%
25 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-23 11:16 -0600
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-23 11:16 -0600
1from plain.http import ResponseRedirect
3from .base import StaffView
4from .registry import registry
7# This will be dashboard view...
8class StaffIndexView(StaffView):
9 template_name = "staff/index.html"
10 title = "Dashboards"
11 slug = ""
13 def get(self):
14 # If there's exactly one dashboard, redirect straight to it
15 dashboards = registry.registered_dashboards
16 if len(dashboards) == 1:
17 return ResponseRedirect(list(dashboards)[0].get_absolute_url())
19 return super().get()
21 def get_template_context(self):
22 context = super().get_template_context()
23 context["dashboards"] = registry.registered_dashboards
24 return context
27class StaffSearchView(StaffView):
28 template_name = "staff/search.html"
29 title = "Search"
30 slug = "search"
32 def get_template_context(self):
33 context = super().get_template_context()
34 context["searchable_views"] = registry.get_searchable_views()
35 context["global_search_query"] = self.request.GET.get("query", "")
36 return context