Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
0b962e23
Commit
0b962e23
authored
Nov 27, 2015
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the group management more generic in the model
parent
5c9e5a24
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
6 deletions
+87
-6
core/migrations/0010_auto_20151127_1503.py
core/migrations/0010_auto_20151127_1503.py
+26
-0
core/migrations/0011_auto_20151127_1504.py
core/migrations/0011_auto_20151127_1504.py
+29
-0
core/migrations/0012_auto_20151127_1504.py
core/migrations/0012_auto_20151127_1504.py
+24
-0
core/models.py
core/models.py
+8
-6
No files found.
core/migrations/0010_auto_20151127_1503.py
0 → 100644
View file @
0b962e23
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0009_auto_20151127_1007'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'page'
,
name
=
'edit_group'
,
),
migrations
.
RemoveField
(
model_name
=
'page'
,
name
=
'owner_group'
,
),
migrations
.
RemoveField
(
model_name
=
'page'
,
name
=
'view_group'
,
),
]
core/migrations/0011_auto_20151127_1504.py
0 → 100644
View file @
0b962e23
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0010_auto_20151127_1503'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'page'
,
name
=
'edit_group'
,
field
=
models
.
ManyToManyField
(
to
=
'core.Group'
,
related_name
=
'editable_object'
,
null
=
True
),
),
migrations
.
AddField
(
model_name
=
'page'
,
name
=
'owner_group'
,
field
=
models
.
ForeignKey
(
related_name
=
'owned_object'
,
default
=
1
,
to
=
'core.Group'
),
),
migrations
.
AddField
(
model_name
=
'page'
,
name
=
'view_group'
,
field
=
models
.
ManyToManyField
(
to
=
'core.Group'
,
related_name
=
'viewable_object'
,
null
=
True
),
),
]
core/migrations/0012_auto_20151127_1504.py
0 → 100644
View file @
0b962e23
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0011_auto_20151127_1504'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'page'
,
name
=
'edit_group'
,
field
=
models
.
ManyToManyField
(
related_name
=
'editable_object'
,
to
=
'core.Group'
),
),
migrations
.
AlterField
(
model_name
=
'page'
,
name
=
'view_group'
,
field
=
models
.
ManyToManyField
(
related_name
=
'viewable_object'
,
to
=
'core.Group'
),
),
]
core/models.py
View file @
0b962e23
...
...
@@ -132,7 +132,14 @@ class Group(AuthGroup):
"""
return
reverse
(
'core:group_edit'
,
kwargs
=
{
'group_id'
:
self
.
pk
})
class
Page
(
models
.
Model
):
class
GroupManagedObject
(
models
.
Model
):
owner_group
=
models
.
ForeignKey
(
Group
,
related_name
=
"owned_object"
,
default
=
1
)
edit_group
=
models
.
ManyToManyField
(
Group
,
related_name
=
"editable_object"
)
view_group
=
models
.
ManyToManyField
(
Group
,
related_name
=
"viewable_object"
)
class
Meta
:
abstract
=
True
class
Page
(
GroupManagedObject
,
models
.
Model
):
"""
The page class to build a Wiki
Each page may have a parent and it's URL is of the form my.site/page/<grd_pa>/<parent>/<mypage>
...
...
@@ -154,11 +161,6 @@ class Page(models.Model):
# playing with a Page object, use get_full_name() instead!
full_name
=
models
.
CharField
(
_
(
'page name'
),
max_length
=
255
,
blank
=
True
)
# TODO: Rightable abstract class from which every object with right needed will be able to be child of
# Put thoses 3 attributes there
owner_group
=
models
.
ForeignKey
(
Group
,
related_name
=
"owned_pages"
,
default
=
1
)
edit_group
=
models
.
ManyToManyField
(
Group
,
related_name
=
"editable_pages"
,
default
=
1
)
view_group
=
models
.
ManyToManyField
(
Group
,
related_name
=
"viewable_pages"
,
default
=
1
)
class
Meta
:
unique_together
=
(
'name'
,
'parent'
)
...
...
Write
Preview
Markdown
is supported
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