Пример #1
0
from flask import g
from app import admin
from models import User, Track, Analysis
from flask.ext.superadmin import model

# Register the admin views/models
class UserAdminModel(model.ModelAdmin):
    list_display = ('name','email', 'last_seen')

    def is_accessible(self):
        return g.user.is_authenticated() and g.user.role == 1 #must be admin

class TrackAdminModel(model.ModelAdmin):
    list_display = ('author','timestamp', 'weight')

    #i'd like to return all of the users posts here instead so the can edit, need to figure out how to do that. But would also need to fix text box thing.

    def is_accessible(self):
        return g.user.is_authenticated() and g.user.role == 1 #must be admin. 

class AnalysisAdminModel(model.ModelAdmin):
    list_display = ('author', 'timestamp')

    def is_accessible(self):
        return g.user.is_authenticated() and g.user.role == 1 #must be admin. 

admin.register(Analysis, AnalysisAdminModel)
admin.register(User, UserAdminModel)
admin.register(Track, TrackAdminModel)
Пример #2
0
from app.admin import register

# Register your models here.

register(__name__, globals())
Пример #3
0

 	



'''
admin.add_view(ModelView(Inmate,db.session))
admin.add_view(ModelView(Inmate,db.session))
admin.add_view(ModelView(Inmate,db.session))
'''




'''
from .models import *

admin.register(Inmate,session=db.session)
admin.register(NextOfKin,session=db.session)
admin.register(PostalAddress,session=db.session)
admin.register(ResidentialAddress,session=db.session)
admin.register(PenalRecord,session=db.session)
admin.register(PreviousConviction	,session=db.session)
admin.register(Discharge,session=db.session)
admin.register(Property,session=db.session)
admin.register(Transfer	,session=db.session)
'''