diff --git a/club/migrations/0011_auto_20180426_2013.py b/club/migrations/0011_auto_20180426_2013.py new file mode 100644 index 00000000..2c4cfa5e --- /dev/null +++ b/club/migrations/0011_auto_20180426_2013.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import club.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('club', '0010_auto_20170912_2028'), + ] + + operations = [ + migrations.AlterField( + model_name='club', + name='owner_group', + field=models.ForeignKey(default=club.models.Club.get_default_owner_group, related_name='owned_club', to='core.Group'), + ), + ] diff --git a/club/models.py b/club/models.py index 383db7f8..575c06ad 100644 --- a/club/models.py +++ b/club/models.py @@ -62,9 +62,9 @@ class Club(models.Model): is_active = models.BooleanField(_('is active'), default=True) short_description = models.CharField(_('short description'), max_length=1000, default='', blank=True, null=True) address = models.CharField(_('address'), max_length=254) - # email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically - owner_group = models.ForeignKey(Group, related_name="owned_club", - default=settings.SITH_GROUP_ROOT_ID) + # This function prevents generating migration upon settings change + def get_default_owner_group(): return settings.SITH_GROUP_ROOT_ID + owner_group = models.ForeignKey(Group, related_name="owned_club", default=get_default_owner_group) edit_groups = models.ManyToManyField(Group, related_name="editable_club", blank=True) view_groups = models.ManyToManyField(Group, related_name="viewable_club", blank=True) home = models.OneToOneField(SithFile, related_name='home_of_club', verbose_name=_("home"), null=True, blank=True, diff --git a/core/migrations/0029_auto_20180426_2013.py b/core/migrations/0029_auto_20180426_2013.py new file mode 100644 index 00000000..fd783652 --- /dev/null +++ b/core/migrations/0029_auto_20180426_2013.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import core.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0028_auto_20171216_2044'), + ] + + operations = [ + migrations.AlterField( + model_name='page', + name='owner_group', + field=models.ForeignKey(verbose_name='owner group', default=core.models.Page.get_default_owner_group, related_name='owned_page', to='core.Group'), + ), + ] diff --git a/core/models.py b/core/models.py index 60df78f0..b94ae1ed 100644 --- a/core/models.py +++ b/core/models.py @@ -920,8 +920,10 @@ class Page(models.Model): # Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when # playing with a Page object, use get_full_name() instead! _full_name = models.CharField(_('page name'), max_length=255, blank=True) + # This function prevents generating migration upon settings change + def get_default_owner_group(): return settings.SITH_GROUP_ROOT_ID owner_group = models.ForeignKey(Group, related_name="owned_page", verbose_name=_("owner group"), - default=settings.SITH_GROUP_ROOT_ID) + default=get_default_owner_group) edit_groups = models.ManyToManyField(Group, related_name="editable_page", verbose_name=_("edit group"), blank=True) view_groups = models.ManyToManyField(Group, related_name="viewable_page", verbose_name=_("view group"), blank=True) lock_user = models.ForeignKey(User, related_name="locked_pages", verbose_name=_("lock user"), blank=True, null=True, default=None) diff --git a/forum/migrations/0006_auto_20180426_2013.py b/forum/migrations/0006_auto_20180426_2013.py new file mode 100644 index 00000000..92c53d9f --- /dev/null +++ b/forum/migrations/0006_auto_20180426_2013.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import forum.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('forum', '0005_forumtopic_subscribed_users'), + ] + + operations = [ + migrations.AlterField( + model_name='forum', + name='edit_groups', + field=models.ManyToManyField(blank=True, default=forum.models.Forum.get_default_edit_group, related_name='editable_forums', to='core.Group'), + ), + migrations.AlterField( + model_name='forum', + name='view_groups', + field=models.ManyToManyField(blank=True, default=forum.models.Forum.get_default_view_group, related_name='viewable_forums', to='core.Group'), + ), + ] diff --git a/forum/models.py b/forum/models.py index 8a79e6b6..7f04779c 100644 --- a/forum/models.py +++ b/forum/models.py @@ -38,6 +38,7 @@ from core.models import User, Group from club.models import Club + class Forum(models.Model): """ The Forum class, made as a tree to allow nice tidy organization @@ -46,6 +47,9 @@ class Forum(models.Model): edit_groups allows to put any group as a forum admin view_groups allows some groups to view a forum """ + # Those functions prevent generating migration upon settings changes + def get_default_edit_group(): return [settings.SITH_GROUP_OLD_SUBSCRIBERS_ID] + def get_default_view_group(): return [settings.SITH_GROUP_PUBLIC_ID] id = models.AutoField(primary_key=True, db_index=True) name = models.CharField(_('name'), max_length=64) description = models.CharField(_('description'), max_length=512, default="") @@ -54,9 +58,9 @@ class Forum(models.Model): owner_club = models.ForeignKey(Club, related_name="owned_forums", verbose_name=_("owner club"), default=settings.SITH_MAIN_CLUB_ID) edit_groups = models.ManyToManyField(Group, related_name="editable_forums", blank=True, - default=[settings.SITH_GROUP_OLD_SUBSCRIBERS_ID]) + default=get_default_edit_group) view_groups = models.ManyToManyField(Group, related_name="viewable_forums", blank=True, - default=[settings.SITH_GROUP_PUBLIC_ID]) + default=get_default_view_group) number = models.IntegerField(_("number to choose a specific forum ordering"), default=1) _last_message = models.ForeignKey('ForumMessage', related_name="forums_where_its_last", verbose_name=_("the last message"), null=True, on_delete=models.SET_NULL)