bodhi/controllers.py | 28 +++++++++++++++++++++++++---
bodhi/templates/master.kid | 2 +-
start-bodhi | 1 -
3 files changed, 26 insertions(+), 5 deletions(-)
New commits:
commit 14b29e9e0ea3c89e65a94d15dd042bc07b9f0204
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Aug 5 16:32:10 2008 -0400
Apply a modified patch from J5 to add a get_auth parameter to the list() method.
This patch allows for the ``get_auth`` argument to the list method, which if
True, will check to see if the current user has rights to modify the request
for release. A 'can_modify' key will be inserted into the returning
dictionary
that contains this value.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index a3e49de..6c13b5b 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -178,15 +178,20 @@ class Root(controllers.RootController):
@expose(template="bodhi.templates.list", allow_json=True)
@paginate('updates', limit=20, allow_limit_override=True)
def list(self, release=None, bugs=None, cves=None, status=None, type_=None,
- package=None, mine=False, stringify=False):
+ package=None, mine=False, stringify=False, get_auth=False):
""" Return a list of updates based on given parameters
"""
- log.debug("list(%s, %s, %s, %s, %s, %s, %s, %s)" % (release, bugs,
cves,
- status, type_, package, mine, stringify))
+ log.debug("list(%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (release, bugs,
+ cves, status, type_, package, mine, stringify, get_auth))
query = []
updates = []
try:
if release:
+ # TODO: if a specific release is requested along with get_auth,
+ # and it is not found in PackageUpdate we should add.
+ # another value to the output which indicates if the.
+ # logged in user is allowed to create a new update for.
+ # this package
rel = Release.byName(release.upper())
query.append(PackageUpdate.q.releaseID == rel.id)
if status:
@@ -250,6 +255,23 @@ class Root(controllers.RootController):
if request_format() == 'json':
return dict(updates=[])
+ # if get_auth is True add can_modify flag and check if the current user
+ # is allowed to modify the request
+ if get_auth:
+ results = []
+ for up in updates:
+ can_modify = False
+ if not identity.current.anonymous:
+ people, groups = get_pkg_pushers(up.builds[0].package.name,
+ up.release.id_prefix.capitalize(),
+ up.release.get_version())
+ if (identity.current.user_name in people[0]):
+ can_modify = True
+ dict_up = dict(up._reprItems())
+ dict_up['can_modify'] = can_modify
+ results.append(dict_up)
+ updates = results
+
if isinstance(updates, list): num_items = len(updates)
else: num_items = updates.count()
if stringify: updates = map(unicode, updates)
commit c44e298d9dc8ebc438f4f52a4d602268e377b1ad
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Aug 5 16:13:05 2008 -0400
Remove an unnecessary __requires__ from the start-bodhi script
diff --git a/start-bodhi b/start-bodhi
index 2ba34c2..1c51f71 100755
--- a/start-bodhi
+++ b/start-bodhi
@@ -1,6 +1,5 @@
#!/usr/bin/python -tt
""" Start script for bodhi """
-#__requires__='bodhi'
from bodhi.commands import start, ConfigurationError
if __name__ == '__main__':
commit 992af7c8a6d8e2ca092ae3b005aefac06b46008f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Aug 1 17:51:54 2008 -0400
Fix the security links on our main toolbar
diff --git a/bodhi/templates/master.kid b/bodhi/templates/master.kid
index f479a31..7587a99 100644
--- a/bodhi/templates/master.kid
+++ b/bodhi/templates/master.kid
@@ -98,7 +98,7 @@ $(document).ready(function() {
<a href="${tg.url('/%s/%s' %
(release['name'], status != 'stable' and status or ''))}"
class="link">${status.title()} (${release['num_' +
status]})</a> <a
href="${tg.url('/rss/rss2.0?release=%s&status=%s' %
(release['name'], status))}" class="rsslink"><img
src="${tg.url('/static/images/rss.png')}" /></a>
</li>
<li class="release">
- <a href="${tg.url('/%s/%s' %
(release['name'], status))}" class="link">Security
(${release['num_security']})</a> <a
href="${tg.url('/rss/rss2.0?release=%s&type=security' %
release['name'])}" class="rsslink"><img
src="${tg.url('/static/images/rss.png')}" /></a>
+ <a href="${tg.url('/%s/security' %
release['name'])}" class="link">Security
(${release['num_security']})</a> <a
href="${tg.url('/rss/rss2.0?release=%s&type=security' %
release['name'])}" class="rsslink"><img
src="${tg.url('/static/images/rss.png')}" /></a>
</li>
</ul>
</div>