Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions backend/src/zimfarm_backend/routes/offliners/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,6 @@ async def get_offliners(
)


@router.get("/{offliner_id}")
async def get_initial_offliner_version(
offliner_id: Annotated[str, Path()],
session: Annotated[OrmSession, Depends(gen_dbsession)],
) -> JSONResponse:
"""Get a specific offliner"""

# find the schema class that matches the offliner
offliner = db_get_offliner(session, offliner_id)
offliner_definition = db_get_offliner_definition(
session, offliner_id=offliner_id, version="initial"
)
schema_cls = build_offliner_model(offliner, offliner_definition.schema_)

flags = schema_to_flags(schema_cls)

return JSONResponse(
content={
"flags": [flag.model_dump(mode="json", by_alias=True) for flag in flags],
"help": ( # dynamic + sourced from backend because it might be custom
f"https://github.com/openzim/{offliner}/wiki/Frequently-Asked-Questions"
),
}
)


@router.post("")
async def create_offliner(
request: OfflinerCreateSchema,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/zimfarm_backend/routes/schedules/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ScheduleCreateSchema(BaseModel):
periodicity: SchedulePeriodicity
tags: list[NotEmptyString] = Field(default_factory=list)
enabled: bool
version: str = "initial" # version of offliner to use for validation
version: NotEmptyString
config: dict[str, Any] # will be validated in the route
notification: ScheduleNotificationSchema | None = None
context: NotEmptyString | None = None
Expand Down
4 changes: 4 additions & 0 deletions backend/tests/routes/test_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_get_similar_schedules(
},
"enabled": True,
"periodicity": SchedulePeriodicity.manually.value,
"version": "initial",
},
HTTPStatus.UNPROCESSABLE_ENTITY,
id="invalid-config-missing-offliner-id",
Expand Down Expand Up @@ -200,6 +201,7 @@ def test_get_similar_schedules(
"monitor": True,
},
"enabled": True,
"version": "initial",
"periodicity": SchedulePeriodicity.manually.value,
},
HTTPStatus.UNPROCESSABLE_ENTITY,
Expand Down Expand Up @@ -266,6 +268,7 @@ def test_get_similar_schedules(
},
"enabled": True,
"periodicity": SchedulePeriodicity.manually.value,
"version": "initial",
},
HTTPStatus.OK,
id="valid-config",
Expand Down Expand Up @@ -867,6 +870,7 @@ def test_create_duplicate_schedule(
),
"enabled": True,
"periodicity": SchedulePeriodicity.manually.value,
"version": "initial",
},
)
assert response.status_code == HTTPStatus.CONFLICT
Expand Down