Exemplo n.º 1
0
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
Exemplo n.º 2
0
class InitAdminDashboard(InitBaseExtension):

    name = 'admin'

    def init_app(self, app):  # Инициируем Админку
        self.extension = Admin(app.web_app, app.auth)

    def configurate_extension(self):

        from ui.admin import get_admin_models

        for m in get_admin_models():
            orm_m, adm_m = m if len(m) == 2 else [m[0], ModelAdmin]
            self.extension.register(orm_m, adm_m)
        self.extension.setup()
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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
Exemplo n.º 7
0
# -*- 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.
Exemplo n.º 8
0
        }

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.select().where(User.join_date > last_week).count()
        messages_this_week = Message.select().where(Message.pub_date > 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': '******'}
    filter_fields = ('user', 'content', 'pub_date', 'user__username')

class NoteAdmin(ModelAdmin):
    columns = ('user', 'message', 'created_date',)
    exclude = ('created_date',)


auth.register_admin(admin)
admin.register(Relationship)
admin.register(Message, MessageAdmin)
Exemplo n.º 9
0
	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
Exemplo n.º 10
0
from flask_peewee.admin import Admin, ModelAdmin

from app import app
from auth import auth
from models import Song

class SongAdmin(ModelAdmin):
    columns = ('title', 'artist', 'album', 'genre', 'path', 'created',)

admin = Admin(app, auth)
admin.register(Song, SongAdmin)
auth.register_admin(admin)


Exemplo n.º 11
0
auth = Auth(app, db)

# REST API
api = RestAPI(app)
api.register(Person)
api.register(Company)
api.register(Payment)
api.register(Tariff)
api.register(Point)
api.register(Bike)
api.register(ReservationState)
api.register(Reservation)
api.setup()

# REST ADMIN
admin = Admin(app, auth)
admin.register(Person, PersonAdmin)
admin.register(Company, CompanyAdmin)
admin.register(Payment, PaymentAdmin)
admin.register(Tariff, TariffAdmin)
admin.register(Point, PointAdmin)
admin.register(Bike, BikeAdmin)
admin.register(ReservationState, ReservationStateAdmin)
admin.register(Reservation, ReservationAdmin)
admin.setup()


def setup_tbl():
    Person.create_table(fail_silently=True)
    Company.create_table(fail_silently=True)
    Payment.create_table(fail_silently=True)
Exemplo n.º 12
0
from flask_peewee.admin import Admin, ModelAdmin

from app import app
from auth import auth
from models import Note


class NoteAdmin(ModelAdmin):
    columns = ('message', 'created',)

admin = Admin(app, auth)
admin.register(Note, NoteAdmin)
auth.register_admin(admin)
admin.setup()

Exemplo n.º 13
0
import datetime
from flask import request, redirect

from flask_peewee.admin import Admin, ModelAdmin, AdminPanel
from flask_peewee.filters import QueryFilter

from app import app, db
from auth import auth
from models import User, News, OursNews

admin = Admin(app, auth)


class NewsAdmin(ModelAdmin):
    columns = ('user', 'text', 'favorited', 'thumbnail_pic', 'bmiddle_pic',
               'original_pic', 'reposts_count', 'comments_count',
               'attitudes_count', 'screen_name', 'name', 'profile_image_url',
               'avatar_large', 'uid', 'ret_text', 'created_at', 'score')


class OursNewsAdmin(ModelAdmin):
    columns = ('user', 'text', 'favorited', 'thumbnail_pic', 'bmiddle_pic',
               'original_pic', 'reposts_count', 'comments_count',
               'attitudes_count', 'screen_name', 'name', 'profile_image_url',
               'avatar_large', 'uid', 'ret_text', 'created_at', 'score')


# admin.register(User, UserAdmin)
admin.register(News, NewsAdmin)
admin.register(OursNews, OursNewsAdmin)
Exemplo n.º 14
0
    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 NotePanel(AdminPanel):
    template_name = 'admin/note.html'

    def get_context(self):

        return {
            'list': Order.select(),
        }


admin = Admin(app, auth, branding='Example Site')

auth.register_admin(admin)
admin = CustomAdmin(app, auth)
admin.register(Photo, PhotoAdmin)
admin.register(Goods, GoodsAdmin)
admin.register(User, UserAdmin)
admin.register(Reviews, ReviewsAdmin)
admin.register(Order)
admin.register_panel('Orders', NotePanel)


Exemplo n.º 15
0
    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()
Exemplo n.º 16
0
# -*- coding: utf-8 -*-
"""Copyright (c) 2012 Sergio Gabriel Teves
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_peewee.admin import Admin 
from pystatus.app import application, auth
from pystatus.app.models import Process

admin = Admin(application, auth)
admin.register(Process)
Exemplo n.º 17
0
Configures the admin interface.
"""

from flask_peewee.admin import Admin

from app import app
from auth import auth
from user import User
from sync_log import SyncLog
from implemented_models import MODELS_CLASS, MASTER_CLASSES, DEPENDENT_CLASSES
from flask_peewee.utils import make_password

#
# Setup the admin interface.
#
admin = Admin(app, auth)
auth.register_admin(admin)

#
# 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='******',
                    password=make_password('admin'),
                    admin=True)
