コード例 #1
0
ファイル: models.py プロジェクト: jespino/django-payments
 def change_status(self, status):
     '''
     Updates the Payment status and sends the status_changed signal.
     '''
     from signals import status_changed
     self.status = status
     self.save()
     status_changed.send(sender=type(self), instance=self)
コード例 #2
0
ファイル: models.py プロジェクト: tbarbugli/django-payments
 def change_status(self, status):
     '''
     Updates the Payment status and sends the status_changed signal.
     '''
     from signals import status_changed
     self.status = status
     self.save()
     status_changed.send(sender=type(self), instance=self)
コード例 #3
0
ファイル: models.py プロジェクト: oraclebill/dsusa
    def save(self, force_insert=False, force_update=False):
#        if not self.project_name:
#            raise exceptions.ValidationError('All orders must contain a project name')
#        if not self.account_code:
#            raise exceptions.ValidationError('All orders must contain an account code')
#        if not (self.status and self.status in [first for (first,second) in self.Const.STATUS_CHOICES]):
#            raise ValueError('All orders must have a valid status')
        changed, old_status = self._check_status_change()

        if changed:
            if self.status == BaseOrder.Const.SUBMITTED:
                self.submitted = datetime.now()
            elif self.status == BaseOrder.Const.COMPLETED:
                self.completed = datetime.now()
                
        if self.status == self.Const.DEALER_EDIT or changed: 
            super(BaseOrder,self).save(force_insert, force_update)
            if None == old_status: # new order
                self._init_tracking_fields()
            if changed:
                status_changed.send(self, old=old_status, new=self.status)
        else:
            raise ValueError('Cannot modify order in %s status.' % self.status)