def article(request, category, slug): """ Handles and renders individual articles. """ utils.check_notifications(request) user_id = None if request.user.is_authenticated(): user_id = str(request.user.user_id)[:8] article = get_object_or_404(Article, slug=slug) article_category = None for cat in CATEGORIES: if cat.url == category: article_category = cat if article_category == None: raise Http404() return render(request, "docs/article.html", { "title": (config.TITLE_FORMAT % article.title), "user_id": user_id, "article": article, "category": article_category, })
def category(request, category): """ Handles """ utils.check_notifications(request) article_category = None for cat in CATEGORIES: if cat.url == category: article_category = cat if article_category == None: raise Http404() user_id = None if request.user.is_authenticated(): user_id = str(request.user.user_id)[:8] return render(request, "docs/category.html", { "title": (config.TITLE_FORMAT % article_category.title), "user_id": user_id, "category": article_category, })
def renderMessenger(request, data={}): """ Renders the messenger page. :param request: Django request object. :param data: Additional data to pass to the template. """ utils.check_notifications(request) # TODO Only get channels from the last week(?) channels = Channel.objects.filter( Q(users__in=[request.user]), ).order_by("-last_message")[:30] # Default values template_args = { "title": (config.TITLE_FORMAT % "Messages"), "user_id": str(request.user.user_id)[:8], "channels": channels, "channel_url": None, "channel_title": "No Channel Selected.", "channel_messages": None, "is_group": False, "pjax_req": None if not "_pjax" in request.GET else request.GET.get("_pjax") } template_args.update(data) return render(request, "messenger/index.html", template_args)
def index(request): """ """ utils.check_notifications(request) user_id = None if request.user.is_authenticated(): user_id = str(request.user.user_id)[:8] return render(request, "docs/index.html", { "title": (config.TITLE_FORMAT % "Documentation"), "user_id": user_id, })
def render_editor(request, data={}): """ Function for creating an editor. :param request: Django request object. :param data: Additional data to pass to the template. """ utils.check_notifications(request) # Default values template_args = { "title": (config.TITLE_FORMAT % "Create"), "user_id": str(request.user.user_id)[:8], } template_args.update(data) return render(request, "docs/editor.html", template_args)
def render_page(request, location=None, data={}): """ Renders a page based on the information given. :param request: Django request object. :param location: String location of the pages template. :param data: Additional data to pass to the template. """ utils.check_notifications(request) user_id = None if request.user.is_authenticated(): user_id = str(request.user.user_id)[:8] template_args = { "user_id": user_id, } template_args.update(data) return render(request, location, template_args)