forked from Yaltik/golem
[IMP][FIX][WIP]GOLEM Activity Session Registration constraints for avoid duplicates or bad season subscription
This commit is contained in:
parent
65898e80b7
commit
7ea95dbac8
@ -76,3 +76,24 @@ class GolemActivitySessionRegistration(models.Model):
|
||||
related='session_id.season_id')
|
||||
is_current = fields.Boolean('Current season?',
|
||||
related='session_id.is_current')
|
||||
|
||||
# TODO : translate / change error ??
|
||||
_sql_constraints = [('golem_activity_session_registration_uniq',
|
||||
'UNIQUE (member_id, session_id)',
|
||||
'This memebr has already been registered for this '
|
||||
'session.')]
|
||||
|
||||
@api.constrains('member_id', 'session_id')
|
||||
def _check_season_reliability(self):
|
||||
""" Forbid registration when member season if not coherent with
|
||||
session season or are duplicates """
|
||||
for r in self:
|
||||
if r.session_id.season_id not in r.member_id.season_ids:
|
||||
emsg = _('Subscription can not be executed : the targeted '
|
||||
'member is not on the same season as the session.')
|
||||
raise models.ValidationError(emsg)
|
||||
# domain = ['&', ('session_id', '=', r.session_id.id),
|
||||
# ('member_id', '=', r.member_id.id)]
|
||||
# if len(self.search(domain)) > 1:
|
||||
# raise models.ValidationError(_('This member has already been '
|
||||
# 'registered for this session.'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user