Exemplo n.º 18
0
# -*- 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.
Exemplo n.º 19
0
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='MQTTitude')

# 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',
    )

    # Upon saving the User model in admin, set the PBKDF2 hash for
Exemplo n.º 20
0

class CountryAdmin(ModelAdmin):
    columns = ('id', 'countrycode', 'countryname')


class ChargeAdmin(ModelAdmin):
    columns = ('id', 'id_cc_card', 'creationdate', 'amount', 'chargetype')


class DidAdmin(ModelAdmin):
    columns = ('id', 'did', 'iduser', 'activated', 'reserved')


class DidDestinationAdmin(ModelAdmin):
    columns = ('destination', 'id_cc_card', 'id_cc_did', 'activated')


admin = Admin(app, auth, branding='A2Billing API Admin Site')
admin.register(Card, CardAdmin)
admin.register(CardGroup, CardGroupAdmin)
admin.register(Callerid, CalleridAdmin)
admin.register(Logrefill, LogrefillAdmin)
admin.register(Logpayment, LogpaymentAdmin)
admin.register(Call, CallAdmin)
admin.register(Country, CountryAdmin)
admin.register(Charge, ChargeAdmin)
# admin.register(Did, DidAdmin)
# admin.register(DidDestination, DidDestinationAdmin)
auth.register_admin(admin)
Exemplo n.º 21
0
# 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/>

import datetime
from flask_peewee.admin import Admin, ModelAdmin

from app import app, db
from auth import auth
from models import comments


class commentsAdmin(ModelAdmin):
    columns = ('model', 'comment', 'author', 'email', 'created')


admin = Admin(app, auth)
admin.register(comments, commentsAdmin)
Exemplo n.º 22
0
    )


class DownloadAdmin(ModelAdmin):
    columns = (
        'project',
        'command',
    )
    foreign_key_lookups = {'project': 'name'}


class AddonAdmin(ModelAdmin):
    columns = (
        'project',
        'number',
        'repo',
        'custom',
    )
    foreign_key_lookups = {'project': 'name'}


admin = Admin(app, auth)
auth.register_admin(admin)

admin.register(User, UserAdmin)
admin.register(Project, ProjectAdmin)
admin.register(Addon, AddonAdmin)
admin.register(Download, DownloadAdmin)

admin.setup()
Exemplo n.º 23
0
def init_admin(app, auth, models):
    admin = Admin(app, auth)
    for model in models:
        admin.register(model)
    admin.setup()
Exemplo n.º 24
0
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)
Exemplo n.º 25
0
    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='*****@*****.**',
            password='******',
            admin = True
        )
    except ValueError:
        pass
    app.run(debug=DEBUG, host=HOST, port=PORT)
