def product(self):
return self.settings.get("bugzilla-product")
+ async def get_products(self):
+ """
+ Returns a dictionary with all products and versions
+ """
+ products = {}
+
+ # Fetch all products
+ response = await self._request("GET", "/rest/product", type="accessible")
+
+ # Walk through all products
+ for product in response.get("products", []):
+ # Fetch name
+ name = product.get("name")
+
+ # Fetch versions
+ versions = [v.get("name") for v in product.get("versions")]
+
+ # Add the product and versions
+ products[name] = versions
+
+ return products
+
def make_url(self, *args, **kwargs):
"""
Composes a URL based on the base URL
custom_config = property(get_custom_config, set_custom_config)
+ # Bugzilla Product
+
+ def get_bugzilla_product(self):
+ return self.data.bugzilla_product
+
+ def set_bugzilla_product(self, product):
+ self._set_attribute("bugzilla_product", product)
+
+ bugzilla_product = property(get_bugzilla_product, set_bugzilla_product)
+
+ # Bugzilla Version
+
+ def get_bugzilla_version(self):
+ return self.data.bugzilla_version
+
+ def set_bugzilla_version(self, version):
+ self._set_attribute("bugzilla_version", version)
+
+ bugzilla_version = property(get_bugzilla_version, set_bugzilla_version)
+
+ # Bugzilla Fields
+
+ @property
+ def bugzilla_fields(self):
+ """
+ Short hand to convey all fields for Bugzilla
+ """
+ return {
+ "product" : self.bugzilla_product,
+ "version" : self.bugzilla_version,
+ }
+
# Permissions
def has_perm(self, user):
arches text[] DEFAULT ARRAY[]::text[] NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
custom_config text DEFAULT ''::text NOT NULL,
- codename text DEFAULT ''::text NOT NULL
+ codename text DEFAULT ''::text NOT NULL,
+ bugzilla_product text DEFAULT ''::text NOT NULL,
+ bugzilla_version text DEFAULT ''::text NOT NULL
);
</div>
</div>
+ {# Bugzilla #}
+ {% if bugzilla_products %}
+ <div class="field">
+ <label class="label">{{ _("Bugzilla") }}</label>
+
+ <div class="control">
+ <div class="select">
+ <select name="bugzilla">
+ {% for bugzilla_product in bugzilla_products %}
+ <optgroup label="{{ bugzilla_product }}">
+ {% for bugzilla_version in bugzilla_products[bugzilla_product] %}
+ <option value="{{ bugzilla_product }}:{{ bugzilla_version }}"
+ {% if distro.bugzilla_product == bugzilla_product and distro.bugzilla_version == bugzilla_version %}selected{% end %}>
+ {{ bugzilla_product }} {{ bugzilla_version }}
+ </option>
+ {% end %}
+ </optgroup>
+ {% end %}
+ </select>
+ </div>
+ </div>
+ </div>
+ {% end %}
+
<div class="field is-grouped">
<div class="control">
<button class="button is-success is-link" type="submit">
class EditHandler(base.BaseHandler):
@tornado.web.authenticated
- def get(self, slug):
+ async def get(self, slug):
distro = self.backend.distros.get_by_slug(slug)
if not distro:
raise tornado.web.HTTPError(404, "Could not find distribution: %s" % slug)
+ # Fetch available Bugzilla products
+ bugzilla_products = await self.backend.bugzilla.get_products()
+
# Check for permissions
if not distro.has_perm(self.current_user):
raise tornado.web.HTTPError(403)
- self.render("distros/edit.html", distro=distro)
+ self.render("distros/edit.html", distro=distro, bugzilla_products=bugzilla_products)
@tornado.web.authenticated
def post(self, slug):
distro.slogan = self.get_argument("slogan", None)
distro.arches = self.get_arguments("arches")
+ # Bugzilla Product/Version
+ distro.bugzilla_product, delim, distro.bugzilla_version = \
+ self.get_argument("bugzilla", "").partition(":")
+
self.redirect("/distros/%s" % distro.slug)