some changes to virtual command api, but its not yet clear how this should function
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
import os, sys
|
||||
|
||||
from backend.models import Permission, Group
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), os.path.pardir))
|
||||
import os
|
||||
import unittest
|
||||
@@ -59,10 +62,30 @@ def cov():
|
||||
return 1
|
||||
|
||||
|
||||
def insert_initial_groups():
|
||||
print("DB: inserting default groups:")
|
||||
for g in app.config.get("GROUPS", []):
|
||||
print(g['name'])
|
||||
g_permissions = g.pop('permissions', [])
|
||||
g['permissions'] = Permission.get_by_names(g_permissions)
|
||||
db.session.add(Group(**g))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@manager.command
|
||||
def recreate_db():
|
||||
"""Drops the db tables."""
|
||||
db.drop_all()
|
||||
"""Creates the db tables."""
|
||||
db.create_all()
|
||||
insert_initial_groups()
|
||||
|
||||
|
||||
@manager.command
|
||||
def create_db():
|
||||
"""Creates the db tables."""
|
||||
db.create_all()
|
||||
insert_initial_groups()
|
||||
|
||||
|
||||
@manager.command
|
||||
|
||||
Reference in New Issue
Block a user