Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
commit f21e3462ff5c9d63f2bb6b661819c726029b2306 Author: Bohuslav Kabrda bkabrda@redhat.com Date: Tue Apr 2 13:47:15 2013 +0200
Admins can delete coprs now
coprs_frontend/coprs/logic/coprs_logic.py | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/coprs/logic/coprs_logic.py b/coprs_frontend/coprs/logic/coprs_logic.py index d5cf340..2c15df0 100644 --- a/coprs_frontend/coprs/logic/coprs_logic.py +++ b/coprs_frontend/coprs/logic/coprs_logic.py @@ -121,8 +121,7 @@ class CoprsLogic(object):
@classmethod def delete(cls, user, copr, check_for_duplicates=True): - if not copr.owner == user: - raise exceptions.InsufficientRightsException('Only owners may delete their Coprs.') + cls.raise_if_cant_delete(user, copr) # TODO: do we want to dump the information somewhere, so that we can search it in future? cls.raise_if_unfinished_blocking_action(user, copr, 'Can't delete this Copr, another operation is in progress: {action}') @@ -170,6 +169,14 @@ class CoprsLogic(object): if unfinished_actions: raise exceptions.ActionInProgressException(message, unfinished_actions[0])
+ @classmethod + def raise_if_cant_delete(cls, user, copr): + """This method raises InsufficientRightsException if given copr cant be deleted + by given user. Returns None otherwise. + """ + if not user.admin and user != copr.owner: + raise exceptions.InsufficientRightsException('Only owners may delete their Coprs.') + class CoprPermissionsLogic(object): @classmethod def get(cls, user, copr, searched_user):
copr-devel@lists.stg.fedorahosted.org