Exemplo n.º 26
0
        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)


Exemplo n.º 27
0
Arquivo: admin.py Projeto: lite/pinche
        }

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': '******'}
    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',)
Exemplo n.º 28
0
                       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()
Exemplo n.º 29
0
        }

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': '******'}
    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',)
Exemplo n.º 30
0
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='******', 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',)
Exemplo n.º 31
0
        Model.create_table(fail_silently=True)
    user_datastore.create_user(email='*****@*****.**', 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)
Exemplo n.º 32
0
		self.facebook_id = facebook_id'''


class Drop(db.Model):
    drop_owner = ForeignKeyField(Owner)
    drop_address = TextField()
    drop_lat = CharField()
    drop_long = CharField()
    drop_tags = CharField()
    '''def __init__(self, drop_owner, drop_address, drop_tags):
		self.drop_owner = drop_owner
		self.drop_address = drop_address
		self.drop_tags = drop_tags'''


admin = Admin(app, auth)


class OwnerAdmin(ModelAdmin):
    columns = (
        'name',
        'email',
        'facebook_id',
    )


class DropAdmin(ModelAdmin):
    columns = (
        'drop_owner',
        'drop_address',
        'drop_lat',
Exemplo n.º 33
0
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()
Exemplo n.º 34
0
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')
Exemplo n.º 35
0
 def init_app(self, app):  # Инициируем Админку
     self.extension = Admin(app.web_app, app.auth)
    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()
Exemplo n.º 37
0
# 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)
auth.register_admin(admin)
admin.setup()


if __name__ == '__main__':
    auth.User.create_table(fail_silently=True)
    # Note.create_table(fail_silently=True)
    try:
        admin = auth.User(username='******', email='', admin=True, active=True)
        admin.set_password('admin')
        admin.save()
    except IntegrityError:
        print "User 'admin' already created!"
Exemplo n.º 38
0
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()
Exemplo n.º 39
0
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)
Exemplo n.º 40
0
Configures the admin interface.
"""

from flask_peewee.admin import Admin

from app import app
from auth import auth
from user import User
from sync_log import SyncLog
from implemented_models import MODELS_CLASS, MASTER_CLASSES, DEPENDENT_CLASSES
from flask_peewee.utils import make_password

#
# Setup the admin interface.
#
admin = Admin(app, auth)
auth.register_admin(admin)

#
# 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='******',
                    password=make_password('admin'),
                    admin=True)
Exemplo n.º 41
0
from flask_peewee.auth import Auth
from flask_peewee.db import Database
from flask_peewee.utils import get_object_or_404
from flask_sslify import SSLify
from peewee import BooleanField, CharField, DateTimeField, ForeignKeyField, TextField
import stripe

logging.basicConfig(level=logging.INFO)


app = Flask(__name__)
app.config.from_object(os.environ['CONFIG'])
assets = Environment(app)
db = Database(app)
auth = Auth(app, db)
admin = Admin(app, auth)
mail = Mail(app)
sslify = SSLify(app)

css = Bundle(app.config['CSS_BOOTSTRAP'], 'css/custom.css')
assets.register('css_all', css)

js = Bundle(app.config['JS_BOOTSTRAP'])
assets.register('js_all', js)

stripe.api_key = app.config['STRIPE_KEYS']['secret_key']


class Piece(db.Model):
    title = CharField()
    slug = CharField()
Exemplo n.º 42
0
'''
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)
Exemplo n.º 43
0
import datetime
from flask import request, redirect
from flask_peewee.auth import Auth
from flask_peewee.admin import Admin, ModelAdmin

from app import app, db
from models import Image, Imageuri, ImageFragment, Metadata, Annotation

# create an Auth object for use with our flask app and database wrapper
auth = Auth(app, db)

class ImageAdmin(ModelAdmin):
    columns = ('id','width', 'created',)

