Skip to content

Commit 720ae29

Browse files
committed
add route to create offliner definitions and drop route to get initial
definition
1 parent 56e30b7 commit 720ae29

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

backend/src/zimfarm_backend/routes/offliners/logic.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,6 @@ async def get_offliners(
5757
)
5858

5959

60-
@router.get("/{offliner_id}")
61-
async def get_initial_offliner_version(
62-
offliner_id: Annotated[str, Path()],
63-
session: Annotated[OrmSession, Depends(gen_dbsession)],
64-
) -> JSONResponse:
65-
"""Get a specific offliner"""
66-
67-
# find the schema class that matches the offliner
68-
offliner = db_get_offliner(session, offliner_id)
69-
offliner_definition = db_get_offliner_definition(
70-
session, offliner_id=offliner_id, version="initial"
71-
)
72-
schema_cls = build_offliner_model(offliner, offliner_definition.schema_)
73-
74-
flags = schema_to_flags(schema_cls)
75-
76-
return JSONResponse(
77-
content={
78-
"flags": [flag.model_dump(mode="json", by_alias=True) for flag in flags],
79-
"help": ( # dynamic + sourced from backend because it might be custom
80-
f"https://github.com/openzim/{offliner}/wiki/Frequently-Asked-Questions"
81-
),
82-
}
83-
)
84-
85-
8660
@router.post("")
8761
async def create_offliner(
8862
request: OfflinerCreateSchema,

backend/src/zimfarm_backend/routes/schedules/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ScheduleCreateSchema(BaseModel):
4141
periodicity: SchedulePeriodicity
4242
tags: list[NotEmptyString] = Field(default_factory=list)
4343
enabled: bool
44-
version: str = "initial" # version of offliner to use for validation
44+
version: NotEmptyString
4545
config: dict[str, Any] # will be validated in the route
4646
notification: ScheduleNotificationSchema | None = None
4747
context: NotEmptyString | None = None

backend/tests/routes/test_schedules.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def test_get_similar_schedules(
168168
},
169169
"enabled": True,
170170
"periodicity": SchedulePeriodicity.manually.value,
171+
"version": "initial",
171172
},
172173
HTTPStatus.UNPROCESSABLE_ENTITY,
173174
id="invalid-config-missing-offliner-id",
@@ -200,6 +201,7 @@ def test_get_similar_schedules(
200201
"monitor": True,
201202
},
202203
"enabled": True,
204+
"version": "initial",
203205
"periodicity": SchedulePeriodicity.manually.value,
204206
},
205207
HTTPStatus.UNPROCESSABLE_ENTITY,
@@ -266,6 +268,7 @@ def test_get_similar_schedules(
266268
},
267269
"enabled": True,
268270
"periodicity": SchedulePeriodicity.manually.value,
271+
"version": "initial",
269272
},
270273
HTTPStatus.OK,
271274
id="valid-config",
@@ -867,6 +870,7 @@ def test_create_duplicate_schedule(
867870
),
868871
"enabled": True,
869872
"periodicity": SchedulePeriodicity.manually.value,
873+
"version": "initial",
870874
},
871875
)
872876
assert response.status_code == HTTPStatus.CONFLICT

0 commit comments

Comments
 (0)