Merge branch 'master' of git.eleves.ens.fr:cof-geek/GestionEvenementiel into Aufinal/permissions
This commit is contained in:
commit
6ece994f1c
5 changed files with 46 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.3 on 2017-07-18 17:05
|
# Generated by Django 1.11.3 on 2017-07-21 14:20
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -12,9 +12,9 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
('contenttypes', '0002_remove_content_type_name'),
|
||||||
('auth', '0008_alter_user_username_max_length'),
|
('auth', '0008_alter_user_username_max_length'),
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
('contenttypes', '0002_remove_content_type_name'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.3 on 2017-07-18 17:05
|
# Generated by Django 1.11.3 on 2017-07-21 14:20
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -24,8 +24,8 @@ class Migration(migrations.Migration):
|
||||||
('description', models.TextField(verbose_name='description')),
|
('description', models.TextField(verbose_name='description')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'matériels permanents',
|
'verbose_name': 'matériel',
|
||||||
'verbose_name': 'matériel permanent',
|
'verbose_name_plural': 'matériels',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -38,8 +38,8 @@ class Migration(migrations.Migration):
|
||||||
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='equipment.Equipment')),
|
('equipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='equipment.Equipment')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'attributions de matériel',
|
|
||||||
'verbose_name': 'attribution de matériel',
|
'verbose_name': 'attribution de matériel',
|
||||||
|
'verbose_name_plural': 'attributions de matériel',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -53,8 +53,8 @@ class Migration(migrations.Migration):
|
||||||
('equipment', models.ForeignKey(help_text='Matériel concerné par la remarque', on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='equipment.Equipment')),
|
('equipment', models.ForeignKey(help_text='Matériel concerné par la remarque', on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='equipment.Equipment')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'remarques sur le matériel',
|
|
||||||
'verbose_name': 'remarque sur matériel',
|
'verbose_name': 'remarque sur matériel',
|
||||||
|
'verbose_name_plural': 'remarques sur le matériel',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
|
@ -65,6 +65,6 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='equipment',
|
model_name='equipment',
|
||||||
name='event',
|
name='event',
|
||||||
field=models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèleest spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement'),
|
field=models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèle est spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from event.models import Activity
|
from event.models import Activity, EventSpecificMixin
|
||||||
from shared.models import EventSpecificMixin
|
|
||||||
|
|
||||||
|
|
||||||
class Equipment(EventSpecificMixin, models.Model):
|
class Equipment(EventSpecificMixin, models.Model):
|
||||||
|
@ -18,8 +18,8 @@ class Equipment(EventSpecificMixin, models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("matériel permanent")
|
verbose_name = _("matériel")
|
||||||
verbose_name_plural = _("matériels permanents")
|
verbose_name_plural = _("matériels")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -40,6 +40,12 @@ class EquipmentAttribution(models.Model):
|
||||||
self.amout,
|
self.amout,
|
||||||
self.activity.get_herited('title'))
|
self.activity.get_herited('title'))
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.equipment.event and self.equipment.event != self.activity.event:
|
||||||
|
raise ValidationError
|
||||||
|
|
||||||
|
super(EquipmentAttribution, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class EquipmentRemark(models.Model):
|
class EquipmentRemark(models.Model):
|
||||||
remark = models.TextField(_("remarque sur le matériel"))
|
remark = models.TextField(_("remarque sur le matériel"))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.3 on 2017-07-18 17:05
|
# Generated by Django 1.11.3 on 2017-07-21 14:20
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -32,8 +32,8 @@ class Migration(migrations.Migration):
|
||||||
('end', models.DateTimeField(verbose_name='heure de fin')),
|
('end', models.DateTimeField(verbose_name='heure de fin')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'activités',
|
|
||||||
'verbose_name': 'activité',
|
'verbose_name': 'activité',
|
||||||
|
'verbose_name_plural': 'activités',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -45,8 +45,8 @@ class Migration(migrations.Migration):
|
||||||
('color', models.CharField(help_text='Rentrer une couleur en hexadécimal', max_length=7, validators=[django.core.validators.RegexValidator(message="La chaîne de caractère rentrée n'est pas une couleur en hexadécimal.", regex='^#(?:[0-9a-fA-F]{3}){1,2}$')], verbose_name='couleur')),
|
('color', models.CharField(help_text='Rentrer une couleur en hexadécimal', max_length=7, validators=[django.core.validators.RegexValidator(message="La chaîne de caractère rentrée n'est pas une couleur en hexadécimal.", regex='^#(?:[0-9a-fA-F]{3}){1,2}$')], verbose_name='couleur')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'tags',
|
|
||||||
'verbose_name': 'tag',
|
'verbose_name': 'tag',
|
||||||
|
'verbose_name_plural': 'tags',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -62,8 +62,8 @@ class Migration(migrations.Migration):
|
||||||
('remarks', models.TextField(blank=True, help_text='Visible uniquement par les organisateurs', null=True, verbose_name='remarques')),
|
('remarks', models.TextField(blank=True, help_text='Visible uniquement par les organisateurs', null=True, verbose_name='remarques')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'templates activité',
|
|
||||||
'verbose_name': 'template activité',
|
'verbose_name': 'template activité',
|
||||||
|
'verbose_name_plural': 'templates activité',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -79,8 +79,8 @@ class Migration(migrations.Migration):
|
||||||
('created_by', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='created_events', to=settings.AUTH_USER_MODEL)),
|
('created_by', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='created_events', to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'évènements',
|
|
||||||
'verbose_name': 'évènement',
|
'verbose_name': 'évènement',
|
||||||
|
'verbose_name_plural': 'évènements',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
@ -89,11 +89,11 @@ class Migration(migrations.Migration):
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(max_length=200, verbose_name='nom du lieu')),
|
('name', models.CharField(max_length=200, verbose_name='nom du lieu')),
|
||||||
('description', models.TextField(blank=True)),
|
('description', models.TextField(blank=True)),
|
||||||
('event', models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèleest spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement')),
|
('event', models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèle est spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'lieux',
|
|
||||||
'verbose_name': 'lieu',
|
'verbose_name': 'lieu',
|
||||||
|
'verbose_name_plural': 'lieux',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
|
@ -114,7 +114,7 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='activitytag',
|
model_name='activitytag',
|
||||||
name='event',
|
name='event',
|
||||||
field=models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèleest spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement'),
|
field=models.ForeignKey(blank=True, help_text="Si spécifié, l'instance du modèle est spécifique à l'évènement en question", null=True, on_delete=django.db.models.deletion.CASCADE, to='event.Event', verbose_name='évènement'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='activity',
|
model_name='activity',
|
||||||
|
|
|
@ -4,7 +4,6 @@ from django.core.validators import RegexValidator
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from communication.models import SubscriptionMixin
|
from communication.models import SubscriptionMixin
|
||||||
from shared.models import EventSpecificMixin
|
|
||||||
|
|
||||||
|
|
||||||
class Event(SubscriptionMixin, models.Model):
|
class Event(SubscriptionMixin, models.Model):
|
||||||
|
@ -39,6 +38,23 @@ class Event(SubscriptionMixin, models.Model):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
class EventSpecificMixin(models.Model):
|
||||||
|
"""Mixin allowing for event-specific models instances
|
||||||
|
or not (depending on whether the event field is null)"""
|
||||||
|
|
||||||
|
event = models.ForeignKey(
|
||||||
|
'event.Event',
|
||||||
|
verbose_name=_("évènement"),
|
||||||
|
help_text=_("Si spécifié, l'instance du modèle "
|
||||||
|
"est spécifique à l'évènement en question"),
|
||||||
|
blank=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class Place(EventSpecificMixin, models.Model):
|
class Place(EventSpecificMixin, models.Model):
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
_("nom du lieu"),
|
_("nom du lieu"),
|
||||||
|
@ -162,7 +178,7 @@ class Activity(AbstractActivityTemplate):
|
||||||
inherited_fields = [f.name for f in ActivityTemplate._meta.get_fields()]
|
inherited_fields = [f.name for f in ActivityTemplate._meta.get_fields()]
|
||||||
m2m_fields = [f.name for f in ActivityTemplate._meta.get_fields()
|
m2m_fields = [f.name for f in ActivityTemplate._meta.get_fields()
|
||||||
if f.many_to_many]
|
if f.many_to_many]
|
||||||
attr = super(Activity, self).__getattribute__(attrname)
|
attr = getattr(self, attrname)
|
||||||
if attrname not in inherited_fields:
|
if attrname not in inherited_fields:
|
||||||
raise FieldError(
|
raise FieldError(
|
||||||
_("%(attrname)s n'est pas un champ héritable"),
|
_("%(attrname)s n'est pas un champ héritable"),
|
||||||
|
@ -172,9 +188,9 @@ class Activity(AbstractActivityTemplate):
|
||||||
if attr.exists():
|
if attr.exists():
|
||||||
return attr
|
return attr
|
||||||
else:
|
else:
|
||||||
return self.parent.__getattribute__(attrname)
|
return getattr(self.parent, attrname)
|
||||||
elif attr is None:
|
elif attr is None:
|
||||||
return self.parent.__getattribute__(attrname)
|
return getattr(self.parent, attrname)
|
||||||
else:
|
else:
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue