Override attribution save() + stuff
This commit is contained in:
parent
3439abe922
commit
8a587b3d56
2 changed files with 27 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from event.models import Activity
|
||||
from shared.models import EventSpecificMixin
|
||||
from event.models import Activity, EventSpecificMixin
|
||||
|
||||
|
||||
class Equipment(EventSpecificMixin, models.Model):
|
||||
|
@ -18,8 +18,8 @@ class Equipment(EventSpecificMixin, models.Model):
|
|||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("matériel permanent")
|
||||
verbose_name_plural = _("matériels permanents")
|
||||
verbose_name = _("matériel")
|
||||
verbose_name_plural = _("matériels")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -40,6 +40,12 @@ class EquipmentAttribution(models.Model):
|
|||
self.amout,
|
||||
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):
|
||||
remark = models.TextField(_("remarque sur le matériel"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue