本文整理汇总了Python中apps.gift.models.Gift.get方法的典型用法代码示例。如果您正苦于以下问题:Python Gift.get方法的具体用法?Python Gift.get怎么用?Python Gift.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.gift.models.Gift
的用法示例。
在下文中一共展示了Gift.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_data
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def update_data(
obj_key=None, catalogue_uid=None,
name=None, name_origin=None,
brand=None, rating=None, category=None,
subcategory=None, group=None,
price=None, barcode=None,
box_size=None, master_box=None,
status=None, receipt_date=None, real_price=None):
obj = Gift.get(obj_key)
if not obj:
print "Unknown error - object not found!"
exit(1)
i = 0
i += update_value(obj, 'catalogue_id', catalogue_uid)
i += update_value(obj, 'name_origin', name_origin)
i += update_value(obj, 'name', name)
i += update_value(obj, 'brand', brand)
i += update_value(obj, 'category', category)
i += update_value(obj, 'subcategory', subcategory)
i += update_value(obj, 'group', group)
i += update_value(obj, 'barcode', barcode)
i += update_value(obj, 'master_box', master_box)
i += update_value(obj, 'box_size', box_size)
i += update_value(obj, 'price', price)
i += update_value(obj, 'real_price', real_price)
i += update_value(obj, 'rating', rating)
i += update_value(obj, 'status', status)
i += update_receipt_date(obj, receipt_date)
if i:
obj.put()
示例2: add_new_thumb
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def add_new_thumb(request):
if request.method == 'POST':
gift_key = request.values.get('gift_key')
gift = Gift.get(gift_key)
if gift is None:
return redirect('/gift/admin/edit/%s/' % gift_key)
new_th_form = AddNewThumb()
if request.form and new_th_form.validate(request.form, request.files):
thumb = new_th_form['img']
content_type = 'image/jpeg'
if gift.name:
title = gift.name.replace('"', '"')
else:
title = ''
thumb_img = ThumbImage()
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(700, 700, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(400, 400, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(200, 200, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(100, 100, ),
title=title, content_type=content_type)
if not gift.thumbs.count():
thumb_img.main_gift = gift
thumb_img.gift = gift
thumb_img.put()
return redirect('/gift/admin/edit/%s/' % gift_key)
return redirect('/gift/admin/all/')
示例3: restore_from_trash
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def restore_from_trash(request, gift_key):
gift = Gift.get(gift_key)
if gift:
gift.in_trash = False
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
示例4: recalculate_order
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def recalculate_order(request, remove_one=None):
gifts = []
total_price = 0
items_count = 0
for key in request.session['order'].keys():
if key == remove_one:
del(request.session['order'][key])
continue
gift_obj = Gift.get(key)
if gift_obj:
gift_obj.number = request.session['order'][key]
if not request.user or request.user.is_anonymous():
total_price += gift_obj.price * gift_obj.number
else:
total_price += gift_obj.real_price * gift_obj.number
gifts.append(gift_obj)
items_count += request.session['order'][key]
else:
del(request.session['order'][key])
if gifts:
request.session['order_items_number'] = len(request.session['order'].keys())
request.session['order_total_price'] = total_price
request.session['order_items_count'] = items_count
else:
reset_order(request)
return gifts
示例5: move_to_trash
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def move_to_trash(request, gift_key):
gift = Gift.get(gift_key)
if gift:
gift.in_trash = True
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
示例6: upload_new_thumb
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def upload_new_thumb(request):
if request.method == 'POST':
gift_key = request.values.get('gift_key')
gift = Gift.get(gift_key)
if gift is None:
return redirect('/')
new_th_form = AddNewThumb()
if request.form and new_th_form.validate(request.form, request.files):
thumb = new_th_form['img']
content_type = 'image/jpeg'
if gift.name:
title = gift.name.replace('"', '"')
else:
title = ''
thumb_img = ThumbImage()
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(700, 700, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(400, 400, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(200, 200, ),
title=title, content_type=content_type)
thumb_img.add_new_thumb(blob_img=thumb, thumb_size=(100, 100, ),
title=title, content_type=content_type)
thumb_img.put()
gift.thumbs.append(str(thumb_img.key()))
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
return redirect('/')
示例7: set_default_thumb
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def set_default_thumb(request, gift, key):
thumb = ThumbImage.get(key)
if thumb:
gift_obj = Gift.get(gift)
if gift_obj:
if gift_obj.main_thumb.count():
for old_thumb in gift_obj.main_thumb:
old_thumb.main_gift = None
old_thumb.put()
thumb.main_gift = gift_obj
thumb.put()
return redirect('/gift/admin/edit/%s/' % gift)
示例8: sync_gift_task
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def sync_gift_task(request, key):
gift = Gift.get(key)
if not gift:
return render_to_response('empty.html')
url = 'http://www.5studio.ru/api/v1/get/gift.json?&uid=%s' \
% gift.uid_5studio
result = urlfetch.fetch(url)
if result.status_code == 200:
j = simplejson.loads(result.content)
gift.leftovers = j.get('leftovers', 0)
gift.category = get_category(j)
gift.subcategory = get_subcategory(j, gift.category)
gift.put()
else:
gift.delete()
return render_to_response('empty.html')
示例9: mass_reset_receipt_dates
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def mass_reset_receipt_dates(request):
gifts_ids = request.session['mass_edit_items']
gifts = []
for gift_id in gifts_ids:
gift = Gift.get(gift_id)
if gift:
gifts.append(gift)
if not gifts:
return redirect('/admin/mass_edit/select_filters/')
for gift in gifts:
if gift.receipt_date:
gift.receipt_date = None
gift.put()
return redirect('/admin/mass_edit/edit/')
示例10: edit
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def edit(request, key):
ret_url = request.values.get('ret_url', '')
gift = Gift.get(key)
if gift is None:
return redirect('/gift/admin/all/')
edit_form = GiftForm(instance=gift)
if request.method == 'POST' and edit_form.validate(request.form):
edit_form.save()
if ret_url:
return redirect(ret_url)
return redirect('/gift/admin/all/')
add_new_thumb_form = AddNewThumb()
return render_to_response('gift/admin/edit.html',
{'edit_form':edit_form.as_widget(),
'gift':gift,
'add_new_thumb_form':add_new_thumb_form.as_widget()})
示例11: change_main_thumb
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def change_main_thumb(request):
gift_key = request.values.get('gift_key')
thumb_key = request.values.get('thumb_key')
gift = Gift.get(gift_key)
if gift is None:
return redirect('/')
thumb = ThumbImage.get(thumb_key)
if thumb is None:
gift.thumbs.remove(thumb_key)
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
if gift.main_thumb == thumb_key:
return redirect('/g/%s' % gift.uid)
else:
gift.main_thumb = thumb_key
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
示例12: delete_thumb
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def delete_thumb(request):
gift_key = request.values.get('gift_key')
thumb_key = request.values.get('thumb_key')
gift = Gift.get(gift_key)
if gift is None:
return redirect('/')
thumb = ThumbImage.get(thumb_key)
if thumb is None:
gift.thumbs.remove(thumb_key)
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
if gift.main_thumb == thumb_key:
gift.main_thumb = None
gift.thumbs.remove(thumb_key)
thumb.delete()
if not len(gift.thumbs):
gift.main_thumb = ''
gift.put()
get_gift(gift.uid, True)
return redirect('/g/%s' % gift.uid)
示例13: mass_selection_edit
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def mass_selection_edit(request):
if request.method == 'POST':
new_brand_name = string.strip(request.values.get('new_brand_name'))
new_presentation_id = string.strip(request.values.get('new_presentation_id'))
new_youtube_id = string.strip(request.values.get('new_youtube_id'))
new_subcategory = string.strip(request.values.get('new_subcategory'))
new_group = string.strip(request.values.get('new_group'))
new_receipt_date = string.strip(request.values.get('new_receipt_date', ''))
if new_receipt_date:
try:
new_receipt_date = datetime.date(datetime.strptime(new_receipt_date, '%Y-%m-%d'))
except ValueError:
new_receipt_date = ''
gifts_ids = request.session['mass_edit_items']
gifts_array = []
for gift_id in gifts_ids:
gift = Gift.get(gift_id)
if gift:
gifts_array.append(gift)
if not gifts_array:
return redirect('/admin/mass_edit/select_filters/')
flag_brand_change = False
flag_groups_change = False
for gift in gifts_array:
flag = False
if new_brand_name and new_brand_name != gift.name:
gift.brand = new_brand_name
flag = flag_brand_change = True
if new_presentation_id and new_presentation_id != gift.presentation_id:
gift.presentation_id = new_presentation_id
flag = True
if new_youtube_id and new_youtube_id != gift.youtube_id:
gift.youtube_id = new_youtube_id
flag = True
if new_subcategory and new_subcategory != gift.subcategory:
gift.subcategory = new_subcategory
flag = True
flag_groups_change = True
if new_group and new_group != gift.group:
gift.group = new_group
flag = True
flag_groups_change = True
if new_receipt_date and new_receipt_date != gift.receipt_date:
gift.receipt_date = new_receipt_date
flag = True
if flag:
gift.put()
if flag_brand_change:
Gift.get_brand_list(force=True, is_admin=True)
if flag_groups_change:
Gift.get_subcategories_list(force=True)
request.session['mass_edit_items'] = 0
return redirect('/admin/mass_edit/select_filters/')
count = len(request.session['mass_edit_items'])
return render_to_response('admin/mass_edit/edit.html', {'count':count})
示例14: delete
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def delete(request, key):
gift = Gift.get(key)
if gift:
gift.delete()
return redirect('/gift/admin/all/')
示例15: delete_gift
# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get [as 别名]
def delete_gift(request, gift_key):
gift = Gift.get(gift_key)
if gift:
gift.delete()
return redirect('/')
return redirect(request.url)