]>
git.ipfire.org Git - pbs.git/blob - src/web/handlers_distro.py
8b8148779e3030c25afbfc22f83e797e5fe9a0f5
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
.backend
.arches
, 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", []):
57 # Check if arch exists
58 if not self
.backend
.arches
.exists(arch
):
63 distro
.arches
= arches
65 self
.redirect("/distribution/%s" % distro
.sname
)
68 class DistroSourceDetailHandler(BaseHandler
):
69 def get(self
, distro_ident
, source_ident
):
70 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
72 raise tornado
.web
.HTTPError(404, "Distro not found")
74 source
= distro
.get_source(source_ident
)
76 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
77 % (source_ident
, distro
.name
))
79 # Get the latest commits.
80 commits
= source
.get_commits(limit
=5)
82 self
.render("distro-source-detail.html", distro
=distro
, source
=source
,
86 class DistroSourceCommitsHandler(BaseHandler
):
87 def get(self
, distro_ident
, source_ident
):
88 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
90 raise tornado
.web
.HTTPError(404, "Distro not found")
92 source
= distro
.get_source(source_ident
)
94 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
95 % (source_ident
, distro
.name
))
97 offset
= self
.get_argument("offset", 0)
103 limit
= self
.get_argument("limit", 50)
109 commits
= source
.get_commits(limit
=limit
, offset
=offset
)
111 self
.render("distro-source-commits.html", distro
=distro
, source
=source
,
112 commits
=commits
, limit
=limit
, offset
=offset
, number
=50)
115 class DistroSourceCommitDetailHandler(BaseHandler
):
116 def get(self
, distro_ident
, source_ident
, commit_ident
):
117 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
119 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
121 source
= distro
.get_source(source_ident
)
123 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
124 % (source_ident
, distro
.name
))
126 commit
= source
.get_commit(commit_ident
)
128 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
129 % (commit_ident
, source
.name
))
131 self
.render("distro-source-commit-detail.html", distro
=distro
,
132 source
=source
, commit
=commit
)
135 class DistroSourceCommitResetHandler(BaseHandler
):
136 @tornado.web
.authenticated
137 def get(self
, distro_ident
, source_ident
, commit_ident
):
138 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
140 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
142 source
= distro
.get_source(source_ident
)
144 raise tornado
.web
.HTTPError(404, "Source '%s' not found in distro '%s'" \
145 % (source_ident
, distro
.name
))
147 commit
= source
.get_commit(commit_ident
)
149 raise tornado
.web
.HTTPError(404, "Commit '%s' not found in source '%s'" \
150 % (commit_ident
, source
.name
))
152 if not self
.current_user
.is_admin():
153 raise tornado
.web
.HTTPError(403)
155 confirmed
= self
.get_argument("confirmed", None)
159 self
.redirect("/distro/%s/source/%s/%s" % \
160 (distro
.identifier
, source
.identifier
, commit
.revision
))
163 self
.render("distro-source-commit-reset.html", distro
=distro
,
164 source
=source
, commit
=commit
)
167 class DistroUpdateCreateHandler(BaseHandler
):
168 def get(self
, distro_ident
):
169 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
171 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
173 # Get all preset builds.
175 for build
in self
.get_arguments("builds", []):
176 build
= self
.pakfire
.builds
.get_by_uuid(build
)
181 self
.render("distro-update-edit.html", update
=None,
182 distro
=distro
, builds
=builds
)
185 class DistroUpdateDetailHandler(BaseHandler
):
186 def get(self
, distro_ident
, year
, num
):
187 distro
= self
.pakfire
.distros
.get_by_name(distro_ident
)
189 raise tornado
.web
.HTTPError(404, "Distribution '%s' not found" % distro_ident
)
191 update
= distro
.get_update(year
, num
)
193 raise tornado
.web
.HTTPError(404, "Update cannot be found: %s %s" % (year
, num
))
195 self
.render("distro-update-detail.html", distro
=distro
,
196 update
=update
, repo
=update
.repo
, user
=update
.user
)
198 # XXX currently unused
199 class SourceListHandler(BaseHandler
):
201 sources
= self
.pakfire
.sources
.get_all()
203 self
.render("source-list.html", sources
=sources
)
206 class SourceDetailHandler(BaseHandler
):
208 source
= self
.pakfire
.sources
.get_by_id(id)
210 self
.render("source-detail.html", source
=source
)