[copr] bkabrda-workspace: Allow admins to modify copr permissions (8d3ced3)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 8d3ced312bda655d4be4cbff4497c157534aa568
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 27 13:58:58 2012 +0100
Allow admins to modify copr permissions
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_general.py | 2 +-
.../tests/test_views/test_coprs_ns/test_general.py | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 217558d..a32b4e5 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -172,7 +172,7 @@ def copr_update_permissions(username, coprname):
permissions_form = forms.DynamicPermissionsFormFactory.create_form_cls(permissions)()
# only owner can update copr permissions
- if flask.g.user != copr.owner:
+ if not flask.g.user.can_edit(copr):
flask.flash('Only owners may update their Coprs permissions.')
return flask.redirect(flask.url_for('coprs_ns.copr_detail', username = copr.owner.name, coprname = copr.name))
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
index 9793245..a30731e 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
@@ -228,3 +228,15 @@ class TestCoprUpdatePermissions(CoprsTestCase):
first()
assert u3_c3_perms.copr_builder == self.helpers.PermissionEnum.num('No Action')
assert u3_c3_perms.copr_admin == self.helpers.PermissionEnum.num('Approved')
+
+ def test_copr_admin_can_update_permissions(self, f_users, f_coprs, f_copr_permissions):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ self.db.session.add_all([self.u2, self.c3])
+ r = c.post('/coprs/detail/{0}/{1}/update_permissions/'.format(self.u2.name, self.c3.name),
+ data = {'copr_builder_1': 'y', 'copr_admin_3': 'y'},
+ follow_redirects = True)
+
+ assert 'Copr permissions were updated' in r.data
11 years, 4 months
[copr] bkabrda-workspace: Remove this TODO... (d1f6144)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit d1f6144f84c9febf83cd71de85807e031664db7f
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 27 13:52:07 2012 +0100
Remove this TODO...
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_general.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 68c26c1..217558d 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -150,7 +150,7 @@ def copr_permissions_applier_change(username, coprname):
return page_not_found('Copr with name {0} does not exist.'.format(name))
if copr.owner == flask.g.user:
flask.flash('Owner cannot request permissions for his own copr.')
- else: # TODO: pull this into logic
+ else:
new_builder = int(applier_permissions_form.copr_builder.data)
new_admin = int(applier_permissions_form.copr_admin.data)
try:
11 years, 4 months
[copr] bkabrda-workspace: Pull applying for permissions into logic (f2a4319)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit f2a4319461104bb959988a7c88498de760f88f95
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 27 13:51:12 2012 +0100
Pull applying for permissions into logic
>---------------------------------------------------------------
coprs_frontend/coprs/logic/coprs_logic.py | 21 +++++++++++++++
.../coprs/views/coprs_ns/coprs_general.py | 27 +++++--------------
.../tests/test_views/test_coprs_ns/test_general.py | 2 +-
3 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/coprs_frontend/coprs/logic/coprs_logic.py b/coprs_frontend/coprs/logic/coprs_logic.py
index 98371e0..2ec3184 100644
--- a/coprs_frontend/coprs/logic/coprs_logic.py
+++ b/coprs_frontend/coprs/logic/coprs_logic.py
@@ -83,5 +83,26 @@ class CoprsPermissionLogic(object):
db.session.add(copr_permission)
@classmethod
+ def update_permissions_by_applier(cls, user, copr, copr_permission, new_builder, new_admin):
+ approved_num = helpers.PermissionEnum.num('Approved')
+ if copr_permission:
+ prev_builder = permission.copr_builder
+ prev_admin = permission.copr_admin
+ # if we had Approved before, we can have it now, otherwise not
+ if new_builder == approved_num and prev_builder != new_builder or \
+ new_admin == approved_num and prev_admin != new_admin:
+ raise exceptions.InsufficientRightsException('User can\'t approve himself.')
+ else:
+ copr_permission.copr_builder = new_builder
+ copr_permission.copr_admin = new_admin
+ else:
+ if new_builder == approved_num or new_admin == approved_num:
+ raise exceptions.InsufficientRightsException('User can\'t approve himself.')
+ else:
+ perm = models.CoprPermission(user = user, copr = copr, copr_builder = new_builder, copr_admin = new_admin)
+ cls.new(user, perm)
+
+
+ @classmethod
def delete(cls, user, copr_permission):
db.session.delete(copr_permission)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 8c4c2c0..68c26c1 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -3,6 +3,7 @@ import time
import flask
from coprs import db, page_not_found
+from coprs import exceptions
from coprs import forms
from coprs import helpers
from coprs import models
@@ -152,27 +153,13 @@ def copr_permissions_applier_change(username, coprname):
else: # TODO: pull this into logic
new_builder = int(applier_permissions_form.copr_builder.data)
new_admin = int(applier_permissions_form.copr_admin.data)
- approved_num = helpers.PermissionEnum.num('Approved')
- if permission:
- prev_builder = permission.copr_builder
- prev_admin = permission.copr_admin
- # if we had Approved before, we can have it now, otherwise not
- if new_builder == approved_num and prev_builder != new_builder or \
- new_admin == approved_num and prev_admin != new_admin:
- flask.flash('User can\'t approve himself.')
- else:
- permission.copr_builder = new_builder
- permission.copr_admin = new_admin
- db.session.commit()
- flask.flash('Successfuly updated permissions in Copr "{0}".'.format(copr.name))
+ try:
+ coprs_logic.CoprsPermissionLogic.update_permissions_by_applier(flask.g.user, copr, permission, new_builder, new_admin)
+ except exceptions.InsufficientRightsException as ex:
+ flask.flash(ex.message)
else:
- if new_builder == approved_num or new_admin == approved_num:
- flask.flash('User can\'t approve himself.')
- else:
- perm = models.CoprPermission(user = flask.g.user, copr = copr, copr_builder = new_builder, copr_admin = new_admin)
- coprs_logic.CoprsPermissionLogic.new(flask.g.user, perm)
- db.session.commit()
- flask.flash('Successfuly applied for permissions in Copr "{0}".'.format(copr.name))
+ flask.flash('Successfuly updated permissions do Copr "{0}".'.format(copr.name))
+ db.session.commit()
return flask.redirect(flask.url_for('coprs_ns.copr_detail', username = copr.owner.name, coprname = copr.name))
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
index d02c473..9793245 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
@@ -184,7 +184,7 @@ class TestCoprApplyForPermissions(CoprsTestCase):
r = c.post('/coprs/detail/{0}/{1}/permissions_applier_change/'.format(self.u1.name, self.c1.name),
data = {'copr_builder': 1, 'copr_admin': 0},
follow_redirects = True)
- assert 'Successfuly applied' in r.data
+ assert 'Successfuly updated' in r.data
self.db.session.add_all([self.u1, self.u2, self.c1])
new_perm = self.models.CoprPermission.query.filter(self.models.CoprPermission.user_id == self.u2.id).\
11 years, 4 months
[copr] bkabrda-workspace: Fix the apache conf example (531bc59)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 531bc59d7fcf0949bb021c351d95fee3c024c302
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 27 13:25:05 2012 +0100
Fix the apache conf example
>---------------------------------------------------------------
coprs_frontend/coprs.conf.example | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/coprs.conf.example b/coprs_frontend/coprs.conf.example
index b0b0cfa..98bf98b 100644
--- a/coprs_frontend/coprs.conf.example
+++ b/coprs_frontend/coprs.conf.example
@@ -2,13 +2,13 @@
ServerName 127.0.0.1
WSGIDaemonProcess 127.0.0.1 user=coprs group=coprs threads=5
- WSGIScriptAlias / /var/www/wsgi/application
+ WSGIScriptAlias / /var/www/coprs_frontend/application
WSGIProcessGroup 127.0.0.1
ErrorLog logs/error_coprs
CustomLog logs/access_coprs common
- <Directory /var/www/wsgi>
+ <Directory /var/www/coprs_frontend>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
11 years, 4 months
[copr] bkabrda-workspace: Get rid of the OpenShift stuff, rename the containing dir to coprs_frontend, include sample apache config file (7632011)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 7632011f74598fcbdf43365461589d5161583c48
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 27 13:22:49 2012 +0100
Get rid of the OpenShift stuff, rename the containing dir to coprs_frontend, include sample apache config file
>---------------------------------------------------------------
{wsgi => coprs_frontend}/TODO | 0
{wsgi => coprs_frontend}/alembic.ini | 0
{wsgi => coprs_frontend}/alembic/env.py | 0
{wsgi => coprs_frontend}/alembic/script.py.mako | 0
.../versions/595a31c145fb_initial_db_setup.py | 0
coprs_frontend/application | 12 ++++++++++++
coprs_frontend/coprs.conf.example | 16 ++++++++++++++++
{wsgi => coprs_frontend}/coprs/__init__.py | 0
{wsgi => coprs_frontend}/coprs/config.py | 15 ++++-----------
{wsgi => coprs_frontend}/coprs/constants.py | 0
{wsgi => coprs_frontend}/coprs/exceptions.py | 0
{wsgi => coprs_frontend}/coprs/filters.py | 0
{wsgi => coprs_frontend}/coprs/forms.py | 0
{wsgi => coprs_frontend}/coprs/helpers.py | 0
.../coprs/logic/.coprs_logic.py.swo | Bin 12288 -> 12288 bytes
{wsgi => coprs_frontend}/coprs/logic/__init__.py | 0
.../coprs/logic/builds_logic.py | 0
.../coprs/logic/coprs_logic.py | 0
{wsgi => coprs_frontend}/coprs/models.py | 0
{wsgi => coprs_frontend}/coprs/static/README | 0
{wsgi => coprs_frontend}/coprs/static/style.css | 0
{wsgi => coprs_frontend}/coprs/templates/404.html | 0
.../coprs/templates/_helpers.html | 0
.../coprs/templates/coprs/_builds_table.html | 0
.../coprs/templates/coprs/_coprs_forms.html | 0
.../coprs/templates/coprs/_permissions_table.html | 0
.../coprs/templates/coprs/add.html | 0
.../coprs/templates/coprs/detail.html | 0
.../coprs/templates/coprs/edit.html | 0
.../coprs/templates/coprs/show.html | 0
.../coprs/templates/coprs/show_builds.html | 0
.../coprs/templates/layout.html | 0
.../coprs/templates/login.html | 0
{wsgi => coprs_frontend}/coprs/views/__init__.py | 0
.../coprs/views/backend_ns/__init__.py | 0
.../coprs/views/backend_ns/backend_general.py | 0
.../coprs/views/coprs_ns/__init__.py | 0
.../coprs/views/coprs_ns/coprs_builds.py | 0
.../coprs/views/coprs_ns/coprs_general.py | 0
{wsgi => coprs_frontend}/coprs/views/misc.py | 0
{wsgi => coprs_frontend}/manage.py | 0
{wsgi => coprs_frontend}/runapp.py | 0
{wsgi => coprs_frontend}/tests/__init__.py | 0
{wsgi => coprs_frontend}/tests/coprs_test_case.py | 0
.../tests/test_views/test_coprs_ns/__init__.py | 0
.../tests/test_views/test_coprs_ns/test_builds.py | 0
.../tests/test_views/test_coprs_ns/test_general.py | 0
wsgi/application | 12 ------------
48 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/wsgi/TODO b/coprs_frontend/TODO
similarity index 100%
rename from wsgi/TODO
rename to coprs_frontend/TODO
diff --git a/wsgi/alembic.ini b/coprs_frontend/alembic.ini
similarity index 100%
rename from wsgi/alembic.ini
rename to coprs_frontend/alembic.ini
diff --git a/wsgi/alembic/env.py b/coprs_frontend/alembic/env.py
similarity index 100%
rename from wsgi/alembic/env.py
rename to coprs_frontend/alembic/env.py
diff --git a/wsgi/alembic/script.py.mako b/coprs_frontend/alembic/script.py.mako
similarity index 100%
rename from wsgi/alembic/script.py.mako
rename to coprs_frontend/alembic/script.py.mako
diff --git a/wsgi/alembic/versions/595a31c145fb_initial_db_setup.py b/coprs_frontend/alembic/versions/595a31c145fb_initial_db_setup.py
similarity index 100%
rename from wsgi/alembic/versions/595a31c145fb_initial_db_setup.py
rename to coprs_frontend/alembic/versions/595a31c145fb_initial_db_setup.py
diff --git a/coprs_frontend/application b/coprs_frontend/application
new file mode 100644
index 0000000..3a5e954
--- /dev/null
+++ b/coprs_frontend/application
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+import logging
+import os
+import sys
+
+# so that errors are not sent to stdout
+logging.basicConfig(stream = sys.stderr)
+
+os.environ['COPRS_ENVIRON_PRODUCTION'] = '1'
+sys.path.insert(0, os.path.dirname(__file__))
+
+from coprs import app as application
diff --git a/coprs_frontend/coprs.conf.example b/coprs_frontend/coprs.conf.example
new file mode 100644
index 0000000..b0b0cfa
--- /dev/null
+++ b/coprs_frontend/coprs.conf.example
@@ -0,0 +1,16 @@
+<VirtualHost 127.0.0.1:8000>
+ ServerName 127.0.0.1
+
+ WSGIDaemonProcess 127.0.0.1 user=coprs group=coprs threads=5
+ WSGIScriptAlias / /var/www/wsgi/application
+ WSGIProcessGroup 127.0.0.1
+
+ ErrorLog logs/error_coprs
+ CustomLog logs/access_coprs common
+
+ <Directory /var/www/wsgi>
+ WSGIApplicationGroup %{GLOBAL}
+ Order deny,allow
+ Allow from all
+ </Directory>
+</VirtualHost>
diff --git a/wsgi/coprs/__init__.py b/coprs_frontend/coprs/__init__.py
similarity index 100%
rename from wsgi/coprs/__init__.py
rename to coprs_frontend/coprs/__init__.py
diff --git a/wsgi/coprs/config.py b/coprs_frontend/coprs/config.py
similarity index 63%
rename from wsgi/coprs/config.py
rename to coprs_frontend/coprs/config.py
index 7dde9d7..e8a403e 100644
--- a/wsgi/coprs/config.py
+++ b/coprs_frontend/coprs/config.py
@@ -1,16 +1,9 @@
import os
-REPO_DIR = ''
-if 'OPENSHIFT_REPO_DIR' in os.environ:
- REPO_DIR = os.environ['OPENSHIFT_REPO_DIR']
-
-DATA_DIR = ''
-if 'OPENSHIFT_DATA_DIR' in os.environ:
- DATA_DIR = os.environ['OPENSHIFT_DATA_DIR']
-
class Config(object):
- DATABASE = os.path.join(REPO_DIR, '../data/copr.db')
- OPENID_STORE = os.path.join(DATA_DIR, '../openid_store')
+ DATA_DIR = os.path.join(os.path.dirname(__file__), '../../data')
+ DATABASE = os.path.join(DATA_DIR, 'copr.db')
+ OPENID_STORE = os.path.join(DATA_DIR, 'openid_store')
SECRET_KEY = 'THISISNOTASECRETATALL'
BACKEND_PASSWORD = 'thisisbackend'
@@ -18,7 +11,7 @@ class Config(object):
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.abspath(DATABASE)
class ProductionConfig(Config):
- pass
+ DEBUG = False
class DevelopmentConfig(Config):
DEBUG = True
diff --git a/wsgi/coprs/constants.py b/coprs_frontend/coprs/constants.py
similarity index 100%
rename from wsgi/coprs/constants.py
rename to coprs_frontend/coprs/constants.py
diff --git a/wsgi/coprs/exceptions.py b/coprs_frontend/coprs/exceptions.py
similarity index 100%
rename from wsgi/coprs/exceptions.py
rename to coprs_frontend/coprs/exceptions.py
diff --git a/wsgi/coprs/filters.py b/coprs_frontend/coprs/filters.py
similarity index 100%
rename from wsgi/coprs/filters.py
rename to coprs_frontend/coprs/filters.py
diff --git a/wsgi/coprs/forms.py b/coprs_frontend/coprs/forms.py
similarity index 100%
rename from wsgi/coprs/forms.py
rename to coprs_frontend/coprs/forms.py
diff --git a/wsgi/coprs/helpers.py b/coprs_frontend/coprs/helpers.py
similarity index 100%
rename from wsgi/coprs/helpers.py
rename to coprs_frontend/coprs/helpers.py
diff --git a/wsgi/coprs/logic/.coprs_logic.py.swo b/coprs_frontend/coprs/logic/.coprs_logic.py.swo
similarity index 100%
rename from wsgi/coprs/logic/.coprs_logic.py.swo
rename to coprs_frontend/coprs/logic/.coprs_logic.py.swo
diff --git a/wsgi/coprs/logic/__init__.py b/coprs_frontend/coprs/logic/__init__.py
similarity index 100%
rename from wsgi/coprs/logic/__init__.py
rename to coprs_frontend/coprs/logic/__init__.py
diff --git a/wsgi/coprs/logic/builds_logic.py b/coprs_frontend/coprs/logic/builds_logic.py
similarity index 100%
rename from wsgi/coprs/logic/builds_logic.py
rename to coprs_frontend/coprs/logic/builds_logic.py
diff --git a/wsgi/coprs/logic/coprs_logic.py b/coprs_frontend/coprs/logic/coprs_logic.py
similarity index 100%
rename from wsgi/coprs/logic/coprs_logic.py
rename to coprs_frontend/coprs/logic/coprs_logic.py
diff --git a/wsgi/coprs/models.py b/coprs_frontend/coprs/models.py
similarity index 100%
rename from wsgi/coprs/models.py
rename to coprs_frontend/coprs/models.py
diff --git a/wsgi/coprs/static/README b/coprs_frontend/coprs/static/README
similarity index 100%
rename from wsgi/coprs/static/README
rename to coprs_frontend/coprs/static/README
diff --git a/wsgi/coprs/static/style.css b/coprs_frontend/coprs/static/style.css
similarity index 100%
rename from wsgi/coprs/static/style.css
rename to coprs_frontend/coprs/static/style.css
diff --git a/wsgi/coprs/templates/404.html b/coprs_frontend/coprs/templates/404.html
similarity index 100%
rename from wsgi/coprs/templates/404.html
rename to coprs_frontend/coprs/templates/404.html
diff --git a/wsgi/coprs/templates/_helpers.html b/coprs_frontend/coprs/templates/_helpers.html
similarity index 100%
rename from wsgi/coprs/templates/_helpers.html
rename to coprs_frontend/coprs/templates/_helpers.html
diff --git a/wsgi/coprs/templates/coprs/_builds_table.html b/coprs_frontend/coprs/templates/coprs/_builds_table.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/_builds_table.html
rename to coprs_frontend/coprs/templates/coprs/_builds_table.html
diff --git a/wsgi/coprs/templates/coprs/_coprs_forms.html b/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/_coprs_forms.html
rename to coprs_frontend/coprs/templates/coprs/_coprs_forms.html
diff --git a/wsgi/coprs/templates/coprs/_permissions_table.html b/coprs_frontend/coprs/templates/coprs/_permissions_table.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/_permissions_table.html
rename to coprs_frontend/coprs/templates/coprs/_permissions_table.html
diff --git a/wsgi/coprs/templates/coprs/add.html b/coprs_frontend/coprs/templates/coprs/add.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/add.html
rename to coprs_frontend/coprs/templates/coprs/add.html
diff --git a/wsgi/coprs/templates/coprs/detail.html b/coprs_frontend/coprs/templates/coprs/detail.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/detail.html
rename to coprs_frontend/coprs/templates/coprs/detail.html
diff --git a/wsgi/coprs/templates/coprs/edit.html b/coprs_frontend/coprs/templates/coprs/edit.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/edit.html
rename to coprs_frontend/coprs/templates/coprs/edit.html
diff --git a/wsgi/coprs/templates/coprs/show.html b/coprs_frontend/coprs/templates/coprs/show.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/show.html
rename to coprs_frontend/coprs/templates/coprs/show.html
diff --git a/wsgi/coprs/templates/coprs/show_builds.html b/coprs_frontend/coprs/templates/coprs/show_builds.html
similarity index 100%
rename from wsgi/coprs/templates/coprs/show_builds.html
rename to coprs_frontend/coprs/templates/coprs/show_builds.html
diff --git a/wsgi/coprs/templates/layout.html b/coprs_frontend/coprs/templates/layout.html
similarity index 100%
rename from wsgi/coprs/templates/layout.html
rename to coprs_frontend/coprs/templates/layout.html
diff --git a/wsgi/coprs/templates/login.html b/coprs_frontend/coprs/templates/login.html
similarity index 100%
rename from wsgi/coprs/templates/login.html
rename to coprs_frontend/coprs/templates/login.html
diff --git a/wsgi/coprs/views/__init__.py b/coprs_frontend/coprs/views/__init__.py
similarity index 100%
rename from wsgi/coprs/views/__init__.py
rename to coprs_frontend/coprs/views/__init__.py
diff --git a/wsgi/coprs/views/backend_ns/__init__.py b/coprs_frontend/coprs/views/backend_ns/__init__.py
similarity index 100%
rename from wsgi/coprs/views/backend_ns/__init__.py
rename to coprs_frontend/coprs/views/backend_ns/__init__.py
diff --git a/wsgi/coprs/views/backend_ns/backend_general.py b/coprs_frontend/coprs/views/backend_ns/backend_general.py
similarity index 100%
rename from wsgi/coprs/views/backend_ns/backend_general.py
rename to coprs_frontend/coprs/views/backend_ns/backend_general.py
diff --git a/wsgi/coprs/views/coprs_ns/__init__.py b/coprs_frontend/coprs/views/coprs_ns/__init__.py
similarity index 100%
rename from wsgi/coprs/views/coprs_ns/__init__.py
rename to coprs_frontend/coprs/views/coprs_ns/__init__.py
diff --git a/wsgi/coprs/views/coprs_ns/coprs_builds.py b/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
similarity index 100%
rename from wsgi/coprs/views/coprs_ns/coprs_builds.py
rename to coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
similarity index 100%
rename from wsgi/coprs/views/coprs_ns/coprs_general.py
rename to coprs_frontend/coprs/views/coprs_ns/coprs_general.py
diff --git a/wsgi/coprs/views/misc.py b/coprs_frontend/coprs/views/misc.py
similarity index 100%
rename from wsgi/coprs/views/misc.py
rename to coprs_frontend/coprs/views/misc.py
diff --git a/wsgi/manage.py b/coprs_frontend/manage.py
similarity index 100%
rename from wsgi/manage.py
rename to coprs_frontend/manage.py
diff --git a/wsgi/runapp.py b/coprs_frontend/runapp.py
similarity index 100%
rename from wsgi/runapp.py
rename to coprs_frontend/runapp.py
diff --git a/wsgi/tests/__init__.py b/coprs_frontend/tests/__init__.py
similarity index 100%
rename from wsgi/tests/__init__.py
rename to coprs_frontend/tests/__init__.py
diff --git a/wsgi/tests/coprs_test_case.py b/coprs_frontend/tests/coprs_test_case.py
similarity index 100%
rename from wsgi/tests/coprs_test_case.py
rename to coprs_frontend/tests/coprs_test_case.py
diff --git a/wsgi/tests/test_views/test_coprs_ns/__init__.py b/coprs_frontend/tests/test_views/test_coprs_ns/__init__.py
similarity index 100%
rename from wsgi/tests/test_views/test_coprs_ns/__init__.py
rename to coprs_frontend/tests/test_views/test_coprs_ns/__init__.py
diff --git a/wsgi/tests/test_views/test_coprs_ns/test_builds.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_builds.py
similarity index 100%
rename from wsgi/tests/test_views/test_coprs_ns/test_builds.py
rename to coprs_frontend/tests/test_views/test_coprs_ns/test_builds.py
diff --git a/wsgi/tests/test_views/test_coprs_ns/test_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
similarity index 100%
rename from wsgi/tests/test_views/test_coprs_ns/test_general.py
rename to coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
diff --git a/wsgi/application b/wsgi/application
deleted file mode 100644
index b849d4f..0000000
--- a/wsgi/application
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-import os
-
-virtenv = os.environ['APPDIR'] + '/virtenv/'
-os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages')
-virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
-try:
- execfile(virtualenv, dict(__file__=virtualenv))
-except IOError:
- pass
-
-from coprs import app as application
11 years, 4 months
[copr] bkabrda-workspace: Don't forget to store the copr creation date (2578e93)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 2578e93f3164de961f822356edee4c1ab4aae79e
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Mon Nov 26 14:38:31 2012 +0100
Don't forget to store the copr creation date
>---------------------------------------------------------------
wsgi/coprs/views/coprs_ns/coprs_general.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/wsgi/coprs/views/coprs_ns/coprs_general.py
index 4cd2abf..8c4c2c0 100644
--- a/wsgi/coprs/views/coprs_ns/coprs_general.py
+++ b/wsgi/coprs/views/coprs_ns/coprs_general.py
@@ -1,3 +1,5 @@
+import time
+
import flask
from coprs import db, page_not_found
@@ -58,7 +60,8 @@ def copr_new():
copr = models.Copr(name = form.name.data,
chroots = ' '.join(form.chroots),
repos = form.repos.data.replace('\n', ' '),
- owner = flask.g.user)
+ owner = flask.g.user,
+ created_on = int(time.time()))
coprs_logic.CoprsLogic.new(flask.g.user, copr, check_for_duplicates = False) # form validation checks for duplicates
db.session.commit()
11 years, 4 months
[copr] bkabrda-workspace: Add epel to CHROOTS and sort the chroots for form select field (5bf70ae)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 5bf70ae316b2a7c618c0a6f6ce3d47188d6e0597
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Mon Nov 26 14:37:54 2012 +0100
Add epel to CHROOTS and sort the chroots for form select field
>---------------------------------------------------------------
wsgi/coprs/constants.py | 2 ++
wsgi/coprs/forms.py | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/wsgi/coprs/constants.py b/wsgi/coprs/constants.py
index a845e6a..d9968e0 100644
--- a/wsgi/coprs/constants.py
+++ b/wsgi/coprs/constants.py
@@ -6,6 +6,8 @@ CHROOTS = {'fedora-16': DEFAULT_ARCHES,
'fedora-17': DEFAULT_ARCHES,
'fedora-18': DEFAULT_ARCHES,
'fedora-rawhide': DEFAULT_ARCHES,
+ 'epel-5': DEFAULT_ARCHES,
+ 'epel-6': DEFAULT_ARCHES,
}
# PAGINATION
diff --git a/wsgi/coprs/forms.py b/wsgi/coprs/forms.py
index 8755a13..4fe86ac 100644
--- a/wsgi/coprs/forms.py
+++ b/wsgi/coprs/forms.py
@@ -79,7 +79,7 @@ class CoprForm(wtf.Form):
CoprUniqueNameValidator()])
# choices must be list of tuples
# => make list like [(fedora-18, fedora-18), ...]
- release = wtf.SelectField('Release', choices = [(x, x) for x in constants.CHROOTS])
+ release = wtf.SelectField('Release', choices = [(x, x) for x in sorted(constants.CHROOTS)])
arches = wtf.SelectMultipleField('Architectures',
choices = [(x, x) for x in constants.DEFAULT_ARCHES],
validators = [wtf.Required(), AllowedArchesValidator()])
11 years, 4 months
[copr] bkabrda-workspace: Last couple of fixes to allow copr_admins to edit copr. (5508aa7)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 5508aa79efca002276548828bc65a9a0b469f126
Author: Bohuslav Kabrda <bkabrda(a)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))
11 years, 4 months
[copr] bkabrda-workspace: Some more fixes (30aee74)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 30aee74e8f0f8162643b090b5f268cf8b2cdef02
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Mon Nov 26 13:43:19 2012 +0100
Some more fixes
>---------------------------------------------------------------
wsgi/coprs/views/coprs_ns/coprs_general.py | 12 +++++--
wsgi/tests/coprs_test_case.py | 1 +
.../tests/test_views/test_coprs_ns/test_general.py | 34 +++++++------------
3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/wsgi/coprs/views/coprs_ns/coprs_general.py
index bc32dc4..e1638f1 100644
--- a/wsgi/coprs/views/coprs_ns/coprs_general.py
+++ b/wsgi/coprs/views/coprs_ns/coprs_general.py
@@ -189,13 +189,19 @@ def copr_update_permissions(username, coprname):
if permissions_form.validate_on_submit():
# we don't change owner (yet)
for perm in permissions:
- copr_builder = helpers.PermissionEnum.num('Request')
- copr_admin = helpers.PermissionEnum.num('Request')
+ copr_builder = perm.copr_builder
+ copr_admin = perm.copr_admin
+ # if the permission is granted, use Approved
+ # otherwise if it was Approved and it is ungranted, use Request,
+ # else use original value
if permissions_form['copr_builder_{0}'.format(perm.user_id)].data:
copr_builder = helpers.PermissionEnum.num('Approved')
+ elif copr_builder == helpers.PermissionEnum.num('Approved'):
+ copr_builder = helpers.PermissionEnum.num('Request')
if permissions_form['copr_admin_{0}'.format(perm.user_id)].data:
copr_admin = helpers.PermissionEnum.num('Approved')
-
+ elif copr_admin == helpers.PermissionEnum.num('Approved'):
+ copr_admin = helpers.PermissionEnum.num('Request')
models.CoprPermission.query.filter(models.CoprPermission.copr_id == copr.id).\
filter(models.CoprPermission.user_id == perm.user_id).\
diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 3aa7496..732200e 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -15,6 +15,7 @@ class CoprsTestCase(object):
self.app.testing = True
self.db = coprs.db
self.models = models
+ self.helpers = helpers
# create datadir if it doesn't exist
datadir = os.path.commonprefix([self.app.config['DATABASE'], self.app.config['OPENID_STORE']])
if not os.path.exists(datadir):
diff --git a/wsgi/tests/test_views/test_coprs_ns/test_general.py b/wsgi/tests/test_views/test_coprs_ns/test_general.py
index 6e11d2a..d02c473 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -193,23 +193,6 @@ class TestCoprApplyForPermissions(CoprsTestCase):
assert new_perm.copr_builder == 1
assert new_perm.copr_admin == 0
-class TestCoprGiveUpBuilding(CoprsTestCase):
- def test_give_up(self, f_users, f_coprs, f_copr_permissions):
- with self.tc as c:
- with c.session_transaction() as s:
- s['openid'] = self.u1.openid_name
-
- self.db.session.add_all([self.u1, self.u2, self.c2])
- r = c.post('/coprs/detail/{0}/{1}/give_up_building/'.format(self.u2.name, self.c2.name),
- follow_redirects = True)
- assert 'You have successfuly given up' in r.data
-
- self.db.session.add_all([self.u1, self.u2, self.c2])
- exists = self.models.CoprPermission.query.filter(self.models.CoprPermission.user_id == self.u1.id).\
- filter(self.models.CoprPermission.copr_id == self.c2.id).\
- first()
- assert not exists
-
class TestCoprUpdatePermissions(CoprsTestCase):
def test_cancel_permission(self, f_users, f_coprs, f_copr_permissions):
with self.tc as c:
@@ -231,8 +214,17 @@ class TestCoprUpdatePermissions(CoprsTestCase):
self.db.session.add_all([self.u2, self.c3])
r = c.post('/coprs/detail/{0}/{1}/update_permissions/'.format(self.u2.name, self.c3.name),
- data = {'user_1': 'y', 'user_3': 'y'},
+ data = {'copr_builder_1': 'y', 'copr_admin_3': 'y'},
follow_redirects = True)
- self.db.session.add_all([self.u1, self.u3])
- assert '<tr><td>{0}</td><td>{1}</td></tr>'.format(self.u1.name, 'True') in r.data
- assert '<tr><td>{0}</td><td>{1}</td></tr>'.format(self.u3.name, 'True') in r.data
+ self.db.session.add_all([self.c3, self.u1, self.u3])
+ u1_c3_perms = self.models.CoprPermission.query.filter(self.models.CoprPermission.copr_id == self.c3.id).\
+ filter(self.models.CoprPermission.user_id == self.u1.id).\
+ first()
+ assert u1_c3_perms.copr_builder == self.helpers.PermissionEnum.num('Approved')
+ assert u1_c3_perms.copr_admin == self.helpers.PermissionEnum.num('Request')
+
+ u3_c3_perms = self.models.CoprPermission.query.filter(self.models.CoprPermission.copr_id == self.c3.id).\
+ filter(self.models.CoprPermission.user_id == self.u3.id).\
+ first()
+ assert u3_c3_perms.copr_builder == self.helpers.PermissionEnum.num('No Action')
+ assert u3_c3_perms.copr_admin == self.helpers.PermissionEnum.num('Approved')
11 years, 4 months
[copr] bkabrda-workspace: Yet some more fixes (c79f63a)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit c79f63a78dd669efb5b01a3fb9f5e8aee33e028f
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Mon Nov 26 13:15:02 2012 +0100
Yet some more fixes
>---------------------------------------------------------------
wsgi/coprs/views/coprs_ns/coprs_general.py | 2 +-
.../tests/test_views/test_coprs_ns/test_general.py | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/wsgi/coprs/views/coprs_ns/coprs_general.py
index d370bbf..bc32dc4 100644
--- a/wsgi/coprs/views/coprs_ns/coprs_general.py
+++ b/wsgi/coprs/views/coprs_ns/coprs_general.py
@@ -161,7 +161,7 @@ def copr_permissions_applier_change(username, coprname):
permission.copr_builder = new_builder
permission.copr_admin = new_admin
db.session.commit()
- flask.flash('Successfuly updated your permissions in Copr "{0}".'.format(copr.name))
+ flask.flash('Successfuly updated permissions in Copr "{0}".'.format(copr.name))
else:
if new_builder == approved_num or new_admin == approved_num:
flask.flash('User can\'t approve himself.')
diff --git a/wsgi/tests/test_views/test_coprs_ns/test_general.py b/wsgi/tests/test_views/test_coprs_ns/test_general.py
index d5088cf..6e11d2a 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -174,22 +174,24 @@ class TestCoprUpdate(CoprsTestCase):
follow_redirects = True)
assert 'Copr was updated successfully' in r.data
-class TestCoprApplyForBuilding(CoprsTestCase):
+class TestCoprApplyForPermissions(CoprsTestCase):
def test_apply(self, f_users, f_coprs):
with self.tc as c:
with c.session_transaction() as s:
s['openid'] = self.u2.openid_name
self.db.session.add_all([self.u1, self.u2, self.c1])
- r = c.post('/coprs/detail/{0}/{1}/apply_for_building/'.format(self.u1.name, self.c1.name),
+ r = c.post('/coprs/detail/{0}/{1}/permissions_applier_change/'.format(self.u1.name, self.c1.name),
+ data = {'copr_builder': 1, 'copr_admin': 0},
follow_redirects = True)
- assert 'You have successfuly applied' in r.data
+ assert 'Successfuly applied' in r.data
self.db.session.add_all([self.u1, self.u2, self.c1])
new_perm = self.models.CoprPermission.query.filter(self.models.CoprPermission.user_id == self.u2.id).\
filter(self.models.CoprPermission.copr_id == self.c1.id).\
first()
- assert not new_perm.copr_builder
+ assert new_perm.copr_builder == 1
+ assert new_perm.copr_admin == 0
class TestCoprGiveUpBuilding(CoprsTestCase):
def test_give_up(self, f_users, f_coprs, f_copr_permissions):
11 years, 4 months