mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Prevent loop in Wiki
This commit is contained in:
parent
18115a0dc4
commit
cdcf4099fc
1
core/fixtures/groups.json
Normal file
1
core/fixtures/groups.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"pk": 1, "model": "auth.group", "fields": {"name": "root", "permissions": [1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12, 19, 20, 21, 16, 17, 18, 13, 14, 15]}}]
|
@ -174,6 +174,21 @@ class Page(models.Model):
|
|||||||
code='duplicate',
|
code='duplicate',
|
||||||
)
|
)
|
||||||
super(Page, self).clean()
|
super(Page, self).clean()
|
||||||
|
if self.parent is not None and self in self.get_parent_list():
|
||||||
|
raise ValidationError(
|
||||||
|
_('Loop in page tree'),
|
||||||
|
code='loop',
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_parent_list(self):
|
||||||
|
l = []
|
||||||
|
p = self.parent
|
||||||
|
while p is not None:
|
||||||
|
l.append(p)
|
||||||
|
p = p.parent
|
||||||
|
return l
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.full_clean()
|
self.full_clean()
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.contrib.auth import logout as auth_logout
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.forms import PasswordChangeForm
|
|
||||||
|
|
||||||
from core.models import User, Page
|
|
||||||
from core.views.forms import RegisteringForm, LoginForm, UserEditForm, PageEditForm, PagePropForm
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
# This file contains all the views that concern the user model
|
# This file contains all the views that concern the user model
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from django.contrib.auth import logout as auth_logout
|
||||||
|
from django.contrib.auth.forms import PasswordChangeForm
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from core.views.forms import RegisteringForm, LoginForm
|
from core.views.forms import RegisteringForm, LoginForm, UserEditForm
|
||||||
|
from core.models import User
|
||||||
|
|
||||||
def register(request):
|
def register(request):
|
||||||
context = {'title': 'Register a user'}
|
context = {'title': 'Register a user'}
|
||||||
|
Loading…
Reference in New Issue
Block a user