class ImageuriAdmin(ModelAdmin):
    columns = ('image','uri', 'created',)	

admin = Admin(app, auth)
admin.register(Image, ImageAdmin)
admin.register(Imageuri, ImageuriAdmin)
admin.register(ImageFragment)
admin.register(Metadata)
admin.register(Annotation)
auth.register_admin(admin)
admin.setup()

auth.User.create_table(fail_silently=True)
Exemplo n.º 44
0
    def save_model(self, instance, form, adding=True):
        '''function that is responsible for persisting user password changes to the database
        
        parameters
        ----------
        instance: an unsaved user model instance
        form: a validated form instance
        adding: boolean to indicate whether a new instance is being added or saving an existing instance
        '''
        orig_password = instance.password

        user = super(UserAdmin, self).save_model(instance, form, adding)

        if orig_password != form.password.data:  # if user adds or edits password
            user.set_password(form.password.data)  # set as new password
            user.save()  # save new password

        return user


# instantiate Admin object
admin = Admin(app, auth)
auth.register_admin(admin)

# register models to expose them to the admin area
admin.register(room,
               RoomAdmin)  # pass model and subclass with display variables
admin.register(module, ModuleAdmin)
admin.register(timetable, TimetableAdmin)
admin.register(User, UserAdmin)
Exemplo n.º 45
0
        }

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.select().where(User.join_date > last_week).count()
        messages_this_week = Message.select().where(Message.pub_date > last_week).count()
        return {
            'signups': signups_this_week,
            'messages': messages_this_week,
        }


admin = Admin(app, auth, branding='Admin the boat')


class MessageAdmin(ModelAdmin):
    columns = ('user', 'content', 'pub_date',)
    foreign_key_lookups = {'user': '******'}
    filter_fields = ('user', 'content', 'pub_date', 'user__username')

class NoteAdmin(ModelAdmin):
    columns = ('user', 'message', 'created_date',)
    exclude = ('created_date',)


auth.register_admin(admin)
#admin.register(Relationship)
admin.register(Message, MessageAdmin)
Exemplo n.º 46
0
# -*- coding: utf-8 -*-
"""
Admin dashboard.
Configures the admin interface.
"""

from flask_peewee.admin import Admin

from app import app
from auth import auth
from user import User
from product import Product
from customer import Customer

#
# Setup the admin interface.
#
admin = Admin(app, auth)
auth.register_admin(admin)

#
# Register the models available in the admin interface.
#
admin.register(User)
admin.register(Customer)
admin.register(Product)

# Enable the admin interface.
admin.setup()
Exemplo n.º 47
0
from flask_peewee.auth import Auth
from flask_peewee.admin import Admin
from flask_peewee.rest import RestAPI, UserAuthentication

from phrases.app import app, db
from phrases.models import Phrase, Volume, NotePhrase, NoteVolume, UserResource


auth = Auth(app, db)
admin = Admin(app, auth)
user_auth = UserAuthentication(auth)
api = RestAPI(app, default_auth=user_auth)

if __name__ == "__main__":
    admin.register(Phrase, NotePhrase)
    admin.register(Volume, NoteVolume)
    auth.register_admin(admin)
    admin.setup()

    Phrase.create_table(fail_silently=True)
    Volume.create_table(fail_silently=True)
    auth.User.create_table(fail_silently=True)

    api.register(Phrase, UserResource)
    api.setup()

    app.run()
Exemplo n.º 48
0
# 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
login_manager = LoginManager()
login_manager.init_app(server)
Exemplo n.º 49
0
DEBUG = True

SECRET_KEY = settings.SECRET_KEY


# ------------------------------------------------------------------------------
# Flask App Settings

app = Flask(__name__)
app.config.from_object(__name__)

db = Database(app)

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


# ------------------------------------------------------------------------------
# Flask Models

