latest
This commit is contained in:
@@ -23,9 +23,9 @@ def initialise_schools_from_config():
|
||||
"""Initialize a school with the configuration provided from env variables
|
||||
"""
|
||||
default_config = {
|
||||
"school_uuid": "kevlarai",
|
||||
"school_name": "KevlarAI School",
|
||||
"school_website": "https://kevlarai.com",
|
||||
"uuid_string": "kevlarai-dev",
|
||||
"name": "KevlarAI School",
|
||||
"website": "https://kevlarai.com",
|
||||
"timetable_file": "kevlarai_data/kevlarai_timetable.xlsx",
|
||||
"curriculum_file": "kevlarai_data/kevlarai_curriculum.xlsx"
|
||||
}
|
||||
@@ -33,10 +33,10 @@ def initialise_schools_from_config():
|
||||
# school_config_str = os.getenv("SCHOOL_CONFIG") # TODO: Implement this
|
||||
school_config = default_config
|
||||
|
||||
db_name = f"cc.institutes.{school_config['school_uuid']}"
|
||||
db_name = f"cc.institutes.{school_config['uuid_string']}"
|
||||
curriculum_db_name = f"{db_name}.curriculum"
|
||||
|
||||
logger.info(f"Creating database for {school_config['school_name']} using db_name: {db_name}")
|
||||
logger.info(f"Creating database for {school_config['name']} using db_name: {db_name}")
|
||||
driver = driver_tools.get_driver()
|
||||
if driver is None:
|
||||
logger.error("Failed to connect to Neo4j")
|
||||
@@ -54,7 +54,7 @@ def initialise_schools_from_config():
|
||||
# Add filesystem path debugging
|
||||
base_path = os.getenv("NODE_FILESYSTEM_PATH")
|
||||
schools_path = os.path.join(base_path, "schools")
|
||||
school_path = os.path.join(schools_path, f"cc.institutes.{school_config['school_uuid']}")
|
||||
school_path = os.path.join(schools_path, f"cc.institutes.{school_config['uuid_string']}")
|
||||
|
||||
logger.debug("Filesystem paths:", {
|
||||
"base_path": base_path,
|
||||
@@ -70,29 +70,34 @@ def initialise_schools_from_config():
|
||||
})
|
||||
|
||||
# Create database entry for school without timetable or curriculum
|
||||
logger.info(f"Creating school entry for {school_config['school_name']} in database {db_name} without timetable or curriculum")
|
||||
logger.info(f"Creating school entry for {school_config['name']} in database {db_name} without timetable or curriculum")
|
||||
|
||||
school_uuid_string=school_config["uuid_strig"]
|
||||
school_name=school_config["name"]
|
||||
school_website=school_config["website"]
|
||||
|
||||
result = init_school.create_school(
|
||||
db_name=db_name,
|
||||
school_uuid=school_config["school_uuid"],
|
||||
school_name=school_config["school_name"],
|
||||
school_website=school_config["school_website"]
|
||||
school_type="development",
|
||||
uuid_string=school_uuid_string,
|
||||
name=school_name,
|
||||
website=school_website
|
||||
)
|
||||
logger.success(f"{school_config['school_name']} school entry created successfully")
|
||||
logger.success(f"{school_config['name']} school entry created successfully")
|
||||
|
||||
# Create school node from result
|
||||
school_node = result['school_node']
|
||||
refreshed_school_node = SchoolNode(
|
||||
unique_id=school_node.unique_id,
|
||||
school_uuid=school_node.school_uuid,
|
||||
school_name=school_node.school_name,
|
||||
school_website=school_node.school_website,
|
||||
path=school_node.path
|
||||
school_type="development",
|
||||
uuid_string=school_node.uuid_string,
|
||||
name=school_node.name,
|
||||
website=school_node.website
|
||||
)
|
||||
|
||||
# Create timetable entries for school from Excel file
|
||||
timetable_file = os.path.join(os.getenv("BACKEND_INIT_PATH"), school_config["timetable_file"])
|
||||
|
||||
logger.info(f"Creating timetable entries for {school_config['school_name']} using timetable file: {timetable_file}.")
|
||||
logger.info(f"Creating timetable entries for {school_config['name']} using timetable file: {timetable_file}.")
|
||||
school_timetable_dataframes = xl.create_dataframes(timetable_file)
|
||||
|
||||
|
||||
@@ -107,7 +112,7 @@ def initialise_schools_from_config():
|
||||
curriculum_file = os.path.join(os.getenv("BACKEND_INIT_PATH"), school_config["curriculum_file"])
|
||||
school_curriculum_dataframes = xl.create_dataframes(curriculum_file)
|
||||
|
||||
logger.info(f"Creating curriculum entries for {school_config['school_name']} using curriculum file: {curriculum_file}.")
|
||||
logger.info(f"Creating curriculum entries for {school_config['name']} using curriculum file: {curriculum_file}.")
|
||||
init_school_curriculum.create_curriculum(
|
||||
dataframes=school_curriculum_dataframes,
|
||||
db_name=db_name,
|
||||
@@ -123,18 +128,18 @@ async def create_user(
|
||||
user_type: str = Form(...),
|
||||
user_name: str = Form(...),
|
||||
user_email: str = Form(...),
|
||||
school_uuid: str = Form(None),
|
||||
school_uuid_string: str = Form(None),
|
||||
school_name: str = Form(None),
|
||||
school_website: str = Form(None),
|
||||
school_path: str = Form(None),
|
||||
school_node_storage_path: str = Form(None),
|
||||
worker_data: str = Form(None)
|
||||
):
|
||||
logger.info(f"Creating user with user_id: {user_id}, user_type: {user_type}, user_name: {user_name}, user_email: {user_email}")
|
||||
|
||||
if school_uuid:
|
||||
logger.info(f"School UUID provided: {school_uuid}")
|
||||
if school_uuid_string:
|
||||
logger.info(f"School UUID string provided: {school_uuid_string}")
|
||||
else:
|
||||
logger.info(f"No school UUID provided")
|
||||
logger.info(f"No school UUID string provided")
|
||||
|
||||
if school_name:
|
||||
logger.info(f"School name provided: {school_name}")
|
||||
@@ -146,8 +151,8 @@ async def create_user(
|
||||
else:
|
||||
logger.info(f"No school website provided")
|
||||
|
||||
if school_path:
|
||||
logger.info(f"School path provided: {school_path}")
|
||||
if school_node_storage_path:
|
||||
logger.info(f"School path provided: {school_node_storage_path}")
|
||||
else:
|
||||
logger.info(f"No school path provided")
|
||||
|
||||
@@ -169,13 +174,12 @@ async def create_user(
|
||||
|
||||
# Create school node if school data provided
|
||||
school_node = None
|
||||
if all([school_uuid, school_name, school_website, school_path]):
|
||||
if all([school_uuid_string, school_name, school_website, school_node_storage_path]):
|
||||
school_node = SchoolNode(
|
||||
unique_id=f'School_{school_uuid}',
|
||||
school_uuid=school_uuid,
|
||||
school_name=school_name,
|
||||
school_website=school_website,
|
||||
path=school_path
|
||||
uuid_string=school_uuid_string,
|
||||
name=school_name,
|
||||
website=school_website,
|
||||
node_storage_path=school_node_storage_path
|
||||
)
|
||||
|
||||
# Create user with single database reference
|
||||
@@ -219,23 +223,23 @@ async def create_schools():
|
||||
@router.post("/create-department")
|
||||
async def create_department(
|
||||
db_name: str = Form(...),
|
||||
unique_id: str = Form(...),
|
||||
uuid_string: str = Form(...),
|
||||
department_name: str = Form(...),
|
||||
department_code: str = Form(...),
|
||||
path: str = Form(...)
|
||||
department_node_storage_path: str = Form(...)
|
||||
):
|
||||
if db_name is None or unique_id is None or department_name is None or department_code is None or path is None:
|
||||
logging.error(f"Invalid department data: {db_name}, {unique_id}, {department_name}, {department_code}, {path}")
|
||||
if db_name is None or uuid_string is None or department_name is None or department_code is None or department_node_storage_path is None:
|
||||
logging.error(f"Invalid department data: {db_name}, {uuid_string}, {department_name}, {department_code}, {department_node_storage_path}")
|
||||
raise HTTPException(status_code=400, detail="Invalid department data")
|
||||
|
||||
department = DepartmentNode(
|
||||
unique_id=unique_id,
|
||||
uuid_string=uuid_string,
|
||||
department_name=department_name,
|
||||
department_code=department_code,
|
||||
path=path
|
||||
node_storage_path=department_node_storage_path
|
||||
)
|
||||
|
||||
logger.info(f"Creating department {department_name} with unique_id {unique_id}")
|
||||
logger.info(f"Creating department {department_name} with uuid_string {uuid_string}")
|
||||
try:
|
||||
result = init_school.create_department(db_name, department)
|
||||
return JSONResponse(content={"status": "success", "data": result})
|
||||
@@ -246,20 +250,20 @@ async def create_department(
|
||||
@router.post("/create-class")
|
||||
async def create_class(
|
||||
db_name: str = Form(...),
|
||||
unique_id: str = Form(...),
|
||||
uuid_string: str = Form(...),
|
||||
subject_class_code: str = Form(...),
|
||||
year_group: str = Form(...),
|
||||
subject: str = Form(...),
|
||||
subject_code: str = Form(...),
|
||||
path: str = Form(...)
|
||||
subject_node_storage_path: str = Form(...)
|
||||
):
|
||||
subject_class_node = SubjectClassNode(
|
||||
unique_id=unique_id,
|
||||
uuid_string=uuid_string,
|
||||
subject_class_code=subject_class_code,
|
||||
year_group=year_group,
|
||||
subject=subject,
|
||||
subject_code=subject_code,
|
||||
path=path
|
||||
node_storage_path=subject_node_storage_path
|
||||
)
|
||||
# Implementation for creating a class
|
||||
pass
|
||||
@@ -267,14 +271,14 @@ async def create_class(
|
||||
@router.post("/create-room")
|
||||
async def create_room(
|
||||
db_name: str = Form(...),
|
||||
room_unique_id: str = Form(...),
|
||||
room_uuid_string: str = Form(...),
|
||||
room_code: str = Form(...),
|
||||
path: str = Form(...)
|
||||
room_node_storage_path: str = Form(...)
|
||||
):
|
||||
room = RoomNode(
|
||||
room_unique_id=room_unique_id,
|
||||
room_uuid_string=room_uuid_string,
|
||||
room_code=room_code,
|
||||
path=path
|
||||
node_storage_path=room_node_storage_path
|
||||
)
|
||||
# Implementation for creating a room
|
||||
pass
|
||||
Reference in New Issue
Block a user