mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Make the group management more generic in the model
This commit is contained in:
parent
5c9e5a24ab
commit
0b962e2380
26
core/migrations/0010_auto_20151127_1503.py
Normal file
26
core/migrations/0010_auto_20151127_1503.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- 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',
|
||||||
|
),
|
||||||
|
]
|
29
core/migrations/0011_auto_20151127_1504.py
Normal file
29
core/migrations/0011_auto_20151127_1504.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# -*- 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),
|
||||||
|
),
|
||||||
|
]
|
24
core/migrations/0012_auto_20151127_1504.py
Normal file
24
core/migrations/0012_auto_20151127_1504.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# -*- 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'),
|
||||||
|
),
|
||||||
|
]
|
@ -132,7 +132,14 @@ class Group(AuthGroup):
|
|||||||
"""
|
"""
|
||||||
return reverse('core:group_edit', kwargs={'group_id': self.pk})
|
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
|
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>
|
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!
|
# playing with a Page object, use get_full_name() instead!
|
||||||
full_name = models.CharField(_('page name'), max_length=255, blank=True)
|
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:
|
class Meta:
|
||||||
unique_together = ('name', 'parent')
|
unique_together = ('name', 'parent')
|
||||||
|
Loading…
Reference in New Issue
Block a user