[copr] bkabrda-workspace: Last couple of fixes to allow copr_admins to edit copr. (5508aa7)

bkabrda at fedorahosted.org bkabrda at fedorahosted.org
Mon Nov 26 12:55:22 UTC 2012


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : bkabrda-workspace

>---------------------------------------------------------------

commit 5508aa79efca002276548828bc65a9a0b469f126
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Mon Nov 26 13:55:11 2012 +0100

    Last couple of fixes to allow copr_admins to edit copr.


>---------------------------------------------------------------

 wsgi/coprs/models.py                       |    2 +-
 wsgi/coprs/templates/coprs/detail.html     |    2 +-
 wsgi/coprs/views/coprs_ns/coprs_general.py |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/wsgi/coprs/models.py b/wsgi/coprs/models.py
index 63f5259..73166f6 100644
--- a/wsgi/coprs/models.py
+++ b/wsgi/coprs/models.py
@@ -80,7 +80,7 @@ class User(db.Model, Serializer):
         can_edit = False
         if copr.owner == self:
             can_edit = True
-        if self.permissions_for_copr(copr) and self.permissions_for_copr.copr_admin == helpers.PermissionEnum.num('Approved'):
+        if self.permissions_for_copr(copr) and self.permissions_for_copr(copr).copr_admin == helpers.PermissionEnum.num('Approved'):
             can_edit = True
 
         return can_edit
diff --git a/wsgi/coprs/templates/coprs/detail.html b/wsgi/coprs/templates/coprs/detail.html
index 2eb1989..30b653c 100644
--- a/wsgi/coprs/templates/coprs/detail.html
+++ b/wsgi/coprs/templates/coprs/detail.html
@@ -31,7 +31,7 @@
     <h3>Build packages in this repo:</h3>
     {{ copr_build_form(build_form, 'coprs_ns.copr_add_build', copr) }}
   {% endif %}
-  {% if g.user and g.user.id == copr.owner_id %}
+  {% if g.user and g.user.can_edit(copr) %}
     <a href="{{ url_for('coprs_ns.copr_edit', username = copr.owner.name, coprname = copr.name) }}">Edit this Copr</a>
   {% endif %}
   {% if copr.builds %}
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/wsgi/coprs/views/coprs_ns/coprs_general.py
index e1638f1..4cd2abf 100644
--- a/wsgi/coprs/views/coprs_ns/coprs_general.py
+++ b/wsgi/coprs/views/coprs_ns/coprs_general.py
@@ -117,7 +117,7 @@ def copr_update(username, coprname):
     form = forms.CoprForm()
     copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first()
     # only owner can update a copr
-    if flask.g.user != copr.owner:
+    if not flask.g.user.can_edit(copr):
         flask.flash('Only owners may update their Coprs.')
         return flask.redirect(flask.url_for('coprs_ns.copr_detail', username = copr.owner.name, coprname = form.name.data))
 



More information about the copr-devel mailing list