Esempio n. 1
0
    def __init__(self, app, database):

        db = SQLAlchemy(app)
        db_session = scoped_session(
            sessionmaker(autocommit=False, autoflush=False, bind=db.engine))
        self.database = db_session
        self.items = ItemsService(database=db_session)
        self.auctions = AuctionsService(database=db_session)
Esempio n. 2
0
import bcrypt
from flask import Blueprint, flash, render_template, redirect, request, session
from templatesandmoe import db_session
from templatesandmoe.modules.items.models import Item
from templatesandmoe.modules.users.models import User
from templatesandmoe.modules.users.service import UsersService
from templatesandmoe.modules.items.service import ItemsService
from templatesandmoe.modules.reporting.service import ReportingService
from templatesandmoe.modules.admin.forms.user import UserForm

adminModule = Blueprint('admin', __name__, url_prefix='/admin')
users_service = UsersService(database=db_session)
items_service = ItemsService(database=db_session)
reporting_service = ReportingService(database=db_session)


@adminModule.before_request
def before_request():
    # Make sure user is logged in and is an admin
    if session.get('user_id') and session['permission'] > 0:
        pass
    else:
        return redirect('/')


@adminModule.route('/', methods=['GET'])
def home():
    return render_template('admin/home.html')


@adminModule.route('/users', methods=['GET'])