Mercurial > kallithea
diff rhodecode/controllers/admin/gists.py @ 3843:ad4a680113b7 beta
Gist: implemented delete of gists by owner, or super admin
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 11 May 2013 23:19:06 +0200 |
parents | dc4644865e8b |
children | bec04f371579 |
line wrap: on
line diff
--- a/rhodecode/controllers/admin/gists.py Sat May 11 22:43:54 2013 +0200 +++ b/rhodecode/controllers/admin/gists.py Sat May 11 23:19:06 2013 +0200 @@ -41,7 +41,7 @@ from rhodecode.lib.auth import LoginRequired, NotAnonymous from rhodecode.lib.utils2 import safe_str, safe_int, time_to_datetime from rhodecode.lib.helpers import Page -from webob.exc import HTTPNotFound +from webob.exc import HTTPNotFound, HTTPForbidden from sqlalchemy.sql.expression import or_ from rhodecode.lib.vcs.exceptions import VCSError @@ -151,6 +151,16 @@ # h.form(url('gist', id=ID), # method='delete') # url('gist', id=ID) + gist = GistModel().get_gist(id) + owner = gist.gist_owner == c.rhodecode_user.user_id + if h.HasPermissionAny('hg.admin')() or owner: + GistModel().delete(gist) + Session().commit() + h.flash(_('Deleted gist %s') % gist.gist_access_id, category='success') + else: + raise HTTPForbidden() + + return redirect(url('gists')) @LoginRequired() def show(self, id, format='html'):