From 4b7ecc6172be8a04717e2ed93b417ccdb7763ca2 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Fri, 27 Oct 2023 15:27:21 +0200 Subject: [PATCH 1/7] Fix shibboleth accounts urls --- rdmo/accounts/urls/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/rdmo/accounts/urls/__init__.py b/rdmo/accounts/urls/__init__.py index aaa135462..7e04c8845 100644 --- a/rdmo/accounts/urls/__init__.py +++ b/rdmo/accounts/urls/__init__.py @@ -21,8 +21,6 @@ shibboleth_login, name='shibboleth_login'), re_path('^shibboleth/logout/', shibboleth_logout, name='shibboleth_logout'), - re_path('^logout/', - auth_views.LogoutView.as_view(next_page=settings.SHIBBOLETH_LOGOUT_URL), name='account_logout'), ] if settings.ACCOUNT or settings.SOCIALACCOUNT: From 4efca5b051ede4c1e6049c139821a6bf50b94f82 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Fri, 27 Oct 2023 15:45:23 +0200 Subject: [PATCH 2/7] Fix source compilation in IssueDetailView and add tests --- rdmo/projects/tests/test_view_issue.py | 20 ++++++++++++++++++++ rdmo/projects/views/issue.py | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/rdmo/projects/tests/test_view_issue.py b/rdmo/projects/tests/test_view_issue.py index 5404ca277..230bc2f7e 100644 --- a/rdmo/projects/tests/test_view_issue.py +++ b/rdmo/projects/tests/test_view_issue.py @@ -49,6 +49,26 @@ issue_status = ('open', 'in_progress', 'closed') +@pytest.mark.parametrize('username,password', users) +@pytest.mark.parametrize('project_id', projects) +@pytest.mark.parametrize('issue_id', issues) +def test_issue(db, client, username, password, project_id, issue_id): + client.login(username=username, password=password) + issue = Issue.objects.filter(project_id=project_id, id=issue_id).first() + + url = reverse('issue', args=[project_id, issue_id]) + response = client.get(url) + + if issue: + if project_id in view_issue_permission_map.get(username, []): + assert response.status_code == 200 + elif password: + assert response.status_code == 403 + else: + assert response.status_code == 302 + else: + assert response.status_code == 404 + @pytest.mark.parametrize('username,password', users) @pytest.mark.parametrize('project_id', projects) diff --git a/rdmo/projects/views/issue.py b/rdmo/projects/views/issue.py index 4c01fda62..9ec02de58 100644 --- a/rdmo/projects/views/issue.py +++ b/rdmo/projects/views/issue.py @@ -33,13 +33,14 @@ def get_permission_object(self): def get_context_data(self, **kwargs): project = self.get_object().project + project.catalog.prefetch_elements() conditions = self.get_object().task.conditions.all() sources = [] for condition in conditions: sources.append({ 'source': condition.source, - 'questions': condition.source.questions.filter(questionset__section__catalog=project.catalog), + 'questions': filter(lambda q: q.attribute == condition.source, project.catalog.questions), 'values': condition.source.values.filter(project=project, snapshot=None) }) From acebc79b2325f66612a2ea266095a2c69445147d Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Fri, 27 Oct 2023 16:16:39 +0200 Subject: [PATCH 3/7] Fix margin in nested views of management interface --- rdmo/management/assets/js/components/nested/NestedPage.js | 2 +- .../management/assets/js/components/nested/NestedQuestionSet.js | 2 +- rdmo/management/assets/js/components/nested/NestedSection.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rdmo/management/assets/js/components/nested/NestedPage.js b/rdmo/management/assets/js/components/nested/NestedPage.js index c19a212b8..801ddc464 100644 --- a/rdmo/management/assets/js/components/nested/NestedPage.js +++ b/rdmo/management/assets/js/components/nested/NestedPage.js @@ -52,7 +52,7 @@ const NestedPage = ({ config, page, configActions, elementActions }) => { options={getUriPrefixes(page.elements)} /> -
+
{gettext('Show elements:')} {gettext('Question sets')}
diff --git a/rdmo/management/assets/js/components/nested/NestedQuestionSet.js b/rdmo/management/assets/js/components/nested/NestedQuestionSet.js index 42a42b770..70db94a5e 100644 --- a/rdmo/management/assets/js/components/nested/NestedQuestionSet.js +++ b/rdmo/management/assets/js/components/nested/NestedQuestionSet.js @@ -50,7 +50,7 @@ const NestedQuestionSet = ({ config, questionset, configActions, elementActions options={getUriPrefixes(questionset.elements)} />
-
+
{gettext('Show elements:')} {gettext('Question sets')}
diff --git a/rdmo/management/assets/js/components/nested/NestedSection.js b/rdmo/management/assets/js/components/nested/NestedSection.js index 3a852603d..1552ddd0b 100644 --- a/rdmo/management/assets/js/components/nested/NestedSection.js +++ b/rdmo/management/assets/js/components/nested/NestedSection.js @@ -53,7 +53,7 @@ const NestedCatalog = ({ config, section, configActions, elementActions }) => { options={getUriPrefixes(section.elements)} />
-
+
{gettext('Show elements:')} {gettext('Pages')} {gettext('Question sets')} From 44be4a9d4f2da57431cb91a1971c88a2e01680cb Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Fri, 27 Oct 2023 17:02:49 +0200 Subject: [PATCH 4/7] Reset the autoincrement counters for postgres after the migration to pages --- rdmo/questions/migrations/0074_data_migration.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rdmo/questions/migrations/0074_data_migration.py b/rdmo/questions/migrations/0074_data_migration.py index ec36ecbcc..044fa0e03 100644 --- a/rdmo/questions/migrations/0074_data_migration.py +++ b/rdmo/questions/migrations/0074_data_migration.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from django.db import migrations +from django.db import connection, migrations def run_data_migration(apps, schema_editor): @@ -39,6 +39,20 @@ def run_data_migration(apps, schema_editor): question.questionset_id = None question.save() + if connection.vendor == 'postgresql': + # reset the autoincrement value for the page and questionset tables + with connection.cursor() as cursor: + cursor.execute(''' + SELECT SETVAL( + pg_get_serial_sequence('questions_page', 'id'), + (SELECT MAX(id) FROM questions_page) + ); + SELECT SETVAL( + pg_get_serial_sequence('questions_questionset', 'id'), + (SELECT MAX(id) FROM questions_questionset) + ); + ''') + class Migration(migrations.Migration): From 82e558e728be8eafdc43fdfa6fdbdf963e766149 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer Date: Thu, 5 Oct 2023 15:46:37 +0200 Subject: [PATCH 5/7] docs: add additional badges to readme (pre-commit, ruff, django versions) --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index faf00c685..67fadec6b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,10 @@ RDMO - Research Data Management Organiser [![Latest release](https://img.shields.io/pypi/v/rdmo.svg?style=flat)](https://pypi.python.org/pypi/rdmo/) [![Python Versions](https://img.shields.io/pypi/pyversions/rdmo.svg?style=flat)](https://www.python.org/) -[![License](https://img.shields.io/github/license/rdmorganiser/rdmo?style=flat)](https://github.com/rdmorganiser/rdmo/blob/master/LICENSE) +[![Django Versions](https://img.shields.io/pypi/frameworkversions/django/rdmo)](https://pypi.python.org/pypi/rdmo/) +[![License](https://img.shields.io/github/license/rdmorganiser/rdmo?style=flat)](https://github.com/rdmorganiser/rdmo/blob/master/LICENSE) \ +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![CI Workflow Status](https://github.com/rdmorganiser/rdmo/actions/workflows/ci.yml/badge.svg)](https://github.com/rdmorganiser/rdmo/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/rdmorganiser/rdmo/badge.svg?branch=master&service=github)](https://coveralls.io/github/rdmorganiser/rdmo?branch=master) [![Documentation status](https://readthedocs.org/projects/rdmo/badge/?version=latest)](http://rdmo.readthedocs.io/en/latest/?badge=latest) From 6465dc85dd9f84a9ff8d3a9eecff0220dd217559 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:51:29 +0200 Subject: [PATCH 6/7] ci: add pre-commit autoupdate ci job Fixes: #777 --- .github/workflows/pre-commit-autoupdate.yml | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/pre-commit-autoupdate.yml diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml new file mode 100644 index 000000000..a3b72443f --- /dev/null +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -0,0 +1,60 @@ +# This CI job is adapted from: +# Cookiecutter Django (2013-10-17), BSD-3-Clause license +# Ref: https://github.com/cookiecutter/cookiecutter-django/blob/2023.10.17/.github/workflows/pre-commit-autoupdate.yml + +name: Update pre-commit hooks + +on: + schedule: + # run once a month at midnight of the first day of the month + - cron: 0 0 1 * * + # run manually from actions tab + workflow_dispatch: + +permissions: + contents: read + +jobs: + auto-update: + # Disables this workflow from running in a repository that is not part of the indicated organization/user + if: github.repository_owner == 'rdmorganiser' + permissions: + contents: write # for peter-evans/create-pull-request to create branch + pull-requests: write # for peter-evans/create-pull-request to create a PR + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + cache: pip + - run: python -m pip install pre-commit + - run: pre-commit autoupdate > autoupdate.log + - name: Prepare message for pr body + run: | + grep "updating" autoupdate.log > updates.log + sed -i -e 's/\[/- /g' updates.log + echo -e "## Proposed changes\n\nBumps the pre-commit config with the following updates:\n" > pr-body.md + cat updates.log >> pr-body.md + echo -e "\n---\nThis PR is auto-generated once a month." >> pr-body.md + # Ref: https://github.com/peter-evans/create-pull-request + - name: Create pull request + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 + with: + branch: pre-commit-autoupdate + base: dependency-updates + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + title: "build: update pre-commit hooks" + commit-message: "build: update pre-commit hooks" + add-paths: .pre-commit-config.yaml + body-path: pr-body.md + labels: | + dependencies + pre-commit + type: maintenance + delete-branch: true + - name: Write to job summary + run: | + cat updates.log >> $GITHUB_STEP_SUMMARY From 457d19d830c93eb4569bfac16789c2ed00d505ef Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Tue, 31 Oct 2023 18:46:04 +0100 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dee19b0b3..308e14474 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [RDMO 2.0.2](https://github.com/rdmorganiser/rdmo/compare/2.0.1...2.0.2) (Nov 2, 2023) + +* Fix migration to RDMO 2.0 for PostgreSQL +* Fix Shibboleth urls +* Fix issue view +* Fix margins in management interface ## [RDMO 2.0.1](https://github.com/rdmorganiser/rdmo/compare/2.0.0...2.0.1) (Oct 9, 2023)