Skip to content

Commit c2dd967

Browse files
committed
create required debugproxy organization in init_db
1 parent 5949000 commit c2dd967

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

proxyweb/startup/create_users.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
from typing import List, Set, Dict, Tuple, Text, Optional, Any
66

77

8+
def create_debugproxy_organization():
9+
organization = Organization.query.filter(Organization.name == name).first()
10+
if not organization:
11+
organization = Organization(name=name)
12+
db.session.add(organization)
13+
db.session.commit()
14+
15+
816
def create_admin_command(email, password) -> None:
917
admin_role = find_or_create_role('admin', u'Admin')
1018
system_admin_role = find_or_create_role('system_admin', u'System Admin')

proxyweb/startup/manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import database as db
33
from proxyweb.startup.create_users import find_or_create_organization, \
44
find_or_create_user, create_user_command, create_admin_command, \
5-
create_session_command
5+
create_session_command, create_debugproxy_organization
66

77
from proxyweb.startup.create_users import create_users
88
from database.models import Organization, User
@@ -11,21 +11,19 @@
1111
@manager.command
1212
def init_db(): # type: ignore
1313
db.create_all()
14-
14+
create_debugproxy_organization("debugproxy")
1515

1616
@manager.command
1717
def drop_db(): # type: ignore
1818
db.session.commit()
1919
db.drop_all()
2020

21-
2221
@manager.command
2322
def clear_db(): # type: ignore
2423
db.session.query(Organization).delete()
2524
db.session.query(User).delete()
2625
db.session.commit()
2726

28-
2927
@manager.command
3028
def create_admin(email, password):
3129
create_admin_command(email, password)

0 commit comments

Comments
 (0)