some changes to virtual command api, but its not yet clear how this should function

This commit is contained in:
2020-07-31 16:33:02 +02:00
parent cc334f1727
commit dc142bca0c
10 changed files with 294 additions and 51 deletions

View File

@@ -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