Add MetaGroup system

This commit is contained in:
Skia
2016-03-29 12:45:10 +02:00
parent 5bcc94f992
commit debba55350
16 changed files with 137 additions and 158 deletions

View File

@ -2,37 +2,41 @@
from __future__ import unicode_literals
from django.db import migrations, models
import django.core.validators
from django.conf import settings
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Club',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)),
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)),
('name', models.CharField(max_length=30, verbose_name='name')),
('unix_name', models.CharField(unique=True, error_messages={'unique': 'A club with that unix name already exists.'}, validators=[django.core.validators.RegexValidator('^[a-z0-9][a-z0-9._-]*[a-z0-9]$', 'Enter a valid unix name. This value may contain only letters, numbers ./-/_ characters.')], verbose_name='unix name', max_length=30)),
('unix_name', models.CharField(unique=True, max_length=30, verbose_name='unix name', error_messages={'unique': 'A club with that unix name already exists.'}, validators=[django.core.validators.RegexValidator('^[a-z0-9][a-z0-9._-]*[a-z0-9]$', 'Enter a valid unix name. This value may contain only letters, numbers ./-/_ characters.')])),
('address', models.CharField(max_length=254, verbose_name='address')),
('parent', models.ForeignKey(related_name='children', blank=True, to='club.Club', null=True)),
('edit_groups', models.ManyToManyField(to='core.Group', blank=True, related_name='editable_club')),
('owner_group', models.ForeignKey(default=1, related_name='owned_club', to='core.Group')),
('parent', models.ForeignKey(blank=True, related_name='children', to='club.Club', null=True)),
('view_groups', models.ManyToManyField(to='core.Group', blank=True, related_name='viewable_club')),
],
),
migrations.CreateModel(
name='Membership',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)),
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)),
('start_date', models.DateField(auto_now=True, verbose_name='start date')),
('end_date', models.DateField(null=True, verbose_name='end date', blank=True)),
('role', models.IntegerField(verbose_name='role', choices=[(0, 'Membre'), (1, 'Membre actif'), (2, 'Membre du bureau'), (3, 'Responsable info'), (4, 'Secrétaire'), (5, 'Responsable com'), (7, 'Trésorier'), (8, 'Vice-Président'), (9, 'Vice-Président'), (10, 'Président')], default=0)),
('description', models.CharField(max_length=30, verbose_name='description', blank=True)),
('club', models.ForeignKey(related_name='members', to='club.Club')),
('user', models.ForeignKey(related_name='membership', to=settings.AUTH_USER_MODEL)),
('end_date', models.DateField(blank=True, null=True, verbose_name='end date')),
('role', models.IntegerField(choices=[(0, 'Curieux'), (1, 'Membre actif'), (2, 'Membre du bureau'), (3, 'Responsable info'), (4, 'Secrétaire'), (5, 'Responsable com'), (7, 'Trésorier'), (9, 'Vice-Président'), (10, 'Président')], verbose_name='role', default=0)),
('description', models.CharField(max_length=30, blank=True, verbose_name='description')),
('club', models.ForeignKey(to='club.Club', related_name='members')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='membership')),
],
),
]

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
('club', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='club',
name='edit_groups',
field=models.ManyToManyField(to='core.Group', blank=True, related_name='editable_club'),
),
migrations.AddField(
model_name='club',
name='view_groups',
field=models.ManyToManyField(to='core.Group', blank=True, related_name='viewable_club'),
),
]

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
('club', '0002_auto_20160202_1345'),
]
operations = [
migrations.AddField(
model_name='club',
name='owner_group',
field=models.ForeignKey(default=1, to='core.Group', related_name='owned_club'),
),
]

View File

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('club', '0003_club_owner_group'),
]
operations = [
migrations.AlterField(
model_name='membership',
name='role',
field=models.IntegerField(choices=[(0, 'Curieux'), (1, 'Membre actif'), (2, 'Membre du bureau'), (3, 'Responsable info'), (4, 'Secrétaire'), (5, 'Responsable com'), (7, 'Trésorier'), (9, 'Vice-Président'), (10, 'Président')], default=0, verbose_name='role'),
),
]

View File

@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from core.models import User, Group
from core.models import User, MetaGroup, Group
from subscription.models import Subscriber
# Create your models here.
@ -48,6 +48,11 @@ class Club(models.Model):
def clean(self):
self.check_loop()
def save(self):
super(Club, self).save()
MetaGroup(name=self.unix_name+"-board").save()
MetaGroup(name=self.unix_name+"-members").save()
def __str__(self):
return self.name