Commit d72b18c1 authored by Skia's avatar Skia

Add basic page view permission, not really working

parent 5b8b3746
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0005_auto_20151124_1219'),
]
operations = [
migrations.AlterModelOptions(
name='page',
options={'permissions': (('can_view', 'Can view the page'),)},
),
]
...@@ -149,7 +149,7 @@ class Page(models.Model): ...@@ -149,7 +149,7 @@ class Page(models.Model):
unique_together = ('name', 'parent') unique_together = ('name', 'parent')
permissions = ( permissions = (
#("can_edit", "Can edit the page"), #("can_edit", "Can edit the page"),
#("can_view", "Can view the page"), ("can_view", "Can view the page"),
) )
@staticmethod @staticmethod
......
...@@ -12,11 +12,17 @@ def page(request, page_name=None): ...@@ -12,11 +12,17 @@ def page(request, page_name=None):
if page_name == None: if page_name == None:
context['page_list'] = Page.objects.all context['page_list'] = Page.objects.all
return render(request, "core/page.html", context) return render(request, "core/page.html", context)
context['page'] = Page.get_page_by_full_name(page_name) p = Page.get_page_by_full_name(page_name)
if context['page'] is not None: if p is not None:
context['view_page'] = True context['view_page'] = True
context['title'] = context['page'].title if request.user.has_perm('can_view', p):
context['tests'] = "PAGE_FOUND : "+context['page'].title context['title'] = p.title
context['page'] = p
context['tests'] = "PAGE_FOUND : "+p.title
else:
context['title'] = "Access denied"
context['tests'] = "PAGE_FOUND_BUT_DENIED"
context['page'] = Page(title="Denied", content="You have no access to this page")
else: else:
context['title'] = "This page does not exist" context['title'] = "This page does not exist"
context['new_page'] = page_name context['new_page'] = page_name
......
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