本文整理汇总了Python中quokka.core.templates.render_template函数的典型用法代码示例。如果您正苦于以下问题:Python render_template函数的具体用法?Python render_template怎么用?Python render_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: confirmation
def confirmation(self): # redirect_url
context = {}
transaction_param = self.config.get(
'transaction_param',
self.pg.config.get('TRANSACTION_PARAM', 'transaction_id')
)
transaction_code = request.args.get(transaction_param)
if transaction_code:
context['transaction_code'] = transaction_code
response = self.pg.check_transaction(transaction_code)
logger.debug(response.xml)
reference = getattr(response, 'reference', None)
if not reference:
logger.error("no reference found")
return render_template('cart/simple_confirmation.html',
**context)
prefix = self.pg.config.get('REFERENCE_PREFIX', '') or ''
prefix = prefix.replace('%s', '')
status = getattr(response, 'status', None)
# get grossAmount to populate a payment with methods
try:
# self.cart = Cart.objects.get(
# reference_code=reference.replace(PREFIX, '')
# )
ref = reference.replace(prefix, '')
qs = Cart.objects.filter(
reference_code=ref
) or Cart.objects.filter(id=ref)
if not qs:
return "Cart not found"
self.cart = qs[0]
self.cart.set_status(
self.STATUS_MAP.get(str(status), self.cart.status)
)
self.cart.transaction_code = transaction_code
msg = "Status changed to: %s" % self.cart.status
self.cart.addlog(msg)
context['cart'] = self.cart
logger.info("Cart updated")
fee_amount = getattr(response, 'feeAmount', None)
if fee_amount:
self.cart.set_tax(fee_amount)
msg = "Tax set to: %s" % fee_amount
self.cart.addlog(msg)
# send response to reference and products
self.cart.send_response(response, 'pagseguro')
return render_template('cart/confirmation.html', **context)
except Exception as e:
msg = "Error in confirmation: {} - {}".format(reference, e)
logger.error(msg)
return render_template('cart/simple_confirmation.html', **context)
开发者ID:X10project,项目名称:quokka-cart,代码行数:60,代码来源:pagseguro_processor.py
示例2: process
def process(self, *args, **kwargs):
kwargs.update(self._record.config)
kwargs.update(self.cart.config)
response = self.pg.checkout(**kwargs)
self.cart.addlog(
(
"lib checkout data:{pg.data}\n"
" code:{r.code} url:{r.payment_url}\n"
" errors: {r.errors}\n"
" xml: {r.xml}\n"
).format(
pg=self.pg, r=response
)
)
if not response.errors:
self.cart.checkout_code = response.code
#self.cart.status = 'checked_out' # should set on redirect url
self.cart.addlog("PagSeguro processed! {}".format(response.code))
return redirect(response.payment_url)
else:
self.cart.addlog(
'PagSeguro error processing {}'.format(
response.errors
)
)
return render_template("cart/checkout_error.html",
response=response, cart=self.cart)
开发者ID:mpmedia,项目名称:quokka-cart,代码行数:27,代码来源:pagseguro_processor.py
示例3: post
def post(self, long_slug):
context = self.get_context_by_long_slug(long_slug)
form = context.get('form')
#if form.validate():
# comment = Comment()
# form.populate_obj(comment)
#
# content = context.get('content')
# content.comments.append(comment)
# content.save()
#
# return redirect(url_for('.detail', long_slug=long_slug))
if form.validate():
answer = Answer()
form.populate_obj(answer)
question = context.get('question')
question.tries.append(answer)
question.save()
#candidate = context.get('candidate')
#candidate.answers.append(answer)
#candidate.save()
return redirect(url_for('.detail', long_slug=long_slug))
return render_template(
self.get_template_names(),
theme=self.question.get_themes(),
**context
)
开发者ID:munum,项目名称:quokka,代码行数:33,代码来源:views.py
示例4: post
def post(self):
form = self.form(request.form)
if form.validate():
user = get_current_user()
avatar_file_path = user.avatar_file_path
avatar = request.files.get('avatar')
if avatar:
filename = secure_filename(avatar.filename)
avatar_file_path = os.path.join(
'avatars', str(user.id), filename
)
path = os.path.join(lazy_media_path(), avatar_file_path)
if not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path), 0o777)
avatar.save(path)
form.populate_obj(user)
user.avatar_file_path = avatar_file_path
if avatar:
user.use_avatar_from = 'upload'
user.username = User.generate_username(
user.username or user.name, user=user
)
self.update_user_links(request.form, user)
user.save()
flash('Profile saved!', 'alert')
return redirect(
request.args.get('next') or
url_for('quokka.modules.accounts.profile_edit')
)
else:
flash('Error ocurred!', 'alert error') # form errors
return render_template('accounts/profile_edit.html', form=form)
开发者ID:Madankapoor,项目名称:quokka,代码行数:34,代码来源:views.py
示例5: get
def get(self, long_slug):
now = datetime.now()
path = long_slug.split('/')
mpath = ",".join(path)
mpath = ",{0},".format(mpath)
channel = Channel.objects.get_or_404(mpath=mpath)
if channel.render_content:
return ContentDetail().get(
channel.render_content.content.long_slug, True)
self.channel = channel
base_filters = {}
filters = {
'published': True,
'available_at__lte': now,
'show_on_channel': True
}
if not channel.is_homepage:
base_filters['__raw__'] = {
'mpath': {'$regex': "^{0}".format(mpath)}}
filters.update(channel.get_content_filters())
contents = Content.objects(**base_filters).filter(**filters)
themes = channel.get_themes()
return render_template(self.get_template_names(),
theme=themes,
contents=contents,
channel=channel)
开发者ID:FashtimeDotCom,项目名称:quokka,代码行数:34,代码来源:views.py
示例6: get
def get(self, long_slug):
now = datetime.now()
path = long_slug.split('/')
mpath = ",".join(path)
mpath = ",{0},".format(mpath)
channel = Channel.objects.get_or_404(mpath=mpath, published=True)
# if channel.is_homepage and request.path != "/":
# return redirect("/")
if channel.redirect_url:
return redirect(channel.redirect_url)
if channel.render_content:
return ContentDetail().get(
channel.render_content.content.long_slug, True)
self.channel = channel
base_filters = {}
filters = {
'published': True,
'available_at__lte': now,
'show_on_channel': True
}
if not channel.is_homepage:
base_filters['__raw__'] = {
'mpath': {'$regex': "^{0}".format(mpath)}}
filters.update(channel.get_content_filters())
contents = Content.objects(**base_filters).filter(**filters)
if current_app.config.get("PAGINATION_ENABLED", True):
pagination_arg = current_app.config.get("PAGINATION_ARG", "page")
page = request.args.get(pagination_arg, 1)
per_page = (
request.args.get('per_page') or
channel.per_page or
current_app.config.get("PAGINATION_PER_PAGE", 10)
)
contents = contents.paginate(page=int(page),
per_page=int(per_page))
# this can be overkill! try another solution
# to filter out content in unpublished channels
# when homepage and also in blocks
# contents = [content for content in contents
# if content.channel.published]
themes = channel.get_themes()
return render_template(self.get_template_names(),
theme=themes,
contents=contents,
channel=channel)
开发者ID:alyoung,项目名称:quokka,代码行数:57,代码来源:views.py
示例7: get
def get(self, long_slug):
context = self.get_context(long_slug)
if isinstance(context, collections.Callable):
return context
return render_template(
self.get_template_names(),
theme=self.content.get_themes(),
**context
)
开发者ID:nleite,项目名称:quokka,代码行数:9,代码来源:views.py
示例8: process_pipeline
def process_pipeline(self):
if not self.items:
return render_template('cart/empty_cart.html',
url=self.continue_shopping_url)
pipelines = self.build_pipeline()
index = session.get('cart_pipeline_index', 0)
pipeline = import_string(pipelines[index])
return pipeline(self, pipelines, index)._preprocess()
开发者ID:mrshinobi,项目名称:quokka-cart,代码行数:9,代码来源:models.py
示例9: method_not_allowed_page
def method_not_allowed_page(error):
"""
The method specified in the Request-Line is not allowed for the
resource
identified by the Request-URI. The response MUST include an
Allow header
containing a list of valid methods for the requested resource.
"""
return render_template("errors/method_not_allowed.html"), 405
开发者ID:BlazeMediaGroup,项目名称:quokka,代码行数:9,代码来源:error_handlers.py
示例10: get
def get(self, pretty_slug, render_content=False):
context = self.get_context_by_pretty_slug(pretty_slug, render_content)
if not render_content and isinstance(context, collections.Callable):
return context
return render_template(
self.get_template_names(),
theme=self.question.get_themes(),
**context
)
开发者ID:munum,项目名称:quokka,代码行数:9,代码来源:views.py
示例11: dispatch_aliases
def dispatch_aliases():
"""
When ALIASES_ENABLED == True
This method handle 3 QuokkaCMS features:
1. Fixed aliases
Alias is defined in ALIASES_MAP setting as a dictionary
2. Managed Redirects
Alias defined in database
3. Channel and Content aliases
Alias defined in specific channel or content
ALIASES_MAP
keys are long_slug
keys should always start with /
& end with / or extension.
{
"/team/": {
"alias_type": "endpoint|long_slug|url|string|template",
"action": "redirect|render",
"to": "authors|/articles/science.html|http://t.co|'<b>Hello</b>'",
"published": True,
"available_at": "",
"available_until: "",
}
}
- 'endpoint' and 'long_slug' by default are rendered
- 'url' is always redirect
- 'string' and 'template' are always rendered
"""
app = current_app
aliases_map = app.config.get("ALIASES_MAP")
if aliases_map and request.path in aliases_map:
alias = aliases_map[request.path]
status = alias.get("status", 200)
if alias["alias_type"] == "endpoint":
endpoint = alias["to"]
if alias.get("action") == "redirect":
return redirect(url_for(endpoint, **request.args))
else: # render
return app.process_response(app.make_response(app.view_functions[endpoint]()))
elif alias["alias_type"] == "long_slug":
long_slug = alias["to"]
if alias.get("action") == "redirect":
return redirect(long_slug) # pass request.args ?
else: # render
endpoint = route_from(long_slug)[0]
return app.process_response(app.make_response(app.view_functions[endpoint]()))
elif alias["alias_type"] == "url":
return redirect(alias["to"])
elif alias["alias_type"] == "string":
return render_template_string(alias["to"]), status
elif alias["alias_type"] == "template":
return render_template(alias["to"]), status
开发者ID:quokkaproject,项目名称:quokka,代码行数:56,代码来源:aliases.py
示例12: get
def get(self):
"""
Fixme: Should include extra paths, fixed paths
config based paths, static paths
"""
return render_template(
'sitemap.xml',
contents=self.get_contents(),
channels=self.get_channels()
)
开发者ID:Cetids,项目名称:quokka,代码行数:10,代码来源:views.py
示例13: get
def get(self):
user = get_current_user()
context = {}
for link in user.links:
context[link.icon] = link.link
return self.needs_login() or render_template(
'accounts/profile_edit.html',
form=self.form(instance=user),
**context
)
开发者ID:Madankapoor,项目名称:quokka,代码行数:10,代码来源:views.py
示例14: __call__
def __call__(self, *args, **kwargs):
html = super(PrepopulatedText, self).__call__(*args, **kwargs)
slave = args[0].id
if self.master:
html += render_template(
'admin/custom/prepopulated.html',
theme=current_app.config.get('ADMIN_THEME', 'cosmo'),
master=self.master,
slave=slave
)
return html
开发者ID:BlazeMediaGroup,项目名称:quokka,代码行数:11,代码来源:widgets.py
示例15: render
def render(self, template, **kwargs):
# Store self as admin_view
kwargs['admin_view'] = self
kwargs['admin_base_template'] = self.admin.base_template
# Provide i18n support even if flask-babel is not installed or enabled.
kwargs['_gettext'] = gettext
kwargs['_ngettext'] = ngettext
kwargs['h'] = h
# Contribute extra arguments
kwargs.update(self._template_args)
return render_template(template, **kwargs)
开发者ID:sant0sh,项目名称:quokka,代码行数:11,代码来源:models.py
示例16: __call__
def __call__(self, *args, **kwargs):
html = super(PrepopulatedText, self).__call__(*args, **kwargs)
slave = args[0].id
if self.master:
html += render_template(
"admin/custom/prepopulated.html",
theme=current_app.config.get("ADMIN_TEHME", "admin"),
master=self.master,
slave=slave,
)
return html
开发者ID:zhangst23,项目名称:tutorial,代码行数:11,代码来源:widgets.py
示例17: confirmation
def confirmation(self): # redirect_url
context = {}
transaction_param = self.config.get(
'transaction_param',
self.pg.config.get('TRANSACTION_PARAM', 'transaction_id')
)
transaction_code = request.args.get(transaction_param)
if transaction_code:
context['transaction_code'] = transaction_code
response = self.pg.check_transaction(transaction_code)
logger.debug(response.xml)
reference = getattr(response, 'reference', None)
if not reference:
logger.error("no reference found")
return render_template('cart/simple_confirmation.html',
**context)
PREFIX = self.pg.config.get('REFERENCE_PREFIX', '') or ''
PREFIX = PREFIX.replace('%s', '')
status = getattr(response, 'status', None)
# TODO: get grossAmount to populate a payment with methods
try:
self.cart = Cart.objects.get(
reference_code=reference.replace(PREFIX, '')
)
self.cart.set_status(
self.STATUS_MAP.get(str(status), self.cart.status)
)
self.cart.transaction_code = transaction_code
msg = "Status changed to: %s" % self.cart.status
self.cart.addlog(msg)
context['cart'] = self.cart
logger.info("Cart updated")
return render_template('cart/confirmation.html', **context)
except Exception as e:
msg = "Cart not found: {} - {}".format(reference, e)
logger.error(msg)
return render_template('cart/simple_confirmation.html', **context)
开发者ID:mpmedia,项目名称:quokka-cart,代码行数:41,代码来源:pagseguro_processor.py
示例18: forbidden_page
def forbidden_page(error):
"""
The server understood the request, but is refusing to fulfill it.
Authorization will not help and the request SHOULD NOT be repeated.
If the request method was not HEAD and the server wishes to make public
why the request has not been fulfilled, it SHOULD describe the
reason for
the refusal in the entity. If the server does not wish to make this
information available to the client, the status code 404 (Not Found)
can be used instead.
"""
return render_template("errors/access_forbidden.html"), 403
开发者ID:BlazeMediaGroup,项目名称:quokka,代码行数:12,代码来源:error_handlers.py
示例19: page_not_found
def page_not_found(error):
"""
The server has not found anything matching the Request-URI.
No indication
is given of whether the condition is temporary or permanent.
The 410 (Gone)
status code SHOULD be used if the server knows, through some internally
configurable mechanism, that an old resource is permanently unavailable
and has no forwarding address. This status code is commonly used when
the
server does not wish to reveal exactly why the request has been
refused,
or when no other response is applicable.
"""
return render_template("errors/page_not_found.html"), 404
开发者ID:BlazeMediaGroup,项目名称:quokka,代码行数:15,代码来源:error_handlers.py
示例20: post
def post(self, long_slug):
context = self.get_context(long_slug)
form = context.get('form')
if form.validate():
comment = Comment()
form.populate_obj(comment)
content = context.get('content')
content.comments.append(comment)
content.save()
return redirect(url_for('.detail', long_slug=long_slug))
return render_template('content/detail.html', **context)
开发者ID:Motoma,项目名称:quokka,代码行数:15,代码来源:views.py
注:本文中的quokka.core.templates.render_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论