本文整理汇总了Python中accounts.models.Account.get方法的典型用法代码示例。如果您正苦于以下问题:Python Account.get方法的具体用法?Python Account.get怎么用?Python Account.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.Account
的用法示例。
在下文中一共展示了Account.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clearance_edit
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get [as 别名]
def clearance_edit(request, clearance_id):
clearance = Clearance.get_by_id(int(clearance_id))
if clearance is None:
raise Http404
if getConfig('CLEARANCE_ALL_ORDER_ITEMS',0):
logging.info('showing all order items!')
order_item_query = OrderItem.objects.all().filter('date =', clearance.date)
else:
order_item_query = OrderItem.objects.all().filter('date =', clearance.date).filter('clearance_item_ref =', None)
c_pick_form = None
c_give_form = None
c_del_form = None
c_clear_form = None
c_load_form = None
c_deposit_form = None
pick_accounts = Account.objects.all().filter('purpose =', 'user').fetch(100)
give_accounts = Account.objects.all().filter('purpose =', 'credit').fetch(100)
if request.method == 'POST':
logging.info(request.POST)
if request.POST['action'] == 'update':
c_form = ClearanceForm(request.POST)
if c_form.is_valid():
clearance.date = c_form.cleaned_data['date']
clearance.desc = c_form.cleaned_data['desc']
clearance.save()
if request.POST['action'] == 'pick_item':
order_items = order_item_query.fetch(100)
c_pick_form = ClearanceItemPickForm(request.POST,accounts=pick_accounts,order_items=order_items)
if c_pick_form.is_valid():
logging.info('c_pick_form is valid!')
order_item = OrderItem.get(c_pick_form.cleaned_data['order_item_id'])
account = Account.get(c_pick_form.cleaned_data['account_id'])
logging.info('account = %s'%account)
logging.info('order_item = %s'%order_item)
if order_item is None:
raise Http404
if account is None:
raise Http404
ci = ClearanceItem(parent=clearance)
ci.account = account
ci.order_item = order_item
ci.cost = order_item.cost
ci.desc = order_item.name
ci.purpose='pick'
ci.save()
order_item.clearance_item_ref = ci.key()
order_item.save()
c_pick_form = None
if request.POST['action'] == 'give_item':
c_give_form = ClearanceItemGiveForm(request.POST, give_accounts)
if c_give_form.is_valid():
logging.info('c_give_form is valid!')
account = Account.get(c_give_form.cleaned_data['account_id'])
logging.info('account = %s'%account)
if account is None:
raise Http404
ci = ClearanceItem(parent=clearance)
ci.account = account
ci.cost = int(c_give_form.cleaned_data['cost'])
ci.purpose='give'
ci.save()
c_give_form = None
if request.POST['action'] == 'load_item':
c_load_form = ClearanceItemLoadForm(request.POST, give_accounts)
if c_load_form.is_valid():
logging.info('c_load_form is valid!')
account = Account.get(c_load_form.cleaned_data['account_id'])
logging.info('account = %s'%account)
if account is None:
raise Http404
ci = ClearanceItem(parent=clearance)
ci.account = account
ci.cost = int(c_load_form.cleaned_data['cost'])
ci.purpose='load'
ci.desc = c_load_form.cleaned_data['desc']
ci.save()
c_load_form = None
if request.POST['action'] == 'deposit_item':
c_deposit_form = ClearanceItemDepositForm(request.POST, pick_accounts)
if c_deposit_form.is_valid():
logging.info('c_deposit_form is valid!')
account = Account.get(c_deposit_form.cleaned_data['account_id'])
logging.info('account = %s'%account)
if account is None:
raise Http404
#.........这里部分代码省略.........