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


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

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


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

示例1: get

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import shops['value'] [as 别名]
 def get(self):
     form = Form(self.request.arguments, add_schema)
     form.shops['value'] = []
     supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s',
                                    self.current_user.supplier_id)
     form.img_paths['value'] = dict()
     self.render('goods/add.html', form=form, supplier_shops=supplier_shops, error='', action='add', img_url=img_url)
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:9,代码来源:goods.py

示例2: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import shops['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

示例3: get

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

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

        form = Form(goods_info, add_schema)
        form.shops['value'] = shops
        form.img_paths['value'] = dict() if not form.img_paths.value else json.loads(form.img_paths.value)

        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)
        self.render('wx/mall/goods_add.html', form=form, error='', action='edit', img_url=img_url,
                    supplier_shops=supplier_shops)
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:17,代码来源:__init__.py

示例4: get

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import shops['value'] [as 别名]
    def get(self):
        goods_id = self.get_argument('id')
        goods_info, shops, properties = get_goods_info(self.db, goods_id)
        form = Form(goods_info, add_schema)
        form.shops['value'] = shops
        form.supplier_name.value = self.db.get('select short_name from supplier where id=%s',
                                               goods_info.supplier_id).short_name
        form.img_paths['value'] = dict() if not form.img_paths.value else json.loads(form.img_paths.value)

        supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
                                       form.supplier_id.value)
        all_sku = self.db.query('select * from sku where deleted=0 and supplier_id=%s', form.supplier_id.value)
        form.skus.value = ['%s-%s' % (item.sku_id, item.num) for item in
                           self.db.query('select sku_id, num from sku_goods where goods_id=%s', goods_id)]

        distributors = self.db.query('select * from distributor_shop where deleted = 0')
        form.properties.value = ['%s-%s' % (item.name, item.value) for item in properties]
        form.ratios.value = ['%s-%s' % (item.distr_shop_id, item.ratio) for item in
                             self.db.query('select distr_shop_id, ratio from goods_distributor_commission '
                                           'where goods_id=%s', goods_id)]
        self.render('goods/add.html', form=form, error='', action='edit', img_url=img_url,
                    supplier_shops=supplier_shops, all_sku=all_sku, distributors=distributors)
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:24,代码来源:goods.py

示例5: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import shops['value'] [as 别名]
    def post(self):
        form = Form(self.request.arguments, add_schema)
        goods_info, shops, properties = get_goods_info(self.db, form.id.value)
        # 为了下面的 validate 成功 这里必须填入数据
        form.arguments.update({'type': EmptyDict({'value': goods_info.type}),
                               '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 = ['%s-%s' % (item.name, item.value) for item in properties]
            form.shops['value'] = shops

            supplier_shops = self.db.query('select ss.* from supplier_shop ss where ss.supplier_id=%s and ss.deleted=0',
                                           form.supplier_id.value)
            all_sku = self.db.query('select * from sku where deleted=0 and supplier_id=%s', form.supplier_id.value)
            distributors = self.db.query('select * from distributor_shop where deleted = 0')
            form.img_paths['value'] = img_paths
            logging.error(json_dumps(form.errors))
            self.render('goods/add.html', form=form, error='', action='edit', img_url=img_url,
                        supplier_shops=supplier_shops, all_sku=all_sku, distributors=distributors)
            return

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

        update_sql = 'update goods set %s, created_at = NOW(), created_by = %%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(self.current_user.name)
        params.append(form.id.value)

        #将更新前的旧数据插入goods_copy商品
        insert_fields = ('supplier_id', 'face_value', 'purchase_price', 'sales_price', 'sales_count', 'stock',
                         'virtual_sales_count', 'code', 'all_shop', 'name', 'short_name', 'sms_name', 'category_id',
                         'img_path', 'created_at', 'expire_at', 'detail', 'tips', 'supplier_intro', 'status',
                         'created_by', 'deleted', 'type', 'generate_type', 'supplier_goods_id', 'on_sale_at',
                         'off_sale_at', 'img_paths')
        change_fields = ','.join([field for field in insert_fields])
        insert_id = self.db.execute('insert into goods_copy({0}) select {0} from goods '
                                    'where id = %s'.format(change_fields), form.id.value)
        self.db.execute('update goods_copy set goods_id = %s where id = %s', form.id.value, insert_id)

        #更新goods表
        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", "jd_team_id")', 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)
        # 批量更新SKU
        self.db.execute('delete from sku_goods where goods_id=%s', form.id.value)
        if form.skus.value:
            insert_skus(self.db, form.skus.value, form.id.value)
        # 批量更新分销店铺佣金
        self.db.execute('delete from goods_distributor_commission where goods_id=%s', form.id.value)
        if form.ratios.value:
            insert_ratios(self.db, form.ratios.value, form.id.value)

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

示例6: post

# 需要导入模块: from autumn.torn.form import Form [as 别名]
# 或者: from autumn.torn.form.Form import shops['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)

        # 为了下面的 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('wx/mall/goods_add.html', form=form, error='', action='edit', 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')

        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.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.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_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('wx.goods.list'))
开发者ID:xutaoding,项目名称:osp_autumn,代码行数:63,代码来源:__init__.py


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