本文整理汇总了Python中c3smembership.models.C3sMember.get_by_dues16_token方法的典型用法代码示例。如果您正苦于以下问题:Python C3sMember.get_by_dues16_token方法的具体用法?Python C3sMember.get_by_dues16_token怎么用?Python C3sMember.get_by_dues16_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.models.C3sMember
的用法示例。
在下文中一共展示了C3sMember.get_by_dues16_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_dues16_reversal_invoice_pdf
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_by_dues16_token [as 别名]
def make_dues16_reversal_invoice_pdf(request):
"""
This view checks supplied information (in URL) against info in database
-- especially the invoice number --
and conditionally returns
- an error message or
- a PDF
"""
email_address = request.matchdict['email']
token = request.matchdict['code']
invoice_number = request.matchdict['no']
try:
member = C3sMember.get_by_dues16_token(token)
assert member is not None
assert member.dues16_token == token
assert member.email == email_address
except AssertionError:
request.session.flash(
u"This member and token did not match!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
try:
invoice = Dues16Invoice.get_by_invoice_no(invoice_number)
assert invoice is not None
except AssertionError:
request.session.flash(
u"No invoice found!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# sanity check: invoice token must match with token
try:
assert(invoice.token == token)
except AssertionError:
request.session.flash(
u"Token did not match!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# sanity check: reversal invoice token must be reversal
try:
assert(invoice.is_reversal)
except AssertionError:
request.session.flash(
u"No reversal invoice found!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# return a pdf file
pdf_file = make_reversal_pdf_pdflatex(member, invoice)
response = Response(content_type='application/pdf')
pdf_file.seek(0) # rewind to beginning
response.app_iter = open(pdf_file.name, "r")
return response
示例2: make_dues16_invoice_no_pdf
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_by_dues16_token [as 别名]
def make_dues16_invoice_no_pdf(request):
"""
Create invoice PDFs on-the-fly.
This view checks supplied information (in URL) against info in database
and returns
- an error message OR
- a PDF as receipt
=== ===========================================================
URL http://app:port/dues_invoice_no/EMAIL/CAQJGCGUFW/C3S-dues16-0001.pdf
=== ===========================================================
"""
email_address = request.matchdict['email']
token = request.matchdict['code']
invoice_number = request.matchdict['i']
try:
member = C3sMember.get_by_dues16_token(token)
assert member is not None
assert member.dues16_token == token
assert member.email == email_address
except AssertionError:
request.session.flash(
u"This member and token did not match!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
try:
invoice = Dues16Invoice.get_by_invoice_no(
invoice_number.lstrip('0'))
assert invoice is not None
except AssertionError:
request.session.flash(
u"No invoice found!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# sanity check: invoice token must match with token
try:
assert(invoice.token == token)
except AssertionError:
request.session.flash(
u"Token did not match!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# sanity check: invoice must not be reversal
try:
assert(not invoice.is_reversal)
except AssertionError:
request.session.flash(
u"Token did not match!",
'message_to_user' # message queue for user
)
return HTTPFound(request.route_url('error_page'))
# return a pdf file
pdf_file = make_invoice_pdf_pdflatex(member, invoice)
response = Response(content_type='application/pdf')
pdf_file.seek(0) # rewind to beginning
response.app_iter = open(pdf_file.name, "r")
return response