]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/web/handlers_distro.py
3 from handlers_base
import *
6 class DistributionListHandler(BaseHandler
):
8 distros
= self
.pakfire
.distros
.get_all()
10 self
.render("distro-list.html", distros
=distros
)
13 class DistributionDetailHandler(BaseHandler
):
15 distro
= self
.pakfire
.distros
.get_by_name(name
)
17 raise tornado
.web
.HTTPError(404, "Distro not found")
19 self
.render("distro-detail.html", distro
=distro
)
22 class DistributionEditHandler(BaseHandler
):
24 self
.sources
= self
.pakfire
.sources
.get_all()
26 @tornado.web
.authenticated
28 distro
= self
.pakfire
.distros
.get_by_name(name
)
30 raise tornado
.web
.HTTPError(404, "Distro not found")
32 self
.render("distro-edit.html", distro
=distro
,
33 arches
=self
.arches
.get_all(), sources
=self
.sources
)
35 @tornado.web
.authenticated
37 distro
= self
.pakfire
.distros
.get_by_name(name
)
39 raise tornado
.web
.HTTPError(404, "Distro not found")
41 name
= self
.get_argument("name", distro
.name
)
42 vendor
= self
.get_argument("vendor", distro
.vendor
)
43 contact
= self
.get_argument("contact", "")
44 slogan
= self
.get_argument("slogan", distro
.slogan
)
45 tag
= self
.get_argument("tag", "")
47 distro
.set("name", name
)
48 distro
.set("vendor", vendor
)
49 distro
.set("slogan", slogan
)
51 # Update the contact email address.
52 distro
.contact
= contact
57 # Update architectures.
59 for arch
in self
.get_arguments("arches", []):
65 if not self
.arches
.exists(arch_id
):
68 arch
= self
.arches
.get_by_id(arch_id
)
71 distro
.arches
= arches
73 self
.redirect("/distribution/%s" % distro
.sname
)
76 class DistroSourceDetailHandler(BaseHandler
):
77 def get(self
, distro_ident
, source_ident
):
78 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
80 raise tornado
.web
.HTTPError(404, "Distro not found")
82 source
= distro
.get_source(source_ident
)
84 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
85 % (source_ident
, distro
.name
))
87 # Get the latest commits.
88 commits
= source
.get_commits(limit
=5)
90 self
.render("distro-source-detail.html", distro
=distro
, source
=source
,
94 class DistroSourceCommitsHandler(BaseHandler
):
95 def get(self
, distro_ident
, source_ident
):
96 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
98 raise tornado
.web
.HTTPError(404, "Distro not found")
100 source
= distro
.get_source(source_ident
)
102 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
103 % (source_ident
, distro
.name
))
105 offset
= self
.get_argument("offset", 0)
111 limit
= self
.get_argument("limit", 50)
117 commits
= source
.get_commits(limit
=limit
, offset
=offset
)
119 self
.render("distro-source-commits.html", distro
=distro
, source
=source
,
120 commits
=commits
, limit
=limit
, offset
=offset
, number
=50)
123 class DistroSourceCommitDetailHandler(BaseHandler
):
124 def get(self
, distro_ident
, source_ident
, commit_ident
):
125 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
127 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
129 source
= distro
.get_source(source_ident
)
131 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
132 % (source_ident
, distro
.name
))
134 commit
= source
.get_commit(commit_ident
)
136 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
137 % (commit_ident
, source
.name
))
139 self
.render("distro-source-commit-detail.html", distro
=distro
,
140 source
=source
, commit
=commit
)
143 class DistroSourceCommitResetHandler(BaseHandler
):
144 @tornado.web
.authenticated
145 def get(self
, distro_ident
, source_ident
, commit_ident
):
146 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
148 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
150 source
= distro
.get_source(source_ident
)
152 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
153 % (source_ident
, distro
.name
))
155 commit
= source
.get_commit(commit_ident
)
157 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
158 % (commit_ident
, source
.name
))
160 if not self
.current_user
.is_admin():
161 raise tornado
.web
.HTTPError(403)
163 confirmed
= self
.get_argument("confirmed", None)
167 self
.redirect("/distro/%s/source/%s/%s" % \
168 (distro
.identifier
, source
.identifier
, commit
.revision
))
171 self
.render("distro-source-commit-reset.html", distro
=distro
,
172 source
=source
, commit
=commit
)
175 class DistroUpdateCreateHandler(BaseHandler
):
176 def get(self
, distro_ident
):
177 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
179 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
181 # Get all preset builds.
183 for build
in self
.get_arguments("builds", []):
184 build
= self
.pakfire
.builds
.get_by_uuid(build
)
189 self
.render("distro-update-edit.html", update
=None,
190 distro
=distro
, builds
=builds
)
193 class DistroUpdateDetailHandler(BaseHandler
):
194 def get(self
, distro_ident
, year
, num
):
195 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
197 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
199 update
= distro
.get_update(year
, num
)
201 raise tornado
.web
.HTTPError(404, "Update cannot be found: %s %s" % (year
, num
))
203 self
.render("distro-update-detail.html", distro
=distro
,
204 update
=update
, repo
=update
.repo
, user
=update
.user
)
206 # XXX currently unused
207 class SourceListHandler(BaseHandler
):
209 sources
= self
.pakfire
.sources
.get_all()
211 self
.render("source-list.html", sources
=sources
)
214 class SourceDetailHandler(BaseHandler
):
216 source
= self
.pakfire
.sources
.get_by_id(id)
218 self
.render("source-detail.html", source
=source
)