-{% extends "../../modal.html" %}
+{% extends "modal.html" %}
-{% block title %}{{ build }} - {{ _("Add To Repository") }}{% end block %}
+{% block title %}{{ build }} - {{ _("Add To Repository") }}{% endblock %}
{% block breadcrumbs %}
<nav class="breadcrumb" aria-label="breadcrumbs">
</li>
</ul>
</nav>
-{% end block %}
+{% endblock %}
{% block modal_title %}
<h4 class="title is-4">{{ _("Add Build To A Repository") }}</h4>
<h6 class="subtitle is-6">{{ build }}</h6>
-{% end block %}
+{% endblock %}
{% block modal %}
<form method="POST" action="">
- {% raw xsrf_form_html() %}
+ {{ xsrf_form_html() | safe }}
{# Repositories #}
<div class="field">
<div class="control">
<div class="select is-fullwidth">
<select name="repo" required>
- <option value="">{{ _("- Select One -") }}</option>
+ <option value="">
+ {{ _("- Select One -") }}
+ </option>
- {% for repo in sorted(repos) %}
+ {% for repo in repos | sort %}
<option value="{{ repo.slug }}"
- {% if repo in build.repos %}disabled{% end %}>{{ repo }}</option>
- {% end %}
+ {% if repo in build.repos %}disabled{% endif %}>{{ repo }}</option>
+ {% endfor %}
</select>
</div>
</div>
</button>
</div>
</form>
-{% end block %}
+{% endblock %}
-{% extends "../../modal.html" %}
+{% extends "modal.html" %}
-{% block title %}{{ build }} - {{ _("Remove From Repository") }}{% end block %}
+{% block title %}{{ build }} - {{ _("Remove From Repository") }}{% endblock %}
{% block breadcrumbs %}
<nav class="breadcrumb" aria-label="breadcrumbs">
</li>
</ul>
</nav>
-{% end block %}
+{% endblock %}
{% block modal_title %}
<h4 class="title is-4">{{ _("Remove Build From A Repository") }}</h4>
<h6 class="subtitle is-6">{{ build }}</h6>
-{% end block %}
+{% endblock %}
{% block modal %}
<form method="POST" action="">
- {% raw xsrf_form_html() %}
+ {{ xsrf_form_html() | safe }}
- {# When the build is in exactly one repository... #}
- {% if len(build.repos) == 1 %}
- {% set repo = build.repos[0] %}
-
- <input type="hidden" name="repo" value="{{ repo.slug }}">
-
- <div class="block">
- <p>
- {{ _("Do you want to remove this build from %s?") % repo }}
- </p>
- </div>
+ <div class="block">
+ <p>
+ {{ _("Please select the repository you want to remove this build from:") }}
+ </p>
+ </div>
- {# When the build is in multiple repositories... #}
- {% else %}
- <div class="block">
- <p>
- {{ _("Please select the repository you want to remove this build from:") }}
- </p>
- </div>
+ {# Repositories #}
+ <div class="field">
+ <label class="label">
+ {{ _("Repositories") }}
+ </label>
- {# Repositories #}
- {% for repo in sorted(build.repos) %}
- <div class="field">
- <label class="checkbox">
- <input type="checkbox" name="repo" value="{{ repo.slug }}">
- {{ repo }}
- </label>
+ <div class="control">
+ <div class="select is-fullwidth">
+ <select name="repo" required>
+ {% for repo in build.repos | sort %}
+ <option value="{{ repo.slug }}">
+ {{ repo }}
+ </option>
+ {% endfor %}
+ </select>
</div>
- {% end %}
- {% end %}
+ </div>
+ </div>
{# Submit! #}
<div class="field">
</button>
</div>
</form>
-{% end block %}
+{% endblock %}
class ReposAddHandler(base.BaseHandler):
@base.authenticated
- def get(self, uuid):
- build = self.backend.builds.get_by_uuid(uuid)
+ async def get(self, uuid):
+ build = await self.backend.builds.get_by_uuid(uuid)
if not build:
raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
# Fetch all available repositories
try:
- repos = self.current_user.repos[build.distro]
+ repos = await self.current_user.get_repos(build.distro)
except KeyError:
repos = None
- self.render("builds/repos/add.html", build=build, repos=repos)
+ await self.render("builds/repos/add.html", build=build, repos=repos)
@base.authenticated
async def post(self, uuid):
- build = self.backend.builds.get_by_uuid(uuid)
+ build = await self.backend.builds.get_by_uuid(uuid)
if not build:
raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
- slug = self.get_argument("repo")
-
# Fetch the repository
- repo = self.current_user.get_repo(build.distro, slug)
- if not repo:
- raise tornado.web.HTTPError(400, "Could not find repository '%s'" % slug)
+ repo = await self.get_argument_repo("repo", distro=build.distro, user=self.current_user)
# Add the build to the repository
- with self.db.transaction():
+ async with await self.db.transaction():
await repo.add_build(build, user=self.current_user)
self.redirect("/builds/%s" % build.uuid)
class ReposRemoveHandler(base.BaseHandler):
@base.authenticated
- def get(self, uuid):
- build = self.backend.builds.get_by_uuid(uuid)
+ async def get(self, uuid):
+ build = await self.backend.builds.get_by_uuid(uuid)
if not build:
raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
if not build.repos:
raise tornado.web.HTTPError(400)
- self.render("builds/repos/remove.html", build=build)
+ await self.render("builds/repos/remove.html", build=build)
@base.authenticated
async def post(self, uuid):
- build = self.backend.builds.get_by_uuid(uuid)
+ build = await self.backend.builds.get_by_uuid(uuid)
if not build:
raise tornado.web.HTTPError(404, "Could not find build %s" % uuid)
- # Fetch all selected repos
- repos = self.get_arguments("repo")
-
- # Raise an error if nothing has been selected
- if not repos:
- raise tornado.web.HTTPError(400, "No repositories selected")
-
- # Find all selected repositories
- repos = [repo for repo in build.repos if repo.slug in repos]
+ # Fetch the repository
+ repo = await self.get_argument_repo("repo", distro=build.distro, user=self.current_user)
- # Remove build from all repositories
- with self.db.transaction():
- for repo in repos:
- await repo.remove_build(build, user=self.current_user)
+ # Remove build from the repository
+ async with await self.db.transaction():
+ await repo.remove_build(build, user=self.current_user)
self.redirect("/builds/%s" % build.uuid)