本文整理匯總了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 }))