Source code for superdjango.contrib.support.views

# Imports

from superdjango.conf import SUPERDJANGO
from superdjango.contrib.support.library import Content
from superdjango.views import AccessMixin, BreadcrumbsMixin, FormView, GenericView, JSONMixin, TemplateView, ViewSet

content = Content(SUPERDJANGO.SUPPORT_PATH)
content.load()

# Mixins


[docs]class LoginMayBeRequiredMixin(AccessMixin): """An authenticated user may or may not be required.""" login_required = SUPERDJANGO.SUPPORT_REQUIRES_LOGIN
# Views
[docs]class AjaxHelpComment(LoginMayBeRequiredMixin, JSONMixin, GenericView): """Submit a help comment via AJAX.""" pattern_name = "support_ajax_help_comment" pattern_value = "ajax/help/comment/"
[docs]class AjaxHelpRanking(LoginMayBeRequiredMixin, JSONMixin, GenericView): """Submit a help ranking via AJAX.""" pattern_name = "ajax_help_ranking" pattern_value = "ajax/help/ranking/"
[docs]class AjaxLoadHelp(LoginMayBeRequiredMixin, JSONMixin, GenericView): """Load help content for an area of the project.""" pattern_name = "support_ajax_load_help" pattern_value = "ajax/load/help/"
[docs]class AjaxSearchHelp(LoginMayBeRequiredMixin, JSONMixin, GenericView): """Searches for help content using the search catalog.""" pattern_name = "support_ajax_search_help" pattern_value = "ajax/search/help/"
[docs]class SupportArticle(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView): """Responsible for loading specific help content, other than home page content.""" pattern_name = "support_article" pattern_value = "articles/<slug>/" template_name = "support/support_article.html"
[docs] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['areas'] = content.areas article = content.fetch(self.kwargs['slug']) context['article'] = article context['support'] = content.info return context
[docs]class SupportFAQs(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView): """Responsible for loading FAQs.""" pattern_name = "support_faqs" pattern_value = "faqs/" template_name = "support/support_faqs.html"
[docs]class SupportHome(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView): """The home page for support info.""" pattern_name = "support_home" pattern_value = "" template_name = "support/support_home.html"
[docs] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['areas'] = content.areas context['help_url'] = "/help/" context['support'] = content.info return context
[docs]class SupportPage(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView): """Responsible for loading generic, other than home page content.""" pattern_name = "support_page" pattern_value = "page/" template_name = "support/support_page.html"
[docs] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['areas'] = content.areas context['help_url'] = "/help/" context['support'] = content.info return context
[docs]class SupportSearch(LoginMayBeRequiredMixin, BreadcrumbsMixin, FormView): """The search and search results page.""" pattern_name = "support_search" pattern_value = "search/" template_name = "support/support_search.html"
[docs]class SupportTerms(LoginMayBeRequiredMixin, BreadcrumbsMixin, TemplateView): """Responsible for loading terms and definitions.""" pattern_name = "support_terms" pattern_value = "terms/" template_name = "support/support_terms.html"
# View Sets
[docs]class SupportViewSet(ViewSet): """Collects all of the support views together.""" views = [ AjaxHelpComment, AjaxHelpRanking, AjaxLoadHelp, AjaxSearchHelp, SupportArticle, SupportFAQs, SupportHome, SupportPage, SupportSearch, SupportTerms, ]