Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
cdcf4099
Commit
cdcf4099
authored
Nov 24, 2015
by
Skia
Browse files
Prevent loop in Wiki
parent
18115a0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/fixtures/groups.json
0 → 100644
View file @
cdcf4099
[{
"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
]}}]
\ No newline at end of file
core/models.py
View file @
cdcf4099
...
...
@@ -174,6 +174,21 @@ class Page(models.Model):
code
=
'duplicate'
,
)
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
):
self
.
full_clean
()
...
...
core/views/site.py
View file @
cdcf4099
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.http
import
HttpResponse
from
django.contrib.auth
import
logout
as
auth_logout
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
...
...
core/views/user.py
View file @
cdcf4099
# This file contains all the views that concern the user model
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
from
core.views.forms
import
RegisteringForm
,
LoginForm
from
core.views.forms
import
RegisteringForm
,
LoginForm
,
UserEditForm
from
core.models
import
User
def
register
(
request
):
context
=
{
'title'
:
'Register a user'
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment