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
def setup_admin(): auth = Auth(app, db, user_model=User) admin = Admin(app, auth) admin.register(User, UserAdmin) admin.register(Photo, PhotoAdmin) auth.register_admin(admin) admin.setup() return auth, admin
def init_admin(app, db): auth_admin = Auth(app, db) User = auth_admin.User User.create_table(fail_silently=True) if not User.select().where(User.username == 'admin').exists(): admin = User(username='******', email='', admin=True, active=True) admin.set_password('admin') admin.save() admin = Admin(app, auth_admin) from hse_arch.models.customer import Customer from hse_arch.models.order import Order, OrderItem from hse_arch.models.product import Product, ProductIngredient, Ingredient from hse_arch.models.producers import Producer from hse_arch.models.category import Category from hse_arch.models.user import User admin.register(Customer, CustomerAdmin) admin.register(Order) admin.register(OrderItem) admin.register(Product) admin.register(Ingredient) admin.register(Producer) admin.register(Category) admin.register(ProductIngredient) admin.register(User) admin.setup() return admin
def create_app(): app = Flask(__name__) app.config.update( DEBUG=True, SECRET_KEY='supersecret', DATABASE={ 'name': 'example.db', 'engine': 'peewee.SqliteDatabase', }, ) app.db = Database(app) Feedloggr(app, app.db) # OPTIONALLY SETUP BEGINS # Simple authentication for the admin interface app.auth = Auth(app, app.db) app.auth.User.create_table(fail_silently=True) # Try to create a new admin user, but fail silently if it already exists try: user = app.auth.User.create( username='******', email='.', password='', admin=True, active=True, ) except PIE: pass else: user.set_password('admin') user.save() # Initialize the admin interface app.admin = Admin(app, app.auth) app.auth.register_admin(app.admin) # Register the feedloggr feeds model app.admin.register(feedloggr_Feeds, feedloggr_FeedsAdmin) app.admin.setup() # OPTIONALLY SETUP ENDS return app
def index(): auth = Auth(app, models.DATABASE)
from flask_peewee.auth import Auth from flask_peewee.db import Database #from utils import slugify DATABASE = { 'name':'test.db', 'engine':'peewee.SqliteDatabase', } DEBUG = True SECRET_KEY = 'ssshhhh' app = Flask(__name__) app.config.from_object(__name__) db = Database(app) auth = Auth(app, db) # Models user = auth.get_user_model() class Task(db.Model): task = pw.TextField() user = pw.ForeignKeyField(user) created = pw.DateTimeField(default=datetime.datetime.now) due = pw.DateField() @property def tags(self): return Tag.select().join(TaskTag).join(Task).where(Task.id == self.id)
app.config.suppress_callback_exceptions = True # app.css.config.serve_locally = True # app.scripts.config.serve_locally = True app.title = 'Test Dash Project' server = app.server DATABASE = { 'name': DB_NAME, 'engine': 'peewee.SqliteDatabase', } SECRET_KEY = SECRET_KEY_SERVER server.config.from_object(__name__) db = DataBase(server) auth = Auth(app=server, db=db, user_model=Users) admin = Admin(app=server, auth=auth) admin.register(model=Cities) admin.register(model=Date) admin.register(model=Devices) admin.register(model=HoursInDay) admin.register(model=PageViewsByDevices) admin.register(model=RegionsMap) admin.register(model=TrafficSource) admin.register(model=Users) admin.register(model=VisitsCountByHour) admin.register(model=VisitsCountByTrafficSource) admin.setup() # Setup the LoginManager for the server
# -*- coding: utf-8 -*- from app import app from database import db from models import User from flask_peewee.auth import Auth auth = Auth(app, db, user_model=User, prefix='')
# file that contains the authentication system used to provide security to the admin interface from flask_peewee.auth import Auth # Login/logout views, etc. from app import app from models import User, db # instantiate an Auth object for use with flask app and database wrapper auth = Auth(app, db, user_model = User)
from flask import Flask, render_template, redirect, url_for, jsonify from flask_peewee.auth import Auth from flask_peewee.db import Database from flask_peewee.admin import Admin from werkzeug import secure_filename app = Flask(__name__) app.config.from_pyfile('config.py') db = Database(app) auth = Auth(app, db) admin = Admin(app, auth) import models @app.route('/nodos.json') def main(): return jsonify(models.generar_diccionario_nodos()) @app.route('/') def main(): return render_template('test.html', json_data=models.generar_diccionario_nodos()) if __name__ == "__main__": auth.register_admin(admin) admin.register(models.Cooperativa) admin.register(models.Federacion) admin.register(models.CoopFederacion) admin.setup() app.run(host='0.0.0.0')
# -*- coding: utf-8 -*- """ User authentification. """ from flask_peewee.auth import Auth from app import app from database import database from user import User # # Authentification object. # Note: we are providing our own user model, as we want to customize some fields # but we could just relay on an user model 'automagically' generated # by Auth, see Auth.get_user_model(). # auth = Auth(app, database, user_model=User, prefix='')
'العربيه', 'العربية', 'Get Started', 'Unsubscribe', } # Set up flask application app = flask.Flask(__name__) app.config['SECRET_KEY'] = 'super-secret' app.config['DATABASE'] = { 'name': 'labeled_data.db', 'engine': 'peewee.SqliteDatabase', } db = Database(app) auth = Auth(app, db, db_table='annotators') class Conversation(db.Model): id = IntegerField(primary_key=True) annotator = ForeignKeyField(auth.User, backref='conversations', on_delete='SET NULL') completed = BooleanField(default=False) class Message(db.Model): conversation = ForeignKeyField(Conversation, backref='messages') number = IntegerField() content = TextField() category = CharField(null=True) subcategory = CharField(null=True)
if request.method == 'POST': 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):
# -*- coding: utf-8 -*- # Copyright (C) 2013-2014 Avencall # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> from flask_peewee.auth import Auth from app import app, db auth = Auth(app, db) admin_auth = auth.User(username='******', email='*****@*****.**', admin=True, active=True) admin_auth.set_password('admin') admin_auth.save()
from psyc import database from psyc import app from flask_peewee.auth import Auth auth = Auth(app, database.db)
from flask_peewee.auth import Auth from flask_peewee.db import Database from utils import slugify DATABASE = { 'name': 'test.db', 'engine': 'peewee.SqliteDatabase', } DEBUG = True SECRET_KEY = 'ssshhhh' app = Flask(__name__) app.config.from_object(__name__) db = Database(app) auth = Auth(app, db) # Models User = auth.get_user_model() class Task(db.Model): task = pw.TextField() user = pw.ForeignKeyField(User) created = pw.DateTimeField(default=datetime.datetime.now) due = pw.DateField() @property def tags(self): return Tag.select().join(TaskTag).join(Task).where(Task.id == self.id)
All rights reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ """ Created on 29/09/2012 """ from flask import Flask from flask_peewee.db import Database from flask_peewee.auth import Auth from pystatus.settings import Configuration application = Flask(__name__) application.config.from_object(Configuration) db = Database(application) auth = Auth(application, db)
if 'uipass' not in datajson or len(datajson['uipass']) == 0: return False if 'credit' not in datajson or len(datajson['credit']) == 0: return False if 'tariff' not in datajson or len(datajson['tariff']) == 0: return False return True # create a special resource for users that excludes email and password class UserResource(RestResource): exclude = ('password', 'email',) # create an Auth object for use with our flask app and database wrapper auth = Auth(app, db) # instantiate the user auth user_auth = UserAuthentication(auth, protected_methods=['GET', 'POST', 'PUT', 'DELETE']) # create a RestAPI container api = RestAPI(app, default_auth=user_auth) # register the models api.register(Card, CardResource, auth=user_auth) api.register(CardGroup, auth=user_auth) api.register(auth.User, UserResource, auth=user_auth) api.setup() admin = Admin(app, auth, branding='A2Billing API Admin Site') admin.register(Card, CardAdmin) admin.register(CardGroup, CardGroupAdmin)
from flask_peewee.auth import Auth from wx.app import app, database from wx.models.user import User auth = Auth(app, database, user_model=User) login_required = auth.login_required
#from flask_admin.contrib.peewee import tools import main import os import models SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__)) print('path:{}'.format(SCRIPT_PATH)) print('db:{}'.format(main.db.database)) app = Flask(__name__) app.config.from_object('config.Configuration') db = Database(app) # database = db.database # create an Auth object for use with our flask app and database wrapper auth = Auth(app, db) #admin = Admin(app, name='HydroPi_test', template_mode='bootstrap3') #admin = Admin(app, name='HydroPi_test', template_mode='bootstrap3', url='/') #admin = Admin(app, name='HydroPi_test', index_view=AdminIndexView(main.PulseData, url='/', endpoint='')) #admin.register(main.PulseData) #admin.add_view(ModelView(main.PulseData)) #admin.setup() # Add administrative views here
app.register_blueprint(static_app.static_app, url_prefix='/%s' % app_config.PROJECT_SLUG) file_handler = logging.FileHandler('%s/app.log' % app_config.SERVER_LOG_PATH) file_handler.setLevel(logging.INFO) app.logger.addHandler(file_handler) app.logger.setLevel(logging.INFO) class SlideAdmin(ModelAdmin): exclude = ('slug', ) # Set up flask peewee db wrapper db = Database(app) auth = Auth(app, db, prefix='/%s/accounts' % app_config.PROJECT_SLUG) admin = Admin(app, auth, prefix='/%s/admin' % app_config.PROJECT_SLUG) admin.register(Slide, SlideAdmin) admin.register(SlideSequence) admin.setup() @app.route('/%s/admin/stack/' % app_config.PROJECT_SLUG, methods=['GET']) def _stack(): """ Administer a stack of slides. """ context = make_context(asset_depth=1) sequence = SlideSequence.select() sequence_dicts = sequence.dicts()
def init_app(self, app): # Инициируем работу с аутентификацией и авторизацией self.extension = Auth(app.web_app, app.db)
# -*- coding: utf-8 -*- from flask_peewee.rest import RestAPI from flask_peewee.admin import Admin from flask_peewee.auth import Auth from app import app from models import Summary, Detail, Description, db from models import SummaryAdmin, DetailAdmin, DescriptionAdmin auth = Auth(app, db) # REST API api = RestAPI(app) api.register(Summary) api.register(Detail) api.register(Description) api.setup() # REST ADMIN admin = Admin(app, auth) admin.register(Summary, SummaryAdmin) admin.register(Detail, DetailAdmin) admin.register(Description, DescriptionAdmin) admin.setup() if __name__ == "__main__": auth.User.create_table(fail_silently=True) admin = auth.User(username='******', email='', admin=True, active=True) admin.set_password('admin') admin.save()