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):
unique_together = ('name', 'parent')
permissions = (
#("can_edit", "Can edit the page"),
#("can_view", "Can view the page"),
("can_view", "Can view the page"),
)
@staticmethod
......
......@@ -12,11 +12,17 @@ def page(request, page_name=None):
if page_name == None:
context['page_list'] = Page.objects.all
return render(request, "core/page.html", context)
context['page'] = Page.get_page_by_full_name(page_name)
if context['page'] is not None:
p = Page.get_page_by_full_name(page_name)
if p is not None:
context['view_page'] = True
context['title'] = context['page'].title
context['tests'] = "PAGE_FOUND : "+context['page'].title
if request.user.has_perm('can_view', p):
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:
context['title'] = "This page does not exist"
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