当前位置: 首页>>代码示例>>Python>>正文


Python Admin.register方法代码示例

本文整理汇总了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
开发者ID:fspot,项目名称:flask-peewee-example,代码行数:10,代码来源:admin.py

示例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()
开发者ID:DXDSpirits,项目名称:tatinspiration,代码行数:15,代码来源:admin.py

示例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)
开发者ID:dahool,项目名称:flask-peewee,代码行数:32,代码来源:test_app.py

示例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)
开发者ID:cynddl,项目名称:room-service,代码行数:32,代码来源:__init__.py

示例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)


开发者ID:pouyan-ghasemi,项目名称:flask-sql-cms,代码行数:29,代码来源:admin.py

示例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)
开发者ID:ajduncan,项目名称:gistsurfr,代码行数:16,代码来源:admin.py

示例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)
开发者ID:massimobiagioli,项目名称:raspberrypi,代码行数:24,代码来源:admin.py

示例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()
开发者ID:SumAllFoundation,项目名称:powerpoetry-twitter-demo,代码行数:32,代码来源:admin.py

示例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)
开发者ID:Hellrungj,项目名称:flask-security-admin-example,代码行数:33,代码来源:test.py

示例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)
开发者ID:jade-bot,项目名称:pinche,代码行数:32,代码来源:admin.py

示例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)
开发者ID:lite,项目名称:pinche,代码行数:32,代码来源:admin.py

示例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()
开发者ID:michaeljoseph,项目名称:erlenmeyer,代码行数:7,代码来源:extension.py

示例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>')
开发者ID:Stasioo98D,项目名称:serwer,代码行数:33,代码来源:myflaskapp.py

示例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()
开发者ID:Comunitea,项目名称:CMNT_004_15,代码行数:32,代码来源:admin.py

示例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.
开发者ID:kqdtran,项目名称:rating_prediction,代码行数:18,代码来源:admin.py


注:本文中的flask_peewee.admin.Admin.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。