Make it easer to start things up.

This commit is contained in:
Dan 2020-12-01 11:17:07 -05:00
parent 0eefc26006
commit e0c28cbc7d
2 changed files with 9 additions and 0 deletions

View File

@ -70,6 +70,8 @@ def verify_token(token=None):
else:
# Fall back to a default user if this is not production.
g.user = UserModel.query.first()
if not g.user:
raise ApiError("no_user", "You are in development mode, but there are no users in the database. Add one, and it will use it.")
token = g.user.encode_auth_token()
token_info = UserModel.decode_auth_token(token)
return token_info

View File

@ -4,6 +4,7 @@ import os
from crc import app, db, session
from crc.models.file import CONTENT_TYPES
from crc.models.user import UserModel
from crc.models.workflow import WorkflowSpecModel, WorkflowSpecCategoryModel
from crc.services.file_service import FileService
@ -20,6 +21,7 @@ class ExampleDataLoader:
def load_all(self):
self.load_reference_documents()
self.load_default_user()
categories = [
WorkflowSpecCategoryModel(
@ -324,6 +326,11 @@ class ExampleDataLoader:
content_type=CONTENT_TYPES['xls'])
file.close()
def load_default_user(self):
user = UserModel(uid="xxx9x", email="xxx9x@virginia.edu", display_name="Development User")
db.session.add(user)
db.session.commit()
def ldap(): return "x";
def study_info(i): return {"x":"Y"};