Commit 0b962e23 authored by Skia's avatar Skia

Make the group management more generic in the model

parent 5c9e5a24
# -*- 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',
),
]
# -*- 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),
),
]
# -*- 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})
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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment