return [self.get_by_id(b.id, b) for b in self.db.query(query)]
- def get_by_user(self, user, type=None, public=None):
+ def get_by_user(self, user, type=None):
args = []
conditions = []
elif not type or type == "release":
pass # TODO
- if public is True:
- conditions.append("public = 'Y'")
- elif public is False:
- conditions.append("public = 'N'")
-
query = "SELECT builds.* AS id FROM builds \
JOIN packages ON builds.pkg_id = packages.id"
return builds
- def get_by_name(self, name, type=None, public=None, user=None, limit=None, offset=None):
+ def get_by_name(self, name, type=None, user=None, limit=None, offset=None):
args = [name,]
conditions = [
"packages.name = %s",
args.append(type)
or_conditions = []
- if public is True:
- or_conditions.append("public = 'Y'")
- elif public is False:
- or_conditions.append("public = 'N'")
-
if user and not user.is_admin():
or_conditions.append("builds.owner_id = %s")
args.append(user.id)
return [Build(self.backend, b.id, b) for b in self.db.query(query, *args)]
- def get_latest_by_name(self, name, type=None, public=None):
+ def get_latest_by_name(self, name, type=None):
query = "\
SELECT * FROM builds \
LEFT JOIN builds_latest ON builds.id = builds_latest.build_id \
query += " AND builds_latest.build_type = %s"
args.append(type)
- if public is True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public is False:
- query += " AND builds.public = %s"
- args.append("N")
-
# Get the last one only.
# Prefer release builds over scratch builds.
query += "\
if res:
return Build(self.backend, res.id, res)
- def get_active_builds(self, name, public=None):
+ def get_active_builds(self, name):
query = "\
SELECT * FROM builds \
LEFT JOIN builds_latest ON builds.id = builds_latest.build_id \
WHERE builds_latest.package_name = %s AND builds.type = %s"
args = [name, "release"]
- if public is True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public is False:
- query += " AND builds.public = %s"
- args.append("N")
-
builds = []
for row in self.db.query(query, *args):
b = Build(self.backend, row.id, row)
return build
- def get_changelog(self, name, public=None, limit=5, offset=0):
+ def get_changelog(self, name, limit=5, offset=0):
query = "SELECT builds.* FROM builds \
JOIN packages ON builds.pkg_id = packages.id \
WHERE \
packages.name = %s"
args = ["release", name,]
- if public == True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public == False:
- query += " AND builds.public = %s"
- args.append("N")
-
query += " ORDER BY builds.time_created DESC"
if limit:
def date(self):
return self.created.date()
- @property
- def public(self):
- """
- Is this build public?
- """
- return self.data.public
-
@lazy_property
def size(self):
"""
return self._get_package("SELECT * FROM packages \
WHERE id = %s", pkg_id)
- def get_all_names(self, public=None, user=None, states=None):
+ def get_all_names(self, user=None, states=None):
query = "SELECT DISTINCT packages.name AS name, summary FROM packages \
JOIN builds ON builds.pkg_id = packages.id \
WHERE packages.type = 'source'"
conditions = []
args = []
- if public in (True, False):
- if public is True:
- public = "Y"
- elif public is False:
- public = "N"
-
- conditions.append("builds.public = %s")
- args.append(public)
-
if user and not user.is_admin():
conditions.append("builds.owner_id = %s")
args.append(user.id)
ALTER TYPE builds_history_action OWNER TO pakfire;
---
--- Name: builds_public; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE builds_public AS ENUM (
- 'Y',
- 'N'
-);
-
-
-ALTER TYPE builds_public OWNER TO pakfire;
-
--
-- Name: builds_severity; Type: TYPE; Schema: public; Owner: pakfire
--
depends_on integer,
distro_id integer NOT NULL,
owner_id integer,
- public boolean DEFAULT true NOT NULL,
priority integer DEFAULT 0 NOT NULL,
auto_move boolean DEFAULT false NOT NULL
);
if not job:
raise tornado.web.HTTPError(404, "Could not find job: %s" % job_uuid)
- # Check if user is allowed to view this job.
- if job.build.public == False:
- if not self.user:
- raise tornado.web.HTTPError(401)
-
- # Check if an authenticated user has permission to see this build.
- if not job.build.has_perm(self.user):
- raise tornado.web.HTTPError(403)
-
ret = self.job2json(job)
self.finish(ret)
@property
def mirrors(self):
- return self.pakfire.mirrors
-
- @property
- def public(self):
- """
- Indicates what level of public/non-public things a user
- may see.
- """
- if self.current_user and self.current_user.is_admin():
- public = None
- else:
- public = True
-
- return public
+ return self.pakfire.mirrors
\ No newline at end of file
states = ["building", "stable", "testing"]
# Get all packages that fulfill the required parameters.
- pkgs = self.pakfire.packages.get_all_names(public=self.public,
+ pkgs = self.pakfire.packages.get_all_names(
user=self.current_user, states=states)
# Sort all packages in an array like "<first char>" --> [packages, ...]
class PackageNameHandler(BaseHandler):
def get(self, name):
- builds = self.pakfire.builds.get_active_builds(name, public=self.public)
+ builds = self.pakfire.builds.get_active_builds(name)
if not builds:
raise tornado.web.HTTPError(404, "Package '%s' was not found" % name)
limit = self.get_argument("limit", 10)
scratch_builds = self.pakfire.builds.get_by_name(name, type="scratch",
- public=self.public, limit=limit, offset=offset)
+ limit=limit, offset=offset)
if scratch_builds:
latest_build = scratch_builds[0]
else:
- release_builds = self.pakfire.builds.get_by_name(name, type="release", public=self.public, limit=1)
+ release_builds = self.pakfire.builds.get_by_name(name, type="release", limit=1)
if not release_builds:
raise tornado.web.HTTPError(404, "Could not find any build with this name: %s" % name)
class PackagePropertiesHandler(BaseHandler):
@tornado.web.authenticated
def get(self, name):
- build = self.pakfire.builds.get_latest_by_name(name, public=self.public)
+ build = self.pakfire.builds.get_latest_by_name(name)
if not build:
raise tornado.web.HTTPError(404, "Package '%s' was not found" % name)
@tornado.web.authenticated
def post(self, name):
- build = self.pakfire.builds.get_latest_by_name(name, public=self.public)
+ build = self.pakfire.builds.get_latest_by_name(name)
if not build:
raise tornado.web.HTTPError(404, "Package '%s' was not found" % name)
class PackageBuildsTimesHandler(BaseHandler):
def get(self, name):
- latest_build = self.pakfire.builds.get_latest_by_name(name, type="release",
- public=self.public)
+ latest_build = self.pakfire.builds.get_latest_by_name(name, type="release")
# If no build with this name was found, we cannot go on.
if not latest_build:
if not user:
raise tornado.web.HTTPError(404, "User not found: %s" % name)
- # By default users see only public builds.
- # Admins are allowed to see all builds.
- public = True
- if self.current_user and self.current_user.is_admin():
- public = None
-
# Get a list of the builds this user has built.
- builds = self.pakfire.builds.get_by_user(user, public=public)
+ builds = self.pakfire.builds.get_by_user(user)
self.render("user-profile-builds.html", user=user, builds=builds)