示例#1
0
    def full_clean(self, *args, **kw):
        """Checks for the following error conditions:

- You must specify a contract type.
- :message:`Contract ends before it started.`
- Any error message returned by :class:`OverlappingContractsTest`

"""
        if not self.date_ended:
            self.date_ended = self.applies_until
        r = self.active_period()
        if not isrange(*r):
            raise ValidationError(_('Contract ends before it started.'))

        if self.type_id:
            if not self.exam_policy_id:
                if self.type.exam_policy_id:
                    self.exam_policy_id = self.type.exam_policy_id

            if self.client_id is not None:
                if self.type.overlap_group:
                    msg = OverlappingContractsTest(self.client).check(self)
                    if msg:
                        raise ValidationError(msg)
        super(ContractBase, self).full_clean(*args, **kw)

        if self.type_id is None:
            raise ValidationError(dict(
                type=[_("You must specify a contract type.")]))
示例#2
0
 def full_clean(self, *args, **kw):
     if not isrange(self.start_date, self.end_date):
         raise ValidationError(_("Date period ends before it started."))
     super(DateRange, self).full_clean(*args, **kw)
示例#3
0
文件: periods.py 项目: sandeez/lino
 def full_clean(self, *args, **kw):
     if not isrange(self.start_date, self.end_date):
         raise ValidationError(_("Date period ends before it started."))
     super(DatePeriod, self).full_clean(*args, **kw)