# User profiles
(r"/users", users.UsersHandler),
(r"/users/(\w+)", users.ShowHandler),
+ (r"/users/(?P<user_slug>\w+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)",
+ repos.ShowHandler),
+ (r"/users/(?P<user_slug>\w+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)\.repo",
+ repos.ConfigHandler),
+ (r"/users/(?P<user_slug>\w+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)/builds",
+ repos.BuildsHandler),
+ (r"/users/(?P<user_slug>\w+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)/mirrorlist",
+ repos.MirrorlistHandler),
(r"/user/(\w+)/impersonate", users.UserImpersonateHandler),
(r"/user/(\w+)/delete", users.UserDeleteHandler),
(r"/user/(\w+)/edit", users.UserEditHandler),
# Distributions
(r"/distros", distributions.IndexHandler),
(r"/distros/([A-Za-z0-9\-\.]+)", distributions.ShowHandler),
- (r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)", repos.ShowHandler),
- (r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)\.repo", repos.ConfigHandler),
- (r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)/builds", repos.BuildsHandler),
- (r"/distros/([A-Za-z0-9\-\.]+)/repos/([A-Za-z0-9\-]+)/mirrorlist", repos.MirrorlistHandler),
+ (r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)",
+ repos.ShowHandler),
+ (r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)\.repo",
+ repos.ConfigHandler),
+ (r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)/builds",
+ repos.BuildsHandler),
+ (r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)/mirrorlist",
+ repos.MirrorlistHandler),
(r"/distro/([A-Za-z0-9\-\.]+)/repo/([A-Za-z0-9\-]+)/edit",
RepositoryEditHandler),
from . import base
from . import ui_modules
-class ShowHandler(base.BaseHandler):
- def get(self, distro_slug, repo_slug):
+class BaseHandler(base.BaseHandler):
+ def _get_repo(self, repo_slug, distro_slug=None, user_slug=None):
+ distro = user = None
+
# Find the distribution
- distro = self.backend.distros.get_by_slug(distro_slug)
- if not distro:
- raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
+ if distro_slug:
+ distro = self.backend.distros.get_by_slug(distro_slug)
+ if not distro:
+ raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
+
+ # Find the user
+ if user_slug:
+ user = self.backend.users.get_by_name(user_slug)
+ if not user:
+ raise tornado.web.HTTPError(404, "Could not find user: %s" % user_slug)
+
+ assert distro or user, "Neither distro nor user set"
# Find the repository
- repo = distro.get_repo(repo_slug)
+ repo = (distro or user).get_repo(repo_slug)
if not repo:
raise tornado.web.HTTPError(404, "Could not find repo: %s" % repo_slug)
- self.render("repos/show.html", repo=repo, distro=repo.distro)
+ return repo
+class ShowHandler(BaseHandler):
+ def get(self, **kwargs):
+ # Fetch the repository
+ repo = self._get_repo(**kwargs)
-class BuildsHandler(base.BaseHandler):
- def get(self, distro_slug, repo_slug):
- # Find the distribution
- distro = self.backend.distros.get_by_slug(distro_slug)
- if not distro:
- raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
+ self.render("repos/show.html", repo=repo, distro=repo.distro)
- # Find the repository
- repo = distro.get_repo(repo_slug)
- if not repo:
- raise tornado.web.HTTPError(404, "Could not find repo: %s" % repo_slug)
- self.render("repos/builds.html", repo=repo, distro=repo.distro)
+class BuildsHandler(BaseHandler):
+ def get(self, **kwargs):
+ # Fetch the repository
+ repo = self._get_repo(**kwargs)
+ self.render("repos/builds.html", repo=repo, distro=repo.distro)
-class ConfigHandler(base.BaseHandler):
- def get(self, distro_slug, repo_slug):
- # Find the distribution
- distro = self.backend.distros.get_by_slug(distro_slug)
- if not distro:
- raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
- # Find the repository
- repo = distro.get_repo(repo_slug)
- if not repo:
- raise tornado.web.HTTPError(404, "Could not find repo: %s" % repo_slug)
+class ConfigHandler(BaseHandler):
+ def get(self, **kwargs):
+ # Fetch the repository
+ repo = self._get_repo(**kwargs)
# This is plain text
self.set_header("Content-Type", "text/plain")
self.finish(config)
-class MirrorlistHandler(base.BaseHandler):
- def get(self, distro_slug, repo_slug):
- # Find the distribution
- distro = self.backend.distros.get_by_slug(distro_slug)
- if not distro:
- raise tornado.web.HTTPError(404, "Could not find distro: %s" % distro_slug)
-
- # Find the repository
- repo = distro.get_repo(repo_slug)
- if not repo:
- raise tornado.web.HTTPError(404, "Could not find repo: %s" % repo_slug)
+class MirrorlistHandler(BaseHandler):
+ def get(self, **kwargs):
+ # Fetch the repository
+ repo = self._get_repo(**kwargs)
# Send nothing if repository isn't supposed to be mirrored
if not repo.mirrored: