當前位置: 首頁>>代碼示例>>Python>>正文


Python admin.Admin類代碼示例

本文整理匯總了Python中flask_peewee.admin.Admin的典型用法代碼示例。如果您正苦於以下問題:Python Admin類的具體用法?Python Admin怎麽用?Python Admin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Admin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_app

def create_app(settings_override=None):
    app = factory.create_app(__name__, __path__, settings_override)

    admin = Admin(app, auth)
    register_admin(admin)
    admin.setup()
    return app
開發者ID:shanzi,項目名稱:code-vilya,代碼行數:7,代碼來源:__init__.py

示例2: setup_admin

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,代碼行數:8,代碼來源:admin.py

示例3: CharField

    description = CharField(max_length=2000, null=True)
    url = CharField()
    price = DecimalField(max_digits=10, decimal_places=2)
    wishlist = ForeignKeyField(WishList, related_name='items')
    numberOfParts = IntegerField()

class Part(db.Model):
    """
    A part is the smallest subdivision of an item.
    Thanks to this, an item can be bought by several different users.
    """
    user = ForeignKeyField(auth.User, related_name='gifts')
    item = ForeignKeyField(Item, related_name='parts')

# admin part
admin = Admin(app, auth)

admin.register(WishList)
admin.register(Item)
admin.register(Part)


# api part
user_auth = UserAuthentication(auth)
api = RestAPI(app, default_auth=user_auth)

api.register(WishList)
api.register(Item, ItemResource)
api.register(Part)

# setup
開發者ID:Grimbox,項目名稱:gwift,代碼行數:31,代碼來源:gwift.py

示例4: Admin

# -*- 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,代碼行數:16,代碼來源:admin.py

示例5: Admin

from flask_peewee.admin import Admin, ModelAdmin

from app import app, db
from auth import auth
from models import User, Location, Acl
from pbkdf2 import hashing_passwords as hp

admin = Admin(app, auth, branding='ownTracks')

# Check for existing admin user and in none
# exists create one
# TODO: Show flash message for newly created
# admin user
try:
    test_admin = User.get(User.username == 'admin')
except: 
    # No Admin user yet, so create one
    test_admin = auth.User(username='admin', email='', admin=True, active=True, superuser=True)
    test_admin.set_password('admin')
    test_admin.save()

# or you could admin.register(User, ModelAdmin) -- you would also register
# any other models here.

class LocationAdmin(ModelAdmin):
    columns = ('tst', 'username', 'device', 'lat', 'lon', )

class UserAdmin(ModelAdmin):
    columns = ('username', 'superuser', 'pbkdf2',)
開發者ID:RustyDust,項目名稱:backend,代碼行數:29,代碼來源:admin.py

示例6: DateField

    day = DateField(default=datetime.date.today, unique=True, verbose_name="Dzien")
    soup = CharField(null=True, verbose_name="Zupa")
    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()
開發者ID:Stasioo98D,項目名稱:serwer,代碼行數:31,代碼來源:myflaskapp.py

示例7: redirect

            if request.form.get('message'):
                Note.create(
                    user=auth.get_logged_in_user(),
                    message=request.form['message'],
                )
        next = request.form.get('next') or self.dashboard_url()
        return redirect(next)
    
    def get_context(self):
        return {
            'note_list': Note.select().order_by(('created_date', 'desc')).paginate(1, 3)
        }


auth = Auth(app, db, user_model=User)
admin = Admin(app, auth)


class AAdmin(ModelAdmin):
    columns = ('a_field',)

class BAdmin(ModelAdmin):
    columns = ('a', 'b_field',)
    include_foreign_keys = {'a': 'a_field'}

class CAdmin(ModelAdmin):
    columns = ('b', 'c_field',)
    include_foreign_keys = {'b': 'b_field'}

class DAdmin(ModelAdmin):
    columns = ('c', 'd_field',)
開發者ID:dahool,項目名稱:flask-peewee,代碼行數:31,代碼來源:test_app.py

示例8: EntryAdmin

from flask import request, redirect
from auth import auth

from models import *
from app import app, psql_db

class EntryAdmin(ModelAdmin):
    columns = ('title', 'publishdate', 'recipe', 'private')
    def get_query(self):
    	return Entry.select().order_by(-Entry.publishdate)

class UserAdmin(ModelAdmin):
    columns = ('username', 'email',  'twitter', 'admin', 'active')

class RecipeAdmin(ModelAdmin):
    def get_query(self):
    	return Recipe.select().order_by(Recipe.slug)

class PageAdmin(ModelAdmin):
    def get_query(self):
    	return Page.select().order_by(-Page.publishdate)

admin = Admin(app, auth, branding = "Carboy admin")

auth.register_admin(admin)
admin.register(Entry, EntryAdmin)
admin.register(Page, PageAdmin)
admin.register(Recipe, RecipeAdmin)
admin.register(User, UserAdmin)

admin.setup()
開發者ID:tommeagher,項目名稱:Carboy,代碼行數:31,代碼來源:admin.py

示例9: Admin

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,代碼行數:14,代碼來源:admin.py

示例10: UserView

from flask_peewee.admin import Admin, ModelAdmin
from app import app
from auth import auth
from models import User


class UserView(ModelAdmin):
    columns = ('username', 'email',)

admin = Admin(app, auth)
auth.register_admin(admin)
admin.register(User, UserView)
admin.setup()
開發者ID:01walid,項目名稱:Gobolino,代碼行數:13,代碼來源:admin.py

示例11: CarAdmin

from flask_peewee.admin import Admin, ModelAdmin

from app import app, db
from auth import auth
from models import *

class CarAdmin(ModelAdmin):
    columns = ('user', 'vehicle_id', 'model', 'year', 'name', 'picture');

class CommuteAdmin(ModelAdmin):
    columns = ('car', 'trip_mpg', 'trip_milage', 'duration')

class CBSMessageAdmin(ModelAdmin):
    columns = ('car', 'type', 'state', 'description', 'remaining_mileage', 'due_date', 'update_time')

class CCMMessageAdmin(ModelAdmin):
    columns = ('car', 'ccm_id', 'mileage', 'description', 'update_time')

class RawDataAdmin(ModelAdmin):
    columns = ('car', 'update_time', 'tank_level', 'fuel_range', 'fuel_reserve', 'odometer', 'ave_mpg', 'headlights', 'speed', 'engine_status')

admin = Admin(app, auth)
auth.register_admin(admin)
admin.register(Car, CarAdmin)
admin.register(RawData, RawDataAdmin)
admin.register(CCMMessage, CCMMessageAdmin)
admin.register(CBSMessage, CBSMessageAdmin)
admin.register(Commute, CommuteAdmin)
開發者ID:dolphin78,項目名稱:personalizeddrive,代碼行數:28,代碼來源:admin.py

示例12: UserStatsPanel

        }

class UserStatsPanel(AdminPanel):
    template_name = 'admin/user_stats.html'

    def get_context(self):
        last_week = datetime.datetime.now() - datetime.timedelta(days=7)
        signups_this_week = User.filter(join_date__gt=last_week).count()
        messages_this_week = Message.filter(pub_date__gt=last_week).count()
        return {
            'signups': signups_this_week,
            'messages': messages_this_week,
        }


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',)
開發者ID:jade-bot,項目名稱:pinche,代碼行數:31,代碼來源:admin.py

示例13: home

        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,代碼行數:31,代碼來源:test.py

示例14: flash

    if form.validate_on_submit():
        flash("User Created", "success")
        models.Taco.create(user=g.user._get_current_object(),
                           phoneNumber=form.phoneNumber.data,
                           fullName=form.fullName.data,
                           email=form.email.data,
                           member=form.member.data)

        return redirect(url_for('signIn'))
    return render_template('signup.html', form=form)




if __name__ == '__main__':
    models.initialize()
    admin = Admin(app, name="Temple")
    admin.add_view(MyModelView(models.User))
    admin.add_view(MyModelView(models.Taco, name="Member Info"))
    admin.add_view(MyModelView(models.Check))


    try:
        models.User.create_user(
            email='[email protected]',
            password='password',
            admin = True
        )
    except ValueError:
        pass
    app.run(debug=DEBUG, host=HOST, port=PORT)
開發者ID:arraypan,項目名稱:BTLibrary-,代碼行數:31,代碼來源:checkin.py

示例15: init_admin

def init_admin(app, auth, models):
    admin = Admin(app, auth)
    for model in models:
        admin.register(model)
    admin.setup()
開發者ID:michaeljoseph,項目名稱:erlenmeyer,代碼行數:5,代碼來源:extension.py


注:本文中的flask_peewee.admin.Admin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。