本文整理汇总了Python中accounts.models.Account.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Account.get_by_id方法的具体用法?Python Account.get_by_id怎么用?Python Account.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.Account
的用法示例。
在下文中一共展示了Account.get_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: task_one_trans_report
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def task_one_trans_report(request,account_id=None):
account = Account.get_by_id(int(account_id))
if account is None:
raise Http404
logging.info('do_one_trans_report(%s)' % (account_id))
account_report = getDetailAccountReport(account.key().id())
logging.info('account report: "%s"' % account_report)
send_mail_to_user('VMTracker account id:%d report' % int(account_id), account_report, account.report_email)
return HttpResponse('ok')
示例2: account_edit
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def account_edit(request, account_id):
account = Account.get_by_id(int(account_id))
if account is None:
raise Http404
if request.method == 'POST':
form = AccountForm(request.POST, instance=account)
if form.is_valid():
logging.info('edit account before - id: %s key: %s data: %s' % (account.key().id() , account.key(), account))
form.save(commit=False)
logging.info('edit account after - id: %s key: %s data: %s' % (account.key().id() , account.key(), account))
account.save()
return redirect('/accounts/')
else:
form = AccountForm(instance=account)
return render_to_response('accounts/edit.html', RequestContext(request, { 'form': form }))
示例3: transaction_create
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def transaction_create(request, account_id):
account = Account.get_by_id(int(account_id))
if account is None:
raise Http404
if request.method == 'POST':
t = Transaction(parent=account)
form = TransactionForm(request.POST, instance=t)
if form.is_valid():
form.save(commit=False)
t.setDate()
t.save()
logging.info('new transaction created - id: %s key: %s data: %s' % (t.key().id() , t.key(), t))
return redirect('/accounts/'+account_id+'/transactions/')
else:
form = TransactionForm()
return render_to_response('accounts/transaction_create.html', RequestContext(request, { 'form':form }))
示例4: getDetailAccountReport
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def getDetailAccountReport(account_id=None):
if not account_id:
return 'no account id'
report = 'account detail report (account_id: %d, time: %s)\n' % (account_id, datetime.datetime.utcnow())
account = Account.get_by_id(int(account_id))
if account is None:
report = report + 'account id:%d not found' % account_id
return report
report = report + '\nAccount:\n'
report = report + account.getReportInfo()
report = report + '\n\nLast 10 transactions: [id;date;amount;desc]\n'
transaction_list = Transaction.objects.all().ancestor(account).order('-create_date').fetch(10)
for transaction in transaction_list:
report = report + transaction.getReportInfo() + '\n'
return report
示例5: transaction_list
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def transaction_list(request, account_id):
account = Account.get_by_id(int(account_id))
if account is None:
raise Http404
transaction_list = Transaction.objects.all().ancestor(account).order('-create_date').fetch(100)
return render_to_response('accounts/transaction_list.html', RequestContext(request,{ 'transaction_list': transaction_list, 'account': account}))
示例6: account_show
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import get_by_id [as 别名]
def account_show(request,account_id):
account = Account.get_by_id(int(account_id))
if account is None:
raise Http404
return render_to_response('accounts/show.html', RequestContext( request, { 'account': account }))