本文整理汇总了Python中basic.blog.models.Settings.get_current方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get_current方法的具体用法?Python Settings.get_current怎么用?Python Settings.get_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basic.blog.models.Settings
的用法示例。
在下文中一共展示了Settings.get_current方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_result_item
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def post_result_item(post):
'''Generates the item result object for django-springsteen integration.'''
return {
'title': post.title,
'url': build_url(Settings.get_current().site.domain) + post.get_absolute_url(),
'text': post.body,
}
示例2: post_list
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def post_list(request, page=0, paginate_by=20, **kwargs):
page_size = Settings.get_current().page_size
return list_detail.object_list(
request, queryset=Post.objects.published(), paginate_by=page_size, page=page, **kwargs
)
示例3: post_result_item
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def post_result_item(post):
"""Generates the item result object for django-springsteen integration."""
return {
"title": post.title,
"url": build_url(Settings.get_current().site.domain) + post.get_absolute_url(),
"text": post.body,
}
示例4: result_item
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def result_item(proxy):
"""Generates the item result object."""
if proxy.content_type.name == "bookmark":
url = proxy.content_object.get_absolute_url()
else:
url = build_url(Settings.get_current().site.domain) + proxy.content_object.get_absolute_url()
return {"title": proxy.title, "url": url, "text": proxy.description}
示例5: server_error
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def server_error(request, template_name='500.html'):
"""Handles displaying 500 server error page along with application MEDIA."""
t = loader.get_template(template_name)
blog_settings = Settings.get_current()
return http.HttpResponseServerError(t.render(Context({
"MEDIA_URL": settings.MEDIA_URL,
"STATIC_URL": settings.STATIC_URL,
"BLOG_SETTINGS": blog_settings,
})))
示例6: result_item
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def result_item(proxy):
"""Generates the item result object."""
if proxy.content_type.name == 'bookmark':
url = proxy.content_object.get_absolute_url()
else:
url = build_url(Settings.get_current().site.domain) + proxy.content_object.get_absolute_url()
return {
'title': proxy.title,
'url': url,
'text': proxy.description,
}
示例7: home_list
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def home_list(request, page=0, template_name="proxy/proxy_list.html", **kwargs):
"""
Homepage.
Template: ``proxy/proxy_list.html``
Context:
object_list
Aggregated list of Proxy instances (post, quote, bookmark).
"""
posts = Proxy.objects.published().order_by("-pub_date")
pagesize = Settings.get_current().page_size or 20
return list_detail.object_list(
request, queryset=posts, paginate_by=pagesize, page=page, template_name=template_name, **kwargs
)
示例8: blog_settings
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def blog_settings(request):
"""
Adds settings information to the context.
To employ, add the basic_settings method reference to your project
settings TEMPLATE_CONTEXT_PROCESSORS.
Example:
TEMPLATE_CONTEXT_PROCESSORS = (
...
"basic.blog.context_processors.blog_settings",
)
"""
blog_settings = Settings.get_current()
return {"BLOG_SETTINGS": blog_settings}
示例9: home_list
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def home_list(request, page=0, template_name='proxy/proxy_list.html', **kwargs):
'''
Homepage.
Template: ``proxy/proxy_list.html``
Context:
object_list
Aggregated list of Proxy instances (post, quote, bookmark).
'''
posts = Proxy.objects.published().select_related('content_type').order_by('-pub_date')
pagesize = getattr(Settings.get_current(), 'page_size', 20)
paginator = Paginator(posts, pagesize)
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1
try:
current_page = paginator.page(page)
except (EmptyPage, InvalidPage):
current_page = paginator.page(paginator.num_pages)
items = list(current_page.object_list)
counter = 0
model_map = {}
for item in items:
model_map.setdefault(item.content_type, []).append(item.object_id)
for ct, items_ in model_map.items():
for o in ct.model_class().objects.select_related() \
.filter(id__in=items_).all():
items[counter].content_object = o
counter += 1
return render_to_response(template_name, {
'object_list': items,
'page': page,
'paginate_by': pagesize,
}, context_instance=RequestContext(request))
示例10: home_list
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def home_list(request, page=0, template_name='proxy/proxy_list.html', **kwargs):
'''
Homepage.
Template: ``proxy/proxy_list.html``
Context:
object_list
Aggregated list of Proxy instances (post, quote, bookmark).
'''
posts = Proxy.objects.published().order_by('-pub_date')
pagesize = getattr(Settings.get_current(), 'page_size', 20)
return list_detail.object_list(
request,
queryset = posts,
paginate_by = pagesize,
page = page,
template_name = template_name,
**kwargs
)
示例11: settings
# 需要导入模块: from basic.blog.models import Settings [as 别名]
# 或者: from basic.blog.models.Settings import get_current [as 别名]
def settings(self):
if self._settings is None:
self._settings = Settings.get_current()
return self._settings