Exemplo n.º 1
0
class AdaptorProduct(StoreProduct):
    """Product 适配器""" 

    objects = AdaptorProductManager() 
    
    def __str__(self):
        return self.title 
Exemplo n.º 2
0
class OfficialProduct(Product):
    """商城类的Product适配器"""
    def fallback(self):
        """下架商品"""
        self.status = self.FALLDOWN
        self.save()

    @property
    def hasbill(self):
        """查看产品是否有订单产生,如果有的话,return True 否则 return False """
        bills = self.adaptorbill_set.all()
        if len(bills) > 0:
            return True
        else:
            return False

    def set_undeleted(self):
        """
        修改product时,将product的规格的deleted字段预先都设置为1
        """
        self.adaptorrule_set.all().update(deleted=1)

    def delete_droped_rules(self):
        """
        修改product时,有些规格可能被用户删除了
        被删除的规格的deleted字段标记为1

        注意:有未支付订单的规格不能删除
        返回没有删除的记录列表
        """
        rules = self.adaptorrule_set.filter(deleted=1)
        undeleted_list = []
        for rule in rules:
            if rule.has_unpayedbill() > 0:
                rule_error = {}
                rule_error['ruleid'] = rule.id
                rule_error['name'] = rule.name
                undeleted_list.append(rule_error)
                rule.deleted = 0
                rule.save()
            else:
                rule.delete()

        return undeleted_list

    def publish(self):
        """发布商品, 商品上架"""
        self.status = self.PUBLISHED
        self.save()

    objects = AdaptorProductManager()
    taobaourl = models.CharField(_('taobao url'), max_length=2048, null=True)

    def __str__(self):
        return self.title

    class Meta:
        abstract = True
Exemplo n.º 3
0
class AdaptorProduct(OfficialProduct):
    """Product 适配器"""
    objects = AdaptorProductManager()

    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-date']
Exemplo n.º 4
0
class AdaptorProduct(Product):
    """Product 适配器"""
    objects = AdaptorProductManager()
    # 设置到首页,默认0是不放在首页的
    # 1 代表放在首页
    set_homepage = models.SmallIntegerField(default=0)
    # 设置到首页列表中,默认0是不放在首页列表中的
    # 1 代表放在首页列表中
    set_grid = models.SmallIntegerField(default=0)

    def __str__(self):
        return self.title
Exemplo n.º 5
0
class StoreProduct(Product):
    # 是否有货,默认为1代表有货,没有货时为0
    # 没有货时不能下单
    available = models.SmallIntegerField(default=1)
    """商城类的Product适配器"""
    def fallback(self):
        """下架商品"""
        self.status = self.FALLDOWN
        self.save()

    @property
    def hasbill(self):
        """查看产品是否有订单产生,如果有的话,return True 否则 return False """
        bills = self.adaptorbill_set.all()
        if len(bills) > 0:
            return True
        else:
            return False

    def set_undeleted(self):
        """
        修改product时,将product的规格的deleted字段预先都设置为1
        """
        self.adaptorrule_set.all().update(deleted=1)

    def delete_droped_rules(self):
        """
        修改product时,有些规格可能被用户删除了
        被删除的规格的deleted字段标记为1

        注意:有未支付订单的规格不能删除
        返回没有删除的记录列表
        """
        rules = self.adaptorrule_set.filter(deleted=1)
        undeleted_list = []
        for rule in rules:
            rule.delete()

        return undeleted_list

    def publish(self):
        """发布商品, 商品上架"""
        self.status = self.PUBLISHED
        self.save()

    objects = AdaptorProductManager()
    taobaourl = models.CharField(_('taobao url'), max_length=2048, null=True)

    def __str__(self):
        return self.title

    class Meta:
        abstract = True