当前位置: 首页>>代码示例>>Python>>正文


Python Form.off_sale_at['value']方法代码示例

本文整理汇总了Python中autumn.torn.form.Form.off_sale_at['value']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.off_sale_at['value']方法的具体用法?Python Form.off_sale_at['value']怎么用?Python Form.off_sale_at['value']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autumn.torn.form.Form的用法示例。


在下文中一共展示了Form.off_sale_at['value']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import off_sale_at['value'] [as 别名]
    def post(self):
        form = Form(self.request.arguments, add_schema)
        goods_info, shops, properties, img = get_goods_info(self.db, form.id.value)

        if goods_info.supplier_id != self.current_user.supplier_id:
            raise HTTPError(403)

        if goods_info.status not in ['PREPARE', 'REJECT']:
            raise HTTPError(403)

        # 为了下面的 validate 成功 这里必须填入数据
        form.arguments.update({'generate_type': EmptyDict({'value': goods_info.generate_type})})
        img_paths = dict()
        for key in self.request.arguments:
            if key.startswith('var_img_path_'):
                v = self.request.arguments[key][0]
                if v:
                    img_paths[key[key.rindex('_')+1:]] = v
        form.img_paths['value'] = json_dumps(img_paths)
        if not form.validate():
            form.properties.value = properties
            form.shops['value'] = shops
            form.img_paths['value'] = img_paths

            supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
                                           self.current_user.supplier_id)
            logging.error(json_dumps(form.errors))
            self.render('goods/add.html', form=form, error='', action='edit', supplier_shops=supplier_shops,
                        img_url=img_url)

        fields = ('type', 'generate_type', 'expire_at', 'category_id', 'name', 'short_name', 'sms_name', 'face_value',
                  'sales_price', 'purchase_price', 'stock', 'virtual_sales_count', 'img_path', 'detail', 'tips',
                  'supplier_intro', 'all_shop', 'on_sale_at', 'off_sale_at', 'img_paths', 'postage')

        update_sql = 'update goods set %s where id=%%s' % ','.join([field + '=%s' for field in fields])

        form.expire_at['value'] = ceiling(form.expire_at.value, today=True) if form.expire_at.value else None
        form.off_sale_at['value'] = ceiling(form.off_sale_at.value, today=True) if form.off_sale_at.value else None
        params = [form.arguments[field]['value'] for field in fields]
        params.append(form.id.value)

        self.db.execute(update_sql, *params)

        self.db.execute('insert into journal(created_at, type, created_by, message, iid) '
                        'values(NOW(), 3, %s, %s, %s)', self.current_user.name, '商户修改了商品', form.id.value)

        # 批量更新商品属性
        self.db.execute('delete from goods_property where goods_id=%s and name in ("gift_card", "hidden", "ktv")',
                        form.id.value)
        if form.properties.value:
            insert_properties(self.db, form.properties.value, form.id.value)

        # 批量更新关联门店
        self.db.execute('delete from goods_supplier_shop where goods_id=%s', form.id.value)
        if not form.all_shop.value:
            if form.shops.value:
                insert_shops(self.db, form.shops.value, form.id.value)

        self.redirect(self.reverse_url('goods.list'))
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:61,代码来源:goods.py

