Coverage for /Users/davegaeddert/Development/dropseed/plain/plain-staff/plain/staff/views/default.py: 80%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-16 22:04 -0500

1from plain.http import ResponseRedirect 

2 

3from .base import StaffView 

4from .registry import registry 

5 

6 

7# This will be dashboard view... 

8class StaffIndexView(StaffView): 

9 template_name = "staff/index.html" 

10 title = "Dashboards" 

11 slug = "" 

12 

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()) 

18 

19 return super().get() 

20 

21 def get_template_context(self): 

22 context = super().get_template_context() 

23 context["dashboards"] = registry.registered_dashboards 

24 return context 

25 

26 

27class StaffSearchView(StaffView): 

28 template_name = "staff/search.html" 

29 title = "Search" 

30 slug = "search" 

31 

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