From 70b1d9af86f9e4549a44f10a81b833d2d57e5f33 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 12 2016 08:26:06 +0000 Subject: [PATCH 1/3] Give an idea about which project is being adjusted --- diff --git a/alembic/versions/26af5c3602a0_add_the_default_hook_to_all_projects.py b/alembic/versions/26af5c3602a0_add_the_default_hook_to_all_projects.py index eec789f..0e733d8 100644 --- a/alembic/versions/26af5c3602a0_add_the_default_hook_to_all_projects.py +++ b/alembic/versions/26af5c3602a0_add_the_default_hook_to_all_projects.py @@ -36,6 +36,7 @@ def upgrade(): # Update all the existing projects for project in session.query(model.Project).all(): + print 'Installing %s' % project.fullname # Install the default hook plugin = pagure.lib.plugins.get_plugin('default') dbobj = plugin.db_object() From d89f6b67e51faab44217cebd370e7e79991378a3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 12 2016 08:26:33 +0000 Subject: [PATCH 2/3] Fix deleting custom fields The way of deleting a custom field is to set it to an empty string. With the check on length we were always triggering the exception. Instead of that we should just edit/add what was given and remove the rest. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 7093975..11f98f6 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3148,10 +3148,6 @@ def set_custom_key_fields(session, project, fields, types): provided. """ - if len(fields) != len(types): - raise pagure.exceptions.PagureException( - 'Not all the custom fields have a type specified') - current_keys = {} for key in project.issue_keys: current_keys[key.name] = key @@ -3168,6 +3164,11 @@ def set_custom_key_fields(session, project, fields, types): ) session.add(issuekey) + # Delete keys + for key in current_keys: + if key not in fields: + session.delete(current_keys[key]) + return 'List of custom fields updated' diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 9bb1bfb..49b5718 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -2145,9 +2145,6 @@ def update_custom_keys(repo, username=None, namespace=None): SESSION, repo, custom_keys, custom_keys_type) SESSION.commit() flask.flash(msg) - except pagure.exceptions.PagureException as msg: - SESSION.rollback() - flask.flash(msg, 'error') except SQLAlchemyError as err: # pragma: no cover SESSION.rollback() flask.flash(str(err), 'error') From 6c7bc4c4df9b5a0b60bbb594820c3cdc36b3cb3f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 12 2016 08:27:31 +0000 Subject: [PATCH 3/3] Fix displaying the input fields properly so that they can be edited --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index eda3fac..88c62d9 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -316,10 +316,11 @@ {% if authenticated and g.repo_admin %}
- +