andrewmusselman commented on code in PR #309:
URL:
https://github.com/apache/tooling-trusted-releases/pull/309#discussion_r2572299157
##########
atr/post/distribution.py:
##########
@@ -28,17 +28,68 @@
import atr.web as web
+async def record_form_process_page(
+ session: web.Committer,
+ form_data: shared.distribution.DistributeForm,
+ project: str,
+ version: str,
+ /,
+ staging: bool = False,
+) -> web.WerkzeugResponse:
+ platform_wrapper = cast("shared.distribution.DistributionPlatformWrapper",
form_data.platform)
+ sql_platform = shared.distribution.wrapper_to_sql(platform_wrapper)
+ dd = distribution.Data(
+ platform=sql_platform,
+ owner_namespace=form_data.owner_namespace,
+ package=form_data.package,
+ version=form_data.version,
+ details=form_data.details,
+ )
+ release, committee = await
shared.distribution.release_validated_and_committee(
+ project,
+ version,
+ staging=staging,
+ )
+
+ async with
storage.write_as_committee_member(committee_name=committee.name) as w:
+ try:
+ _dist, added, _metadata = await w.distributions.record_from_data(
+ release=release,
+ staging=staging,
+ dd=dd,
+ )
+ except storage.AccessError as e:
+ # Instead of calling record_form_page_new, redirect with error
message
+ return await session.redirect(
+ get.distribution.stage if staging else get.distribution.record,
+ project=project,
+ version=version,
+ error=str(e), # Flash error message
+ )
+
+ # Success - redirect to distribution list with success message
+ message = "Distribution recorded successfully." if added else
"Distribution was already recorded."
+ return await session.redirect(
+ get.distribution.list_get,
+ project=project,
+ version=version,
+ success=message,
+ )
+
+
@post.committer("/distribution/delete/<project>/<version>")
-async def delete(session: web.Committer, project: str, version: str) ->
web.WerkzeugResponse:
- form = await shared.distribution.DeleteForm.create_form(data=await
quart.request.form)
- dd = distribution.DeleteData.model_validate(form.data)
[email protected](shared.distribution.DeleteForm)
+async def delete(
+ session: web.Committer, delete_form: shared.distribution.DeleteForm,
project: str, version: str
+) -> web.WerkzeugResponse:
+ dd = distribution.DeleteData.model_construct(**delete_form.model_dump())
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]