]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/web/handlers_distro.py
3 from .handlers_base
import *
5 class DistributionListHandler(BaseHandler
):
7 self
.render("distro-list.html", distros
=self
.backend
.distros
)
10 class DistributionDetailHandler(BaseHandler
):
12 distro
= self
.pakfire
.distros
.get_by_name(name
)
14 raise tornado
.web
.HTTPError(404, "Distro not found")
16 self
.render("distro-detail.html", distro
=distro
)
19 class DistributionEditHandler(BaseHandler
):
21 self
.sources
= self
.pakfire
.sources
.get_all()
23 @tornado.web
.authenticated
25 distro
= self
.pakfire
.distros
.get_by_name(name
)
27 raise tornado
.web
.HTTPError(404, "Distro not found")
29 self
.render("distro-edit.html", distro
=distro
,
30 arches
=self
.arches
.get_all(), sources
=self
.sources
)
32 @tornado.web
.authenticated
34 distro
= self
.pakfire
.distros
.get_by_name(name
)
36 raise tornado
.web
.HTTPError(404, "Distro not found")
38 name
= self
.get_argument("name", distro
.name
)
39 vendor
= self
.get_argument("vendor", distro
.vendor
)
40 contact
= self
.get_argument("contact", "")
41 slogan
= self
.get_argument("slogan", distro
.slogan
)
42 tag
= self
.get_argument("tag", "")
44 distro
.set("name", name
)
45 distro
.set("vendor", vendor
)
46 distro
.set("slogan", slogan
)
48 # Update the contact email address.
49 distro
.contact
= contact
54 # Update architectures.
56 for arch
in self
.get_arguments("arches", []):
62 if not self
.arches
.exists(arch_id
):
65 arch
= self
.arches
.get_by_id(arch_id
)
68 distro
.arches
= arches
70 self
.redirect("/distribution/%s" % distro
.sname
)
73 class DistroSourceDetailHandler(BaseHandler
):
74 def get(self
, distro_ident
, source_ident
):
75 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
77 raise tornado
.web
.HTTPError(404, "Distro not found")
79 source
= distro
.get_source(source_ident
)
81 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
82 % (source_ident
, distro
.name
))
84 # Get the latest commits.
85 commits
= source
.get_commits(limit
=5)
87 self
.render("distro-source-detail.html", distro
=distro
, source
=source
,
91 class DistroSourceCommitsHandler(BaseHandler
):
92 def get(self
, distro_ident
, source_ident
):
93 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
95 raise tornado
.web
.HTTPError(404, "Distro not found")
97 source
= distro
.get_source(source_ident
)
99 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
100 % (source_ident
, distro
.name
))
102 offset
= self
.get_argument("offset", 0)
108 limit
= self
.get_argument("limit", 50)
114 commits
= source
.get_commits(limit
=limit
, offset
=offset
)
116 self
.render("distro-source-commits.html", distro
=distro
, source
=source
,
117 commits
=commits
, limit
=limit
, offset
=offset
, number
=50)
120 class DistroSourceCommitDetailHandler(BaseHandler
):
121 def get(self
, distro_ident
, source_ident
, commit_ident
):
122 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
124 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
126 source
= distro
.get_source(source_ident
)
128 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
129 % (source_ident
, distro
.name
))
131 commit
= source
.get_commit(commit_ident
)
133 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
134 % (commit_ident
, source
.name
))
136 self
.render("distro-source-commit-detail.html", distro
=distro
,
137 source
=source
, commit
=commit
)
140 class DistroSourceCommitResetHandler(BaseHandler
):
141 @tornado.web
.authenticated
142 def get(self
, distro_ident
, source_ident
, commit_ident
):
143 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
145 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
147 source
= distro
.get_source(source_ident
)
149 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
150 % (source_ident
, distro
.name
))
152 commit
= source
.get_commit(commit_ident
)
154 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
155 % (commit_ident
, source
.name
))
157 if not self
.current_user
.is_admin():
158 raise tornado
.web
.HTTPError(403)
160 confirmed
= self
.get_argument("confirmed", None)
164 self
.redirect("/distro/%s/source/%s/%s" % \
165 (distro
.identifier
, source
.identifier
, commit
.revision
))
168 self
.render("distro-source-commit-reset.html", distro
=distro
,
169 source
=source
, commit
=commit
)
172 class DistroUpdateCreateHandler(BaseHandler
):
173 def get(self
, distro_ident
):
174 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
176 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
178 # Get all preset builds.
180 for build
in self
.get_arguments("builds", []):
181 build
= self
.pakfire
.builds
.get_by_uuid(build
)
186 self
.render("distro-update-edit.html", update
=None,
187 distro
=distro
, builds
=builds
)
190 class DistroUpdateDetailHandler(BaseHandler
):
191 def get(self
, distro_ident
, year
, num
):
192 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
194 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
196 update
= distro
.get_update(year
, num
)
198 raise tornado
.web
.HTTPError(404, "Update cannot be found: %s %s" % (year
, num
))
200 self
.render("distro-update-detail.html", distro
=distro
,
201 update
=update
, repo
=update
.repo
, user
=update
.user
)
203 # XXX currently unused
204 class SourceListHandler(BaseHandler
):
206 sources
= self
.pakfire
.sources
.get_all()
208 self
.render("source-list.html", sources
=sources
)
211 class SourceDetailHandler(BaseHandler
):
213 source
= self
.pakfire
.sources
.get_by_id(id)
215 self
.render("source-detail.html", source
=source
)