示例2: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import off_sale_at['value'] [as 别名]
    def post(self):
        form = Form(self.request.arguments, add_schema)
        img_paths = dict()
        for key in self.request.arguments:
            if key.startswith('var_img_path_'):
                v = self.request.arguments[key][0]
                if v:
                    img_paths[key[key.rindex('_')+1:]] = v

        if not form.validate():
            supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
                                           self.current_user.supplier_id)
            form.img_paths['value'] = img_paths
            logging.error(json_dumps(form.errors))
            return self.render('wx/mall/goods_add.html', form=form, error='error', action='add', supplier_shops=supplier_shops,
                               img_url=img_url)
        # 获取微信商品手续费
        commission = self.db.get('select value from supplier_property where sp_id=%s and name="wx_commission"',
                                 self.current_user.supplier_id)
        if not commission:
            rate = Decimal((100 - options.wx_min_commission)/100.0)
        else:
            rate = Decimal((100 - int(commission.value))/100.0)
        # 更新结算价
        form.arguments['purchase_price']['value'] = form.arguments['sales_price']['value'] * rate

        fields = ('type', 'generate_type', 'expire_at', 'category_id', 'short_name', 'sms_name',
                  'max_buy', 'on_sale_at', 'off_sale_at', 'face_value', 'sales_price', 'purchase_price',
                  'stock', 'img_path', 'all_shop', 'detail',  'postage')

        goods_sql = """
            insert into goods(%s, supplier_id, created_by, img_paths, created_at, status, name)
            values (%s, %%s, %%s, %%s, NOW(), "PREPARE", "")""" % (','.join(fields), ','.join(['%s']*len(fields)))

        form.expire_at['value'] = ceiling(form.expire_at.value, today=True) if form.expire_at.value else None
        form.on_sale_at['value'] = form.on_sale_at.value if form.off_sale_at.value else None
        form.off_sale_at['value'] = ceiling(form.off_sale_at.value, today=True) if form.off_sale_at.value else None
        params = [form.arguments[field]['value'] for field in fields]

        params.extend([self.current_user.supplier_id, self.current_user.name, json_dumps(img_paths)])

        goods_id = self.db.execute_lastrowid(goods_sql, * params)

        self.db.execute('insert into journal(created_at, type, created_by, message, iid) '
                        'values(NOW(), 3, %s, %s, %s)', self.current_user.name, '商户新增了微商城商品', goods_id)

        # 批量插入关联的门店
        if not form.all_shop.value:
            if form.shops.value:
                insert_shops(self.db, form.shops.value, goods_id)

        # 插入微信商品特有属性
        self.db.execute('insert into goods_property (goods_id, name, value) values '
                        '(%s, "is_wx_goods", %s)', goods_id, "1")
        self.db.execute('insert into goods_property (goods_id, name, value) values '
                        '(%s, "is_wx_on_sale", %s)', goods_id, "0")

        self.redirect(self.reverse_url('wx.goods.list'))
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:60,代码来源:__init__.py

示例3: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import off_sale_at['value'] [as 别名]
    def post(self):
        form = Form(self.request.arguments, add_schema)

        img_paths = dict()
        for key in self.request.arguments:
            if key.startswith('var_img_path_'):
                v = self.request.arguments[key][0]
                if v:
                    img_paths[key[key.rindex('_')+1:]] = v
        form.img_paths['value'] = json_dumps(img_paths)

        if not form.validate():
            supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
                                           form.supplier_id.value)
            distributors = self.db.query('select * from distributor_shop where deleted = 0')
            all_sku = self.db.query('select * from sku where deleted=0 and supplier_id=%s', form.supplier_id.value)
            form.img_paths['value'] = img_paths
            logging.error(json_dumps(form.errors))

            return self.render('goods/add.html', form=form, error='error', action='add', img_url=img_url,
                               supplier_shops=supplier_shops, all_sku=all_sku, distributors=distributors)

        fields = ('type', 'generate_type', 'expire_at', 'category_id', 'name', 'short_name', 'sms_name', 'img_paths',
                  'face_value', 'sales_price', 'purchase_price', 'stock', 'virtual_sales_count', 'img_path', 'all_shop',
                  'detail', 'tips', 'supplier_intro', 'created_by', 'supplier_id', 'on_sale_at', 'off_sale_at')

        goods_sql = 'insert into goods(%s, created_at, status) values (%s ,NOW(), "ON_SALE")' % (
            ','.join(fields), ','.join(['%s']*len(fields)))

        form.expire_at['value'] = ceiling(form.expire_at.value, today=True) if form.expire_at.value else None
        form.off_sale_at['value'] = ceiling(form.off_sale_at.value, today=True) if form.off_sale_at.value else None
        form.arguments['created_by'] = EmptyDict({'value': self.current_user.name})

        params = [form.arguments[field]['value'] for field in fields]

        goods_id = self.db.execute_lastrowid(goods_sql, * params)
        self.db.execute('insert into journal(created_at, type, created_by, message, iid) '
                        'values(NOW(), 3, %s, %s, %s)', self.current_user.name, '新增了商品', goods_id)

        # 批量插入商品属性
        if form.properties.value:
            insert_properties(self.db, form.properties.value, goods_id)

        # 批量插入关联的门店
        if not form.all_shop.value:
            if form.shops.value:
                insert_shops(self.db, form.shops.value, goods_id)

        # 批量插入SKU信息
        if form.skus.value:
            insert_skus(self.db, form.skus.value, goods_id)
        # 批量插入分销店铺佣金
        if form.ratios.value:
            insert_ratios(self.db, form.ratios.value, goods_id)
        self.redirect(self.reverse_url('goods.show_list'))
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:57,代码来源:goods.py


注:本文中的autumn.torn.form.Form.off_sale_at['value']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。