Add event-specific groups and signals

This commit is contained in:
Ludovic Stephan 2017-07-21 15:48:40 +02:00
parent 3439abe922
commit 0093956696
4 changed files with 52 additions and 1 deletions

19
event/signals.py Normal file
View file

@ -0,0 +1,19 @@
from django.dispatch import receiver
from django.db.models.signals import post_save
from event.models import Event
from shared.models import GEGroup
@receiver(post_save, sender=Event)
def create_groups_for_event(sender, **kwargs):
event, created = kwargs["instance"], kwargs["created"]
if created:
GEGroup.objects.create(
name="orga",
event=event
)
GEGroup.objects.create(
name="participants",
event=event,
)

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-20 13:37
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0008_alter_user_username_max_length'),
]
operations = [
migrations.CreateModel(
name='GEGroup',
fields=[
('group_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auth.Group')),
],
bases=('auth.group',),
),
]

View file

View file

@ -1,2 +1,9 @@
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
User = get_user_model()
class GEGroup(Group):
pass