本文整理汇总了Python中flask_peewee.admin.Admin.register方法的典型用法代码示例。如果您正苦于以下问题:Python Admin.register方法的具体用法?Python Admin.register怎么用?Python Admin.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_peewee.admin.Admin
的用法示例。
在下文中一共展示了Admin.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
def setup_admin():
auth = Auth(app, db)
admin = Admin(app, auth)
admin.register(Note, NoteAdmin)
admin.register(Author, AuthorAdmin)
auth.register_admin(admin)
admin.setup()
return auth, admin
示例2: Admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
from flask import session
from flask_peewee.admin import Admin
from web.app import app, auth
from web.model import Label, Inspiration, LabelInspirationRelationShip
admin = Admin(app, auth)
register_class = [Label, Inspiration, LabelInspirationRelationShip, auth.User]
for klass in register_class:
admin.register(klass)
admin.setup()
示例3: DAdmin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
columns = ('b', 'c_field',)
include_foreign_keys = {'b': 'b_field'}
class DAdmin(ModelAdmin):
columns = ('c', 'd_field',)
include_foreign_keys = {'c': 'c_field'}
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)
示例4: Flask
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
'name': 'database.db',
'engine': 'peewee.SqliteDatabase',
}
DEBUG = True
SECRET_KEY = 'bleubleu'
# Lancement de l'application
app = Flask(__name__)
app.config.from_object(__name__)
db = Database(app)
auth = Auth(app, db)
from room_service.models import Room, RoomAdmin
import room_service.views
# Admin interface #
admin = Admin(app, auth)
admin.register(Room, RoomAdmin)
auth.register_admin(admin)
admin.setup()
# Assets
assets = Environment(app)
assets.url = app.static_url_path
scss = Bundle('main.scss', filters='pyscss', output='main.css')
assets.register('scss_all', scss)
示例5: save_model
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
return PhotoForm
def save_model(self, instance, form, adding=False):
instance = super(PhotoAdmin, self).save_model(instance, form, adding)
if 'image_file' in request.files:
file = request.files['image_file']
instance.save_image(file)
return instance
class TagAdmin(ModelAdmin):
columns = ['tag']
class PhotoTagsAdmin(ModelAdmin):
columns = ['tags', 'photo']
admin = Admin(app,auth)
auth.register_admin(admin)
admin.register(Note, NoteAdmin)
admin.register(Articles,Article_Custom_Admin)
admin.register(Photo, PhotoAdmin)
admin.register(Tag, TagAdmin)
admin.register(PhotoTags, PhotoTagsAdmin)
admin.register_panel('Notes', NotePanel)
示例6: Admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
from flask_peewee.admin import Admin
from gistsurfr.app import app, db
from gistsurfr.auth import auth
from gistsurfr.models import User, UserRelationship, UserGithub, UserGistFavorite
admin = Admin(app, auth, branding='Gistsurfr')
auth.register_admin(admin)
admin.register(UserRelationship)
admin.register(UserGithub)
admin.register(UserGistFavorite)
示例7: RelayAdmin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
'''
Modulo di Amministrazione
Accesso all'area admin: http://localhost:8080/admin
'''
from app import app
from auth import auth
from flask_peewee.admin import Admin, ModelAdmin
from models import Relay
class RelayAdmin(ModelAdmin):
'''
Amministrazione Model Relay
'''
columns = ('channel', 'device', 'active',)
"Crea oggetto Admin associandolo ad un'Authenticator"
admin = Admin(app, auth)
auth.register_admin(admin)
"Registra Model"
admin.register(Relay, RelayAdmin)
示例8: get_context
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [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()
示例9: home
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
Model.create_table(fail_silently=True)
user_datastore.create_user(email='[email protected]', password='password')
# Views
@app.route('/')
@login_required
def home():
return render_template('index.html')
# needed for authentication
auth = Auth(app, db)
class MessageAdmin(ModelAdmin):
columns = ('user', 'content', 'pub_date')
class Message(db.Model):
user = ForeignKeyField(User)
content = TextField()
pub_date = DateTimeField(default=datetime.datetime.now)
def __unicode__(self):
return '%s: %s' % (self.user, self.content)
admin = Admin(app, auth)
admin.register(Message, MessageAdmin)
admin.setup()
app.run(host = '0.0.0.0',
port = 8080,
debug = True,
threaded = True)
示例10: Admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
}
admin = Admin(app, auth)
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',)
class CityAdmin(ModelAdmin):
columns = ('name',)
class PincheAdmin(ModelAdmin):
columns = ('city', 'title', 'phone', 'route', 'publisher', 'content',)
exclude = ('pub_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)
admin.register(City, CityAdmin)
admin.register(Pinche, PincheAdmin)
示例11: CityAdmin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
exclude = ('created_date',)
class CityAdmin(ModelAdmin):
columns = ('name',)
class PincheAdmin(ModelAdmin):
columns = ('city', 'title', 'phone', 'route', 'publisher', 'content',)
exclude = ('pub_date',)
class CarBrandAdmin(ModelAdmin):
columns = ('name',)
class CarSeriesAdmin(ModelAdmin):
columns = ('brand', 'name',)
class CarModelAdmin(ModelAdmin):
columns = ('series', 'name',)
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)
admin.register(City, CityAdmin)
admin.register(Pinche, PincheAdmin)
admin.register(CarBrand, CarBrandAdmin)
admin.register(CarSeries, CarSeriesAdmin)
admin.register(CarModel, CarModelAdmin)
示例12: init_admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
def init_admin(app, auth, models):
admin = Admin(app, auth)
for model in models:
admin.register(model)
admin.setup()
示例13: CharField
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
main_dish = CharField(null=True, verbose_name="Drugie danie")
def __str__(self):
return "%s - %s - %s" % (self.day, self.soup, self.main_dish)
Obiad.create_table(fail_silently=True)
class Cytat(db.Model):
timestamp = DateTimeField(default=datetime.datetime.now(), verbose_name="Czas dodania")
content = TextField(unique=True, verbose_name="Tresc")
def __str__(self):
return self.content
Cytat.create_table(fail_silently=True)
auth = Auth(app, db)
auth.User.create_table(fail_silently=True)
admin = Admin(app, auth)
auth.register_admin(admin)
admin.register(Przedmiot)
class PracaDomowaAdmin(ModelAdmin):
columns = ('deadline', 'subject', 'short_name', 'description', 'checked',)
admin.register(PracaDomowa, PracaDomowaAdmin)
class SprawdzianAdmin(ModelAdmin):
columns = ('date', 'subject', 'short_name', 'description', 'done',)
admin.register(Sprawdzian, SprawdzianAdmin)
class ObiadAdmin(ModelAdmin):
columns = ('day', 'soup', 'main_dish',)
admin.register(Obiad, ObiadAdmin)
class CytatAdmin(ModelAdmin):
columns = ('content',)
admin.register(Cytat, CytatAdmin)
admin.setup()
@app.route('/api/add/homework/<password>/<subject>/<int:year>/<int:month>/<int:day>/<long_desc>')
示例14: init_db
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
#
# Register the models available in the admin interface.
#
def init_db():
if not SyncLog.table_exists():
SyncLog.create_table()
if not User.table_exists():
User.create_table()
User.create(username='admin',
password=make_password('admin'),
admin=True)
for mod_class in MASTER_CLASSES.keys():
if not MODELS_CLASS[mod_class].table_exists():
MODELS_CLASS[mod_class].create_table()
for mod_class in sorted(DEPENDENT_CLASSES.keys()):
if not MODELS_CLASS[mod_class].table_exists():
MODELS_CLASS[mod_class].create_table()
init_db()
for mod_class in MODELS_CLASS:
admin.register(MODELS_CLASS[mod_class])
admin.register(User)
# Enable the admin interface.
admin.setup()
示例15: Admin
# 需要导入模块: from flask_peewee.admin import Admin [as 别名]
# 或者: from flask_peewee.admin.Admin import register [as 别名]
# -*- coding: utf-8 -*-
"""
admin imports app, auth and models, but none of these import admin
so we're OK
"""
from flask_peewee.admin import Admin, ModelAdmin
from app import app, db
from auth import auth
from models import User
admin = Admin(app, auth)
# auth.register_admin(admin)
admin.register(User, ModelAdmin)
# register any other models here.