Hide keyboard shortcuts

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 

2 

3from superdjango.conf import SUPERDJANGO 

4from superdjango.contrib.support.library import Content 

5from superdjango.views import AccessMixin, BreadcrumbsMixin, FormView, GenericView, JSONMixin, TemplateView, ViewSet 

6 

7content = Content(SUPERDJANGO.SUPPORT_PATH) 

8content.load() 

9 

10# Mixins 

11 

12 

13class LoginMayBeRequiredMixin(AccessMixin): 

14 """An authenticated user may or may not be required.""" 

15 login_required = SUPERDJANGO.SUPPORT_REQUIRES_LOGIN 

16 

17# Views 

18 

19 

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/" 

24 

25 

26class AjaxHelpRanking(LoginMayBeRequiredMixin, JSONMixin, GenericView): 

27 """Submit a help ranking via AJAX.""" 

28 pattern_name = "ajax_help_ranking" 

29 pattern_value = "ajax/help/ranking/" 

30 

31 

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/" 

36 

37 

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/" 

42 

43 

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" 

49 

50 def get_context_data(self, **kwargs): 

51 context = super().get_context_data(**kwargs) 

52 

53 context['areas'] = content.areas 

54 

55 article = content.fetch(self.kwargs['slug']) 

56 context['article'] = article 

57 

58 context['support'] = content.info 

59 

60 return context 

61 

62 

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" 

68 

69 

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" 

75 

76 def get_context_data(self, **kwargs): 

77 context = super().get_context_data(**kwargs) 

78 

79 context['areas'] = content.areas 

80 context['help_url'] = "/help/" 

81 context['support'] = content.info 

82 

83 return context 

84 

85 

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" 

91 

92 def get_context_data(self, **kwargs): 

93 context = super().get_context_data(**kwargs) 

94 

95 context['areas'] = content.areas 

96 context['help_url'] = "/help/" 

97 context['support'] = content.info 

98 

99 return context 

100 

101 

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" 

107 

108 

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" 

114 

115 

116# View Sets 

117 

118 

119class SupportViewSet(ViewSet): 

120 """Collects all of the support views together.""" 

121 

122 views = [ 

123 AjaxHelpComment, 

124 AjaxHelpRanking, 

125 AjaxLoadHelp, 

126 AjaxSearchHelp, 

127 SupportArticle, 

128 SupportFAQs, 

129 SupportHome, 

130 SupportPage, 

131 SupportSearch, 

132 SupportTerms, 

133 ]