From: Michael Tremer Date: Sat, 13 May 2023 11:20:00 +0000 (+0000) Subject: distros: Store Bugzilla product & version X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb2a53d130154d59ff7700dbb4888af3fca42486;p=pbs.git distros: Store Bugzilla product & version Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/bugtracker.py b/src/buildservice/bugtracker.py index f3693f92..677b84a8 100644 --- a/src/buildservice/bugtracker.py +++ b/src/buildservice/bugtracker.py @@ -50,6 +50,28 @@ class Bugzilla(base.Object): 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 diff --git a/src/buildservice/distribution.py b/src/buildservice/distribution.py index e6a7d161..38578d8d 100644 --- a/src/buildservice/distribution.py +++ b/src/buildservice/distribution.py @@ -212,6 +212,38 @@ class Distribution(base.DataObject): 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): diff --git a/src/database.sql b/src/database.sql index 3e1057ec..5ba1e8ff 100644 --- a/src/database.sql +++ b/src/database.sql @@ -343,7 +343,9 @@ CREATE TABLE public.distributions ( 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 ); diff --git a/src/templates/distros/edit.html b/src/templates/distros/edit.html index 6a1c72c0..3f9e0d9b 100644 --- a/src/templates/distros/edit.html +++ b/src/templates/distros/edit.html @@ -90,6 +90,30 @@ + {# Bugzilla #} + {% if bugzilla_products %} +
+ + +
+
+ +
+
+
+ {% end %} +