本文整理汇总了Python中core.models.Blog.select方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.select方法的具体用法?Python Blog.select怎么用?Python Blog.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.Blog
的用法示例。
在下文中一共展示了Blog.select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: system_delete_theme
# 需要导入模块: from core.models import Blog [as 别名]
# 或者: from core.models.Blog import select [as 别名]
def system_delete_theme(theme_id):
user = auth.is_logged_in(request)
permission = auth.is_sys_admin(user)
# TODO: attach an installing user to the theme
# allow that user to delete
tags = template_tags(user=user)
from core.models import Theme
from settings import BASE_URL
from core.utils import Status
theme = Theme.load(theme_id)
if request.forms.getunicode('confirm') == user.logout_nonce:
from settings import THEME_FILE_PATH # , _sep
import shutil, os
shutil.rmtree(os.path.join(THEME_FILE_PATH, theme.json))
theme.delete_instance()
status = Status(
type='success',
close=False,
message='''
Theme <b>{}</b> was successfully deleted from the system.</p>
'''.format(theme.for_log),
action='Return to theme list',
url='{}/system/themes'.format(
BASE_URL)
)
else:
m1 = '''You are about to remove theme <b>{}</b>. <b>THIS ACTION CANNOT BE UNDONE.</b></p>
'''.format(theme.for_display)
blogs_with_theme = Blog.select().where(
Blog.theme == theme_id)
if blogs_with_theme.count() > 0:
used_in = []
for n in blogs_with_theme:
used_in.append("<li>{}</li>".format(n.for_display))
m2 = '''<p>This theme is in use by the following blogs:<ul>{}</ul>
Deleting this theme may <i>break these blogs entirely!</i></p>
'''.format(
''.join(used_in))
else:
m2 = ''
status = Status(
type='warning',
close=False,
message=m1 + m2,
url='{}/system/theme/{}/delete'.format(
BASE_URL, theme.id),
yes={'id':'delete',
'name':'confirm',
'label':'Yes, I want to delete this theme',
'value':user.logout_nonce},
no={'label':'No, don\'t delete this theme',
'url':'{}/system/themes'.format(
BASE_URL)}
)
tags.status = status
return report(tags, 'system_delete_theme', theme)