Esempio n. 1
0
    def delete(self, *args, **kwargs):
        # mark when the record deleted
        self.deleted_at = timezone.now()
        self.deleted_at_timestamp = to_timestamp(self.deleted_at)

        # save it
        return super(_BaseAbstract, self).save(*args, **kwargs)
Esempio n. 2
0
    def save(self, *args, **kwargs):
        now = timezone.now()
        if self.closed_by:
            if not self.closed_at:
                self.closed_at = now
                self.closed_at_timestamp = to_timestamp(self.closed_at)

        return super(CashBack, self).save(*args, **kwargs)
Esempio n. 3
0
    def save(self, *args, **kwargs):
        now = timezone.now()

        if self.sale_at is None:
            self.sale_at = now
            self.sale_at_timestamp = to_timestamp(self.sale_at)

        instance = super(Checkout, self).save(*args, **kwargs)
        return instance
Esempio n. 4
0
    def save(self, *args, **kwargs):
        now = timezone.now()

        # create first time record
        if self.created_at is None:
            self.created_at = now
            self.created_at_timestamp = to_timestamp(self.created_at)

        # always update
        self.updated_at = now
        self.updated_at_timestamp = to_timestamp(self.updated_at)

        # save the first time record
        instance = super(_BaseAbstract, self).save(*args, **kwargs)

        # generate id62
        if self.id and not self.id62:
            self.id62 = base62_encode(self.id)
            instance = super(_BaseAbstract, self).save(*args, **kwargs)
        
        return instance
Esempio n. 5
0
    def save(self, *args, **kwargs):
        now = timezone.now()

        if self.sale_at is None:
            self.sale_at = now
            self.sale_at_timestamp = to_timestamp(self.sale_at)

        if self.discount:
            self.discounted_price = self.price - ((self.price * self.discount.reduction) / 100)
        else:
            self.discounted_price = self.price

        return super(Sale, self).save(*args, **kwargs)