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
def clean_ustation(request): for _item_info in Item.find_ustation(): _item = Item(_item_info['item_id']) _item.update(ustation=1) return HttpResponseRedirect(reverse('management_ustation_list'))