Skip to content

Commit

Permalink
Merge pull request #799 from rdmorganiser/dev-2.0.2
Browse files Browse the repository at this point in the history
RDMO 2.0.2
  • Loading branch information
jochenklar committed Nov 2, 2023
2 parents bb5f093 + 80edd4a commit 76dd615
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 8 deletions.
60 changes: 60 additions & 0 deletions .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
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
6 changes: 6 additions & 0 deletions 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)

Expand Down
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions rdmo/accounts/urls/__init__.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rdmo/management/assets/js/components/nested/NestedPage.js
Expand Up @@ -52,7 +52,7 @@ const NestedPage = ({ config, page, configActions, elementActions }) => {
options={getUriPrefixes(page.elements)} />
</div>
</div>
<div className="checkboxes">
<div className="mt-10">
<span className="mr-10">{gettext('Show elements:')}</span>
<Link className="mr-10" onClick={toggleQuestionSets}>{gettext('Question sets')}</Link>
</div>
Expand Down
Expand Up @@ -50,7 +50,7 @@ const NestedQuestionSet = ({ config, questionset, configActions, elementActions
options={getUriPrefixes(questionset.elements)} />
</div>
</div>
<div className="checkboxes">
<div className="mt-10">
<span className="mr-10">{gettext('Show elements:')}</span>
<Link className="mr-10" onClick={toggleQuestionSets}>{gettext('Question sets')}</Link>
</div>
Expand Down
Expand Up @@ -53,7 +53,7 @@ const NestedCatalog = ({ config, section, configActions, elementActions }) => {
options={getUriPrefixes(section.elements)} />
</div>
</div>
<div className="checkboxes">
<div className="mt-10">
<span className="mr-10">{gettext('Show elements:')}</span>
<Link className="mr-10" onClick={togglePages}>{gettext('Pages')}</Link>
<Link className="mr-10" onClick={toggleQuestionSets}>{gettext('Question sets')}</Link>
Expand Down
20 changes: 20 additions & 0 deletions rdmo/projects/tests/test_view_issue.py
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion rdmo/projects/views/issue.py
Expand Up @@ -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)
})

Expand Down
16 changes: 15 additions & 1 deletion 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):
Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit 76dd615

Please sign in to comment.