Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from superdjango.conf import SUPERDJANGO
4from superdjango.contrib.support.library import Content
5from superdjango.views import AccessMixin, BreadcrumbsMixin, FormView, GenericView, JSONMixin, TemplateView, ViewSet
7content = Content(SUPERDJANGO.SUPPORT_PATH)
8content.load()
10# Mixins
13class LoginMayBeRequiredMixin(AccessMixin):
14 """An authenticated user may or may not be required."""
15 login_required = SUPERDJANGO.SUPPORT_REQUIRES_LOGIN
17# Views
20class AjaxHelpComment(LoginMayBeRequiredMixin, JSONMixin, GenericView):
21 """Submit a help comment via AJAX."""
22 pattern_name = "support_ajax_help_comment"
23 pattern_value = "ajax/help/comment/"
26class AjaxHelpRanking(LoginMayBeRequiredMixin, JSONMixin, GenericView):
27 """Submit a help ranking via AJAX."""
28 pattern_name = "ajax_help_ranking"
29 pattern_value = "ajax/help/ranking/"
32class AjaxLoadHelp(LoginMayBeRequiredMixin, JSONMixin, GenericView):
33 """Load help content for an area of the project."""
34 pattern_name = "support_ajax_load_help"
35 pattern_value = "ajax/load/help/"
38class AjaxSearchHelp(LoginMayBeRequiredMixin, JSONMixin, GenericView):
39 """Searches for help content using the search catalog."""
40 pattern_name = "support_ajax_search_help"
41 pattern_value = "ajax/search/help/"
44class SupportArticle(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView):
45 """Responsible for loading specific help content, other than home page content."""
46 pattern_name = "support_article"
47 pattern_value = "articles/<slug>/"
48 template_name = "support/support_article.html"
50 def get_context_data(self, **kwargs):
51 context = super().get_context_data(**kwargs)
53 context['areas'] = content.areas
55 article = content.fetch(self.kwargs['slug'])
56 context['article'] = article
58 context['support'] = content.info
60 return context
63class SupportFAQs(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView):
64 """Responsible for loading FAQs."""
65 pattern_name = "support_faqs"
66 pattern_value = "faqs/"
67 template_name = "support/support_faqs.html"
70class SupportHome(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView):
71 """The home page for support info."""
72 pattern_name = "support_home"
73 pattern_value = ""
74 template_name = "support/support_home.html"
76 def get_context_data(self, **kwargs):
77 context = super().get_context_data(**kwargs)
79 context['areas'] = content.areas
80 context['help_url'] = "/help/"
81 context['support'] = content.info
83 return context
86class SupportPage(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView):
87 """Responsible for loading generic, other than home page content."""
88 pattern_name = "support_page"
89 pattern_value = "page/"
90 template_name = "support/support_page.html"
92 def get_context_data(self, **kwargs):
93 context = super().get_context_data(**kwargs)
95 context['areas'] = content.areas
96 context['help_url'] = "/help/"
97 context['support'] = content.info
99 return context
102class SupportSearch(LoginMayBeRequiredMixin, BreadcrumbsMixin, FormView):
103 """The search and search results page."""
104 pattern_name = "support_search"
105 pattern_value = "search/"
106 template_name = "support/support_search.html"
109class SupportTerms(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView):
110 """Responsible for loading terms and definitions."""
111 pattern_name = "support_terms"
112 pattern_value = "terms/"
113 template_name = "support/support_terms.html"
116# View Sets
119class SupportViewSet(ViewSet):
120 """Collects all of the support views together."""
122 views = [
123 AjaxHelpComment,
124 AjaxHelpRanking,
125 AjaxLoadHelp,
126 AjaxSearchHelp,
127 SupportArticle,
128 SupportFAQs,
129 SupportHome,
130 SupportPage,
131 SupportSearch,
132 SupportTerms,
133 ]