Skip to content

Commit

Permalink
change make_current from query param to body
Browse files Browse the repository at this point in the history
  • Loading branch information
elsholz committed Jan 13, 2024
1 parent 5b6a880 commit c9a096c
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 118 deletions.
8 changes: 6 additions & 2 deletions api/code/metroplanner_api/type_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,13 @@ class PlanstateComponents(BaseModel):


class CreatePlanstate(
PlanstateDimensions, PlanstateComponents, PlanstateComponentOderings
PlanstateDimensions,
PlanstateComponents,
# PlanstateComponentOderings
ModelMayMissFields,
):
color_theme: Optional[Union[str, ObjectId]] = None
color_theme: MaybeMissing(Optional[Union[str, ObjectId]]) = Missing
make_current: bool = False


class PlanstateHistoryItem(PlanstateStats):
Expand Down
50 changes: 27 additions & 23 deletions api/code/metroplanner_api/v1/endpoints/_planstates.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ def post_planstate(
plan_id,
planstate_data: type_definitions.CreatePlanstate,
sub: str = Depends(check_auth),
make_current: bool = False,
) -> type_definitions.PlanstatePrivatePostResponse:
db = ENV.database
user_data = db.users.find_one({'sub': sub})
user_data = db.users.find_one({"sub": sub})
plan_details = db.plans.find_one(
{"_id": BsonObjectId(plan_id)},
{
Expand All @@ -28,7 +27,7 @@ def post_planstate(
)

if user_data and plan_details:
if plan_details["owned_by"] == user_data['_id']:
if plan_details["owned_by"] == user_data["_id"]:
number_of_edges = 0
set_planstate_data = {}

Expand All @@ -43,31 +42,34 @@ def post_planstate(

set_planstate_data["created_at"] = (now := datetime.now().isoformat())

created_result = db.planstates.insert_one({set_planstate_data} | {
'lines': planstate_data.lines,
'nodes': planstate_data.nodes,
'independent_labels': planstate_data.independent_labels,
})
created_result = db.planstates.insert_one(
{set_planstate_data}
| {
"lines": planstate_data.lines,
"nodes": planstate_data.nodes,
"independent_labels": planstate_data.independent_labels,
}
)
print("Created planstate:", created_result)

set_plan_data = {
"last_modified_at": now,
}

if make_current:
set_plan_data["current_state"] = created_result.inserted_id
set_plan_data["current_number_of_edges"] = planstate_data[
"number_of_edges"
]
set_plan_data["current_number_of_lines"] = planstate_data[
"number_of_lines"
]
set_plan_data["current_number_of_nodes"] = planstate_data[
"number_of_nodes"
]
set_plan_data["current_number_of_labels"] = planstate_data[
"number_of_labels"
]
if plan_details.make_current:
set_plan_data["current_state"] = created_result.inserted_id
set_plan_data["current_number_of_edges"] = planstate_data[
"number_of_edges"
]
set_plan_data["current_number_of_lines"] = planstate_data[
"number_of_lines"
]
set_plan_data["current_number_of_nodes"] = planstate_data[
"number_of_nodes"
]
set_plan_data["current_number_of_labels"] = planstate_data[
"number_of_labels"
]

db.plans.update_one(
{"_id": BsonObjectId(plan_id)},
Expand All @@ -79,7 +81,9 @@ def post_planstate(
},
)

return {"planstateId": str(created_result.inserted_id)} #, **planstate_data}
return {
"planstateId": str(created_result.inserted_id)
} # , **planstate_data}
else:
raise responses.unauthorized_401()
else:
Expand Down
File renamed without changes.
93 changes: 0 additions & 93 deletions q-frontend/src/css/fonts/OFL.txt

This file was deleted.

Binary file removed q-frontend/src/css/fonts/Oxygen-Bold.ttf
Binary file not shown.
Binary file removed q-frontend/src/css/fonts/Oxygen-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file added q-frontend/src/css/fonts/Oxygen-Sans-Bold.otf
Binary file not shown.
Binary file not shown.
Binary file added q-frontend/src/css/fonts/Oxygen-Sans-Book.otf
Binary file not shown.
Binary file removed q-frontend/src/css/fonts/OxygenMono-Regular.ttf
Binary file not shown.

0 comments on commit c9a096c

Please sign in to comment.