class ShakespeareQuote(db.Model):
    quote = TextField()
    created = DateTimeField(default=datetime.datetime.now)
    source_url = TextField()
    is_tweeted = BooleanField(default=False)

    def set_tweeted(self):
        self.is_tweeted = True
        self.save()
Exemplo n.º 50
0
    return render_template('apply.html', title='Apply', form=form)


@app.route('/')
def index():

    auth = Auth(app, models.DATABASE)


#admin = Admin(app, auth)
#admin.register(models.User)
#admin.setup()

if __name__ == '__main__':
    models.initialize()

    # needed for authentication
    admin = Admin(app, name="GrizzHacks")
    admin.add_view(UserView(models.User))
    admin.add_view(MyModelView(models.Apply))
    admin.add_view(MyModelView(models.emailSignup))
    #    admin.set_password('admin')
    try:
        models.User.create_user(email='*****@*****.**',
                                password='******',
                                admin=True)
    except ValueError:
        pass

    app.run(debug=DEBUG, host=HOST, port=PORT)
Exemplo n.º 51
0
        }

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.select().where(User.join_date > last_week).count()
        messages_this_week = Message.select().where(Message.pub_date > last_week).count()
        return {
            'signups': signups_this_week,
            'messages': messages_this_week,
        }


admin = Admin(app, auth, branding='Example Site')


class MessageAdmin(ModelAdmin):
    columns = ('user', 'content', 'pub_date',)
    foreign_key_lookups = {'user': '******'}
    filter_fields = ('user', 'content', 'pub_date', 'user__username')

class NoteAdmin(ModelAdmin):
    columns = ('user', 'message', 'created_date',)
    exclude = ('created_date',)


auth.register_admin(admin)
admin.register(Relationship)
admin.register(Message, MessageAdmin)
Exemplo n.º 52
0
    '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)
Exemplo n.º 53
0
from app import app, db
from auth import auth
from models import *


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.select().where(User.join_date > last_week).count()
        return {
            'signups': signups_this_week,
        }

admin = Admin(app, auth, branding='Example Site')


class TeamAdmin(ModelAdmin):
    columns = ('name',)


class ScoreAdmin(ModelAdmin):
    columns = ('user', 'week', 'week_start','week_end','score')
    exclude = ('created_at',)


class TeamLeaderAdmin(ModelAdmin):
    columns = ('leader', 'team')

Exemplo n.º 54
0
            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',)
Exemplo n.º 55
0
# -*- coding: utf-8 -*-

from flask_peewee.admin import Admin
from flask_peewee.auth import Auth

from app import app, db
from models import *

auth = Auth(app, db, user_model=AdminUser)
admin = Admin(app, auth, branding=app.config['BRANDING'])

auth.register_admin(admin)
admin.register(AdminUser)
admin.register(User)
admin.register(Travel)
admin.register(Document)
admin.setup()
Exemplo n.º 56
0
import psyc.models.processor as processor
import psyc.models.execution as execution

from gevent.wsgi import WSGIServer
from flask_peewee.admin import Admin
port = 9080

auth.User.create_table(fail_silently=True)

url.Url.create_table(fail_silently=True)
resource.Resource.create_table(fail_silently=True)
catalog.Catalog.create_table(fail_silently=True)
processor.Processor.create_table(fail_silently=True)
execution.Execution.create_table(fail_silently=True)

admin = Admin(app,auth)
auth.register_admin(admin)

admin.register(url.Url, url.UrlAdmin)
admin.register(resource.Resource, resource.ResourceAdmin)
admin.register(catalog.Catalog, catalog.CatalogAdmin)
admin.register(processor.Processor, processor.ProcessorAdmin)
admin.register(execution.Execution, execution.ExecutionAdmin)

admin.setup()

import psyc.rest
import psyc.views
catalog.register()
#app.run(host='0.0.0.0', port=port, debug=True)
http_server = WSGIServer(('', port), app)
Exemplo n.º 57
0
"""
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)
# or you could admin.register(User, ModelAdmin) -- you would also register
# any other models here.