mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 21:53:30 +00:00
Add basic page view permission, not really working
This commit is contained in:
parent
5b8b3746e6
commit
d72b18c120
18
core/migrations/0006_auto_20151125_0855.py
Normal file
18
core/migrations/0006_auto_20151125_0855.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- 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
|
||||
|
Loading…
Reference in New Issue
Block a user