atr/routes/compose.py (66 lines of code) (raw):

# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from typing import TYPE_CHECKING import quart import werkzeug.wrappers.response as response import wtforms import atr.db as db import atr.db.models as models import atr.revision as revision import atr.routes as routes import atr.routes.draft as draft import atr.routes.resolve as resolve import atr.util as util if TYPE_CHECKING: from collections.abc import Sequence async def check( session: routes.CommitterSession, release: models.Release, task_mid: str | None = None, form: wtforms.Form | None = None, archive_url: str | None = None, vote_task: models.Task | None = None, ) -> response.Response | str: base_path = util.release_directory(release) paths = [path async for path in util.paths_recursive(base_path)] paths.sort() info = await db.path_info(release, paths) user_ssh_keys: Sequence[models.SSHKey] = [] async with db.session() as data: user_ssh_keys = await data.ssh_key(asf_uid=session.uid).all() revision_name_from_link, revision_editor, revision_time = await revision.latest_info( release.project.name, release.version ) # Get the number of ongoing tasks for the current revision ongoing_tasks_count = 0 if revision_name_from_link: ongoing_tasks_count = await db.tasks_ongoing(release.project.name, release.version, revision_name_from_link) delete_draft_form = await draft.DeleteForm.create_form() delete_file_form = await draft.DeleteFileForm.create_form() resolve_form = await resolve.ResolveForm.create_form() return await quart.render_template( "check-selected.html", project_name=release.project.name, version_name=release.version, release=release, paths=paths, info=info, revision_editor=revision_editor, revision_time=revision_time, revision_name_from_link=revision_name_from_link, ongoing_tasks_count=ongoing_tasks_count, delete_form=delete_draft_form, delete_file_form=delete_file_form, asf_id=session.uid, server_domain=session.app_host, user_ssh_keys=user_ssh_keys, format_datetime=util.format_datetime, models=models, task_mid=task_mid, form=form, resolve_form=resolve_form, vote_task=vote_task, archive_url=archive_url, ) @routes.committer("/compose/<project_name>/<version_name>") async def selected(session: routes.CommitterSession, project_name: str, version_name: str) -> response.Response | str: """Show the contents of the release candidate draft.""" await session.check_access(project_name) release = await session.release(project_name, version_name, with_committee=True) return await check(session, release)