import os

from dotenv import load_dotenv

from boilerplate import create_app
from boilerplate import db
from boilerplate.permission.models import Permissions
from boilerplate.role.models import Roles

project_folder = os.path.dirname(
    os.path.dirname(os.path.dirname(
        os.path.abspath(__file__))))  # Path to .env file
load_dotenv(os.path.join(project_folder, '.env'))
app = create_app()
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = os.environ.get(
    'SQLALCHEMY_TRACK_MODIFICATIONS')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'SQLALCHEMY_DATABASE_URI')


class RolePermissionSeeder:
    def roleseeder():
        try:

            with app.app_context():
                roles = Roles.query.all()
                if len(roles) == 0:
                    permission_list = [
                        Permissions(name="admin_list", status="active"),
                        Permissions(name="admin_create", status="active"),
                        Permissions(name="admin_show", status="active"),
Exemplo n.º 2
0
 def create_app(self):
     return create_app(TestConfig)