From b6bbb7b05a9be19c1587b0364d56cf7a78e74776 Mon Sep 17 00:00:00 2001 From: Gustavo Andres Morero Date: Thu, 8 Jun 2017 15:29:23 -0300 Subject: [PATCH] adding check for organization and redirect. --- wiki/decorators.py | 2 ++ wiki/templates/wiki/no_organization.html | 7 +++++++ wiki/urls.py | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 wiki/templates/wiki/no_organization.html diff --git a/wiki/decorators.py b/wiki/decorators.py index 0286b91a..561f7648 100644 --- a/wiki/decorators.py +++ b/wiki/decorators.py @@ -86,6 +86,8 @@ def get_article(func=None, can_read=True, can_write=False, # noqa article_id = kwargs.pop('article_id', None) org = request.organization + if org is None: + return redirect('wiki:no_organization') urlpath = None # fetch by urlpath.path diff --git a/wiki/templates/wiki/no_organization.html b/wiki/templates/wiki/no_organization.html new file mode 100644 index 00000000..6be83e03 --- /dev/null +++ b/wiki/templates/wiki/no_organization.html @@ -0,0 +1,7 @@ +{% extends "wiki/base.html" %} + +{% block wiki_pagetitle %}No organization found{% endblock %} + +{% block wiki_contents %} +No organization have been found. +{% endblock %} diff --git a/wiki/urls.py b/wiki/urls.py index ebbe3e0a..af92ba8c 100644 --- a/wiki/urls.py +++ b/wiki/urls.py @@ -2,6 +2,8 @@ from __future__ import absolute_import, unicode_literals from django.conf.urls import include, url +from django.views.generic import TemplateView + from wiki.conf import settings from wiki.core.plugins import registry from wiki.core.plugins.loader import load_wiki_plugins @@ -77,6 +79,10 @@ class WikiURLPatterns(object): url(r'^_revision/diff/(?P\d+)/$', self.article_diff_view, name='diff'), + url(r'^no-organization/$', + TemplateView.as_view( + template_name='wiki/no_organization.html'), + name='no_organization'), ] return urlpatterns -- 2.45.2