Ejemplo n.º 1
0
def _get_ustation_entity(entity_id, update_ustation=False):
    _entity = Entity(entity_id)
    _entity_context = _entity.read()

    if _entity_context.has_key('item_id_list') and len(
            _entity_context['item_id_list']):
        _item = Item(_entity_context['item_id_list'][0])
        _item_context = _item.read()

        _entity_context['buy_link'] = _item_context['buy_link']
        _entity_context['taobao_title'] = _item_context['title']
        _entity_context['taobao_id'] = _item_context['taobao_id']
        _entity_context['taobao_shop_nick'] = _item_context['shop_nick']

        if _item_context.has_key('shop_nick') and (
                not _item_context.has_key('ustation')
                or _item_context['ustation'] != 1):
            _shop_context = TaobaoShop(_item_context['shop_nick']).read()
            if _shop_context != None:
                _entity_context['commission_rate'] = _shop_context[
                    'extended_info']['commission_rate']
                if _shop_context['extended_info']['orientational']:
                    _entity_context['commission_type'] = 'orientational'
                else:
                    _entity_context['commission_type'] = 'general'
                if _entity_context['commission_rate'] > 0:
                    if update_ustation:
                        if not _item_context.has_key(
                                'ustation'
                        ) or _item_context['ustation'] == None:
                            _item.update(ustation=0)
                    return _entity_context
    return None
Ejemplo n.º 2
0
 def __get_context(self):
     context = {}
     entity = Entity(self.activity_obj.entity_id)
     item = Item(self.activity_obj.item_id)
     context['activity_id'] = self.activity_obj.id
     context['entity_context'] = entity.read()
     context['item_context'] = item.read()
     context['shop_nick'] = self.activity_obj.shop_nick
     context['taobao_id'] = self.activity_obj.taobao_id
     context['sale_price'] = self.activity_obj.sale_price
     context['total_volume'] = self.activity_obj.total_volume
     context['sales_volume'] = self.activity_obj.sales_volume
     context['start_time'] = self.activity_obj.start_time
     context['end_time'] = self.activity_obj.end_time
     context['seller_remarks'] = self.activity_obj.seller_remarks
     context['editor_remarks'] = self.activity_obj.editor_remarks
     context['created_time'] = self.activity_obj.created_time
     context['updated_time'] = self.activity_obj.updated_time
     context['status'] = self.activity_obj.status
     return context
Ejemplo n.º 3
0
def commodities(request, user_context, shop_inst):
    item_list = Item.find_taobao_item(shop_nick=user_context['shop_nick'],
                                      full_info=True)
    for i in range(len(item_list)):
        item = Item(item_list[i]['item_id'])
        item_context = item.read()
        item_list[i]['item'] = item_context
        item_list[i]['entity'] = Entity(item_context['entity_id']).read()
    verification_form = ShopVerificationForm()
    shop_context = shop_inst.read()
    if not shop_context['shop_verified']:
        shop_verification = shop_inst.read_shop_verification()
    else:
        shop_verification = None
    return render_to_response("commodities.html", {
        "item_list": item_list,
        "user_context": user_context,
        "verification_form": verification_form,
        "shop_verification": shop_verification
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 4
0
def shop_detail(request):
    _nick = request.GET.get("nick", None)
    if _nick:
        shop = TaobaoShop(_nick)
        shop_context = shop.read()
        item_list = Item.find_taobao_item(shop_nick=shop_context['shop_nick'],
                                          full_info=True)
        items = []
        for item in item_list:
            inst = Item(item['item_id'])
            item_context = inst.read()
            entity = Entity(item['entity_id'])
            item_context['image'] = entity.read()['chief_image']
            items.append(item_context)
        return render_to_response("shop/detail.html", {
            "shop": shop_context,
            "items": items,
            "gifts": ALL_GIFTS,
            "priorities": range(11),
            "taobao_shop_types": SHOP_TYPES
        },
                                  context_instance=RequestContext(request))
    else:
        return Http404()