Commit f9227fa2 authored by Sli's avatar Sli

Merge branch 'bugfix' into 'master'

Fix error 500 when accessing user tools with anonymous user and fix dependancies

See merge request !220
parents a2b431b1 96a3eaff
Pipeline #1923 passed with stage
in 24 minutes and 46 seconds
......@@ -5,7 +5,7 @@ test:
stage: test
script:
- apt-get update
- apt-get install -y gettext python3-xapian
- apt-get install -y gettext python3-xapian libgraphviz-dev
- pushd /usr/lib/python3/dist-packages/xapian && ln -s _xapian* _xapian.so && popd
- export PYTHONPATH="/usr/lib/python3/dist-packages:$PYTHONPATH"
- python -c 'import xapian' # Fail immediately if there is a problem with xapian
......
......@@ -396,6 +396,21 @@ http://git.an
)
class UserToolsTest(TestCase):
def setUp(self):
call_command("populate")
def test_anonymous_user_unauthorized(self):
response = self.client.get(reverse("core:user_tools"))
self.assertEquals(response.status_code, 403)
def test_page_is_working(self):
self.client.login(username="guy", password="plop")
response = self.client.get(reverse("core:user_tools"))
self.assertNotEquals(response.status_code, 500)
self.assertEquals(response.status_code, 200)
# TODO: many tests on the pages:
# - renaming a page
# - changing a page's parent --> check that page's children's full_name
......
......@@ -214,6 +214,17 @@ class FormerSubscriberMixin(View):
return super(FormerSubscriberMixin, self).dispatch(request, *args, **kwargs)
class UserIsLoggedMixin(View):
"""
This view check if the user is logged
"""
def dispatch(self, request, *args, **kwargs):
if request.user.is_anonymous:
raise PermissionDenied
return super(UserIsLoggedMixin, self).dispatch(request, *args, **kwargs)
class TabedViewMixin(View):
"""
This view provide the basic functions for displaying tabs in the template
......
......@@ -52,6 +52,7 @@ from core.views import (
CanViewMixin,
CanEditMixin,
CanEditPropMixin,
UserIsLoggedMixin,
TabedViewMixin,
QuickNotifMixin,
)
......@@ -762,7 +763,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
current_tab = "groups"
class UserToolsView(QuickNotifMixin, UserTabsMixin, TemplateView):
class UserToolsView(QuickNotifMixin, UserTabsMixin, UserIsLoggedMixin, TemplateView):
"""
Displays the logged user's tools
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment