本文整理汇总了Python中flask_peewee.admin.Admin.register_panel方法的典型用法代码示例。如果您正苦于以下问题:Python Admin.register_panel方法的具体用法?Python Admin.register_panel怎么用?Python Admin.register_panel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_peewee.admin.Admin
的用法示例。
在下文中一共展示了Admin.register_panel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageAdmin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register_panel [as 别名]
class MessageAdmin(ModelAdmin):
columns = ('user', 'content', 'pub_date',)
class NoteAdmin(ModelAdmin):
columns = ('user', 'message', 'created_date',)
auth.register_admin(admin)
admin.register(AModel, AAdmin)
admin.register(BModel, BAdmin)
admin.register(CModel, CAdmin)
admin.register(DModel, DAdmin)
admin.register(BDetails)
admin.register(Message, MessageAdmin)
admin.register(Note, NoteAdmin)
admin.register_panel('Notes', NotePanel)
class UserResource(RestResource):
exclude = ('password', 'email',)
def get_query(self):
return User.filter(active=True)
class AResource(RestResource):
pass
class BResource(RestResource):
include_resources = {'a': AResource}
class CResource(RestResource):
示例2: get_context
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register_panel [as 别名]
def get_context(self):
ins = celery.control.inspect()
return {
"scheduled_tasks": ins.scheduled(),
"active_tasks": ins.active()
}
class ConfigAdmin(ModelAdmin):
columns = ("name", "value")
class TweetAdmin(ModelAdmin):
columns = ("id", "created_at", "tweeted_by", "text", "score")
class UserAdmin(ModelAdmin):
columns = ("username", "email", "admin")
admin = Admin(app, auth, branding="Power Poetry Twitter Demo")
admin.register(Config, ConfigAdmin)
admin.register(Tweet, TweetAdmin)
admin.register(User, UserAdmin)
admin.register_panel("Celery Tasks", TasksPanel)
admin.setup()
示例3: get_context
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register_panel [as 别名]
def get_context(self):
last_week = datetime.datetime.now() - datetime.timedelta(days=7)
signups_this_week = User.select().where(User.join_date > last_week).count()
messages_this_week = Message.select().where(Message.pub_date > last_week).count()
return {
'signups': signups_this_week,
'messages': messages_this_week,
}
admin = Admin(app, auth, branding='Admin the boat')
class MessageAdmin(ModelAdmin):
columns = ('user', 'content', 'pub_date',)
foreign_key_lookups = {'user': 'username'}
filter_fields = ('user', 'content', 'pub_date', 'user__username')
class NoteAdmin(ModelAdmin):
columns = ('user', 'message', 'created_date',)
exclude = ('created_date',)
auth.register_admin(admin)
#admin.register(Relationship)
admin.register(Message, MessageAdmin)
admin.register(Note, NoteAdmin)
admin.register_panel('Notes', NotePanel)
admin.register_panel('User stats', UserStatsPanel)
示例4: NoteAdmin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register_panel [as 别名]
columns = ("user", "content", "pub_date")
class NoteAdmin(ModelAdmin):
columns = ("user", "message", "created_date")
auth.register_admin(admin)
admin.register(AModel, AAdmin)
admin.register(BModel, BAdmin)
admin.register(CModel, CAdmin)
admin.register(DModel, DAdmin)
admin.register(BDetails)
admin.register(Message, MessageAdmin)
admin.register(Note, NoteAdmin)
admin.register_panel("Notes", NotePanel)
class UserResource(RestResource):
exclude = ("password", "email")
def get_query(self):
return User.select().where(User.active == True)
class AResource(RestResource):
pass
class BResource(RestResource):
include_resources = {"a": AResource}