From 761944ea951d7239cf7fc26f1ec43c45bfc57995 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Wed, 8 May 2024 16:26:00 -0400 Subject: [PATCH 01/13] Bump next version to 1.7-dev --- mep/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mep/__init__.py b/mep/__init__.py index d6074cd5..7d413e1a 100644 --- a/mep/__init__.py +++ b/mep/__init__.py @@ -1,4 +1,4 @@ -__version_info__ = (1, 6, 0, None) +__version_info__ = (1, 7, 0, "dev") # Dot-connect all but the last. Last is dash-connected if not None. From 61eb9a58d29ca1e891ecb70047baf852264b8cc1 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Wed, 8 May 2024 17:02:08 -0400 Subject: [PATCH 02/13] Update versions of deprecated actions --- .github/workflows/unit_tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 76b21f04..e0792eab 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: Cache node modules @@ -34,12 +34,12 @@ jobs: - name: Run webpack build run: npm run build:prod - name: Upload built files - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bundles path: bundles/ - name: Upload stats file - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: webpack-stats.json path: webpack-stats.json @@ -67,7 +67,7 @@ jobs: - name: Run Jest run: npx jest --collectCoverage - name: Upload test coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: flags: typescript @@ -127,7 +127,7 @@ jobs: pip install -r dev-requirements.txt - name: Download webpack stats - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: webpack-stats.json @@ -140,7 +140,7 @@ jobs: run: py.test --cov=./ --cov-report=xml - name: Upload test coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: flags: python From 479cc816351cebbe4bc0ac91379ccd9078019d81 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Mon, 12 Aug 2024 12:24:25 -0400 Subject: [PATCH 03/13] Add boolean field to override setting birth/death date from viaf on save ref #824 --- mep/people/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mep/people/models.py b/mep/people/models.py index 21c009bd..8efafb07 100644 --- a/mep/people/models.py +++ b/mep/people/models.py @@ -449,6 +449,12 @@ class Person(TrackChangesModel, Notable, DateRange, ModelIndexable): birth_year = AliasIntegerField(db_column="start_year", blank=True, null=True) #: death year death_year = AliasIntegerField(db_column="end_year", blank=True, null=True) + #: override for setting dates from viaf + viaf_date_override = models.BooleanField( + "VIAF override", + default=False, + help_text="Do not set birth/death date from VIAF on save", + ) #: flag to indicate organization instead of person is_organization = models.BooleanField( default=False, From 0c308b56758b253dde26cece32e0d62195aeed9f Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Mon, 12 Aug 2024 12:26:33 -0400 Subject: [PATCH 04/13] Make viaf override checkbox available in admin ref #824 --- mep/people/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mep/people/admin.py b/mep/people/admin.py index 3db29116..3e6ee7bd 100644 --- a/mep/people/admin.py +++ b/mep/people/admin.py @@ -231,7 +231,7 @@ class PersonAdmin(admin.ModelAdmin): ("slug", "mep_id"), ("has_account", "in_logbooks", "has_card", "is_creator"), "viaf_id", - ("birth_year", "death_year"), + ("birth_year", "death_year", "viaf_date_override"), "gender", "profession", "nationalities", From e4c11241960d71a1d76998526c122c83236031c9 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Mon, 12 Aug 2024 13:17:57 -0400 Subject: [PATCH 05/13] Skip setting dates from viaf when override flag is set ref #824 --- mep/people/models.py | 7 ++++++- mep/people/tests/test_models.py | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mep/people/models.py b/mep/people/models.py index 8efafb07..a9ffb521 100644 --- a/mep/people/models.py +++ b/mep/people/models.py @@ -543,13 +543,18 @@ class Meta: def save(self, *args, **kwargs): """Adds birth and death dates if they aren't already set - and there's a viaf id for the record""" + and there's a viaf id for the record; keep a record of + past person slugs when a person slug has changed""" + # set birth and death date if VIAF id is set and birth year and death + # year are NOT set; UNLESS skip viaf lookup config or + # viaf date override are true if ( not getattr(settings, "SKIP_VIAF_LOOKUP", False) and self.viaf_id and not self.birth_year and not self.death_year + and not self.viaf_date_override ): self.set_birth_death_years() diff --git a/mep/people/tests/test_models.py b/mep/people/tests/test_models.py index a48607a3..4cb2fc16 100644 --- a/mep/people/tests/test_models.py +++ b/mep/people/tests/test_models.py @@ -191,6 +191,15 @@ def test_save(self): pers.save() mock_setbirthdeath.assert_called_with() + # viaf set, no dates, and date override set to true + # - should NOT call + pers.viaf_date_override = True + pers.birth_year = None + pers.death_year = None + mock_setbirthdeath.reset_mock() + pers.save() + mock_setbirthdeath.assert_not_called() + # should lookup normally, but configured to skip with override_settings(SKIP_VIAF_LOOKUP=True): mock_setbirthdeath.reset_mock() From b91ace8efa32dc960a1ab19b3028841f7f065fa1 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:06:21 -0400 Subject: [PATCH 06/13] Use pyproject for python requirements so dev versions don't override --- README.rst | 5 +-- dev-requirements.txt | 9 ----- mep/__init__.py | 8 +--- pyproject.toml | 88 ++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 37 ------------------- 5 files changed, 91 insertions(+), 56 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml delete mode 100644 requirements.txt diff --git a/README.rst b/README.rst index 7ab8ddcf..c8a56bed 100644 --- a/README.rst +++ b/README.rst @@ -58,9 +58,8 @@ Initial setup and installation: - Install required python dependencies:: - # install requirements - pip install -r dev-requirements.txt - pip install -r requirements.txt + # install python dependencies, including dev dependencies + pip install -e '.[dev]' - Install javascript dependencies:: diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index aa23140e..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -pytest>=5 -pytest-django>=3.4.7 -pytest-cov -pytest-ordering -django-debug-toolbar -sphinx -wheel -pre-commit -wagtail-factories \ No newline at end of file diff --git a/mep/__init__.py b/mep/__init__.py index 7d413e1a..c99688b4 100644 --- a/mep/__init__.py +++ b/mep/__init__.py @@ -1,10 +1,4 @@ -__version_info__ = (1, 7, 0, "dev") - - -# Dot-connect all but the last. Last is dash-connected if not None. -__version__ = ".".join([str(i) for i in __version_info__[:-1]]) -if __version_info__[-1] is not None: - __version__ += "-%s" % (__version_info__[-1],) +__version__ = "1.7.0.dev0" # context processor to add version to the template environment diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..4fd3b490 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,88 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "mep-django" +description = "Shakespeare and Company Project - Python/Django web application" +requires-python = ">=3.9" +license = {text = "Apache-2"} +classifiers = [ + "Programming Language :: Python :: 3", +] +dependencies = [ + "Django>=3.2.4,<4.0", + "django-grappelli>=3.0", + "cached_property", + "django-cas-ng", + "pucas>=0.8", + "eulxml>=1.1.3", + "viapy>=0.3", + "wagtail>=5.1,<5.2", + "django-autocomplete-light>=3.9", + "python-dateutil", + "django-apptemplates", + "py-flags", + "django-tabular-export", + "django-webpack-loader<=2.0", + "parasolr>=0.9.2", + "django-widget-tweaks", + # pymarc api changes significantly in 5.0 + "pymarc<5.0", + "progressbar2", + "rdflib>=6.0", + "djiffy>=0.6", + "django-csp", + "bleach", + "django-fullurl", + "unidecode", + "stop_words", + # as of 2024-05-08 django-markdownify==0.9.4 causes an error with bleach + "django-markdownify==0.9.3", + "tweepy", + # specify bs4 version to avoid wagtail version conflict + "beautifulsoup4<4.9", + "psycopg2-binary", + # TODO: unpin piffle from 0.4 once breaking changes with piffle.iiif are handled in djiffy + "piffle==0.4", + # 4.0 is not compatible with django 3.2, so pin to pre 4.0 + "django-import-export<4.0", + "django-adminlogentries" +] +dynamic = ["version", "readme"] + +[tool.setuptools] +packages = ["mep"] + +[tool.setuptools.dynamic] +version = {attr = "mep.__version__"} +readme = {file = ["README.rst"]} + +[project.optional-dependencies] +dev = [ + "pytest>=5", + "pytest-django>=3.4.7", + "pytest-cov", + "pytest-ordering", + # pin to pre 4.4, which forces django 4.2 + "django-debug-toolbar<=4.4", + "sphinx", + "wheel", + "pre-commit", + "wagtail-factories<4.1", +] + +[tool.pytest.ini_options] +DJANGO_SETTINGS_MODULE="mep.settings" +# look for tests in standard django test location +python_files = ["mep/**/tests.py", "mep/**/tests/*.py"] +addopts = "-p parasolr.django.disconnect_indexing" +# limit testpath to speed up collecting step +testpaths = "mep" +markers = ["last", "second_to_last"] + +[tool.black] +line-length = 88 +target-version = ['py39'] +# include = '' +# extend-exclude = '' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 021c841f..00000000 --- a/requirements.txt +++ /dev/null @@ -1,37 +0,0 @@ -Django>=3.2.4,<4.0 -django-grappelli>=3.0 -cached_property -django-cas-ng -pucas>=0.8 -eulxml>=1.1.3 -viapy>=0.3 -wagtail>=5.1,<5.2 -django-autocomplete-light>=3.9 -python-dateutil -django-apptemplates -py-flags -django-tabular-export -django-webpack-loader<=2.0 -parasolr>=0.9.2 -django-widget-tweaks -# pymarc api changes significantly in 5.0 -pymarc<5.0 -progressbar2 -rdflib>=6.0 -djiffy>=0.6 -django-csp -bleach -django-fullurl -unidecode -stop_words -# as of 2024-05-08 django-markdownify==0.9.4 causes an error with bleach -django-markdownify==0.9.3 -tweepy -# specify bs4 version to avoid wagtail version conflict -beautifulsoup4<4.9 -psycopg2-binary -# TODO: unpin piffle from 0.4 once breaking changes with piffle.iiif are handled in djiffy -piffle==0.4 -# 4.0 is not compatible with django 3.2, so pin to pre 4.0 -django-import-export<4.0 -django-adminlogentries \ No newline at end of file From ce7ea1233672208edca56494b3510d07ef1cd409 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:06:52 -0400 Subject: [PATCH 07/13] Moved pytest configuration to pyproject --- pytest.ini | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 7640c94c..00000000 --- a/pytest.ini +++ /dev/null @@ -1,10 +0,0 @@ -[pytest] -DJANGO_SETTINGS_MODULE=mep.settings -# look for tests in standard django test location -python_files = "mep/**/tests.py" "mep/**/tests/*.py" -addopts = -p parasolr.django.disconnect_indexing -# limit testpath to speed up collecting step -testpaths = mep -markers = - last - second_to_last From ba50c3c4bb422245b99ddfbc814a8abfa097a7ac Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:26:32 -0400 Subject: [PATCH 08/13] Clean up readme --- README.rst | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/README.rst b/README.rst index c8a56bed..9a94b9fe 100644 --- a/README.rst +++ b/README.rst @@ -36,25 +36,13 @@ Development instructions Initial setup and installation: -- recommended: create and activate a python 3.9 virtual environment. Using pyenv: +- Recommended: create and activate a python virtual environment using the +python version in `.python-version` using `pyenv `_. - # if pyenv is not installed - curl https://pyenv.run | bash - - # get recommended python version - vnum=$(cat .python-version) - - # install that version - pyenv install $vnum - - # activate it - pyenv shell $num - - # create virtual environmnt - python -m venv venv - - # activate virtual environment - . venv/bin/activate + - `pyenv install` will install the specified version of python, if needed; + `pyenv local` will report the configured version + - Run `python -m venv env` to create a new virtual environment named `env` + - `source env/bin/activate` to activate the virtual environment - Install required python dependencies:: @@ -82,7 +70,7 @@ Remember to add a ``SECRET_KEY`` setting! The manage command will automatically reload the core to ensure schema changes take effect. -- Run the migrations +- Run the migrations:: python manage.py migrate @@ -117,7 +105,6 @@ docs `_. If you make changes to js or scss files and need to rebuild static assets:: - npm run build:qa This will compile and minify all assets to ``static/`` with sourcemaps. @@ -128,7 +115,6 @@ Alternatively, to run a production build without sourcemaps, you can use:: Finally, for iterative frontend development, you can activate a webpack dev server with hot reload using:: - npm start Switching between the webpack dev server and serving from ``static/`` requires a @@ -161,11 +147,11 @@ You will also need to configure Django to use the Solr instance in Unit Tests ---------- -Python unit tests are written with `py.test `__ but use +Python unit tests are written with `py.test `_ but use Django fixture loading and convenience testing methods when that makes things easier. To run them, first install development requirements:: - pip install -r dev-requirements.txt + pip install -e '.[dev]' Run tests using py.test:: @@ -197,17 +183,17 @@ debug toolbar, so you'll probably want to turn it off. Setup pre-commit hooks ~~~~~~~~~~~~~~~~~~~~~~ -If you plan to contribute to this repository, please run the following command: +If you plan to contribute to this repository, please run the following command:: pre-commit install This will add a pre-commit hook to automatically format python code with `black `_. -Because these styling conventions were instituted after multiple releases of development on this project, ``git blame`` may not reflect the true author of a given line. In order to see a more accurate ``git blame`` execute the following command: +Because these styling conventions were instituted after multiple releases of development on this project, ``git blame`` may not reflect the true author of a given line. In order to see a more accurate ``git blame`` execute the following command:: git blame --ignore-revs-file .git-blame-ignore-revs -Or configure your git to always ignore styling revision commits: +Or configure your git to always ignore styling revision commits:: git config blame.ignoreRevsFile .git-blame-ignore-revs @@ -238,4 +224,4 @@ License ------- This project is licensed under the `Apache 2.0 License `_. -©2020 Trustees of Princeton University. Permission granted via Princeton Docket #21-3743-1 for distribution online under a standard Open Source license. \ No newline at end of file +©2024 Trustees of Princeton University. Permission granted via Princeton Docket #21-3743-1 for distribution online under a standard Open Source license. \ No newline at end of file From e5c408d5a680b5bfcb2b1758c40fce6f95edd7b4 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:29:23 -0400 Subject: [PATCH 09/13] Update pip install for unit tests to use pyproject.toml --- .github/workflows/unit_tests.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index e0792eab..9435af81 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -115,16 +115,14 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + key: pip-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} restore-keys: | - pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + pip-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} pip-${{ matrix.python }} pip- - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install -r dev-requirements.txt + - name: Install python dependencies + run: pip install -e '.[dev]' - name: Download webpack stats uses: actions/download-artifact@v4 From f9d7889739c3f10fb249b586a13d59e1274f2387 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:34:56 -0400 Subject: [PATCH 10/13] Add migration for viaf date override to version control --- .../0023_person_viaf_date_override.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mep/people/migrations/0023_person_viaf_date_override.py diff --git a/mep/people/migrations/0023_person_viaf_date_override.py b/mep/people/migrations/0023_person_viaf_date_override.py new file mode 100644 index 00000000..d0931965 --- /dev/null +++ b/mep/people/migrations/0023_person_viaf_date_override.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.20 on 2024-08-12 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("people", "0022_populate_birth_death_dates_from_viaf"), + ] + + operations = [ + migrations.AddField( + model_name="person", + name="viaf_date_override", + field=models.BooleanField( + default=False, + help_text="Check this to disable VIAF birth/death date lookup on save", + ), + ), + ] From d8143e09e9170254247130ed74fe4edea03a16a6 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 11:56:20 -0400 Subject: [PATCH 11/13] Display analysis banner on renamed discoveries list page --- srcmedia/scss/common/_header.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcmedia/scss/common/_header.scss b/srcmedia/scss/common/_header.scss index f1fe1dfe..25f43a50 100644 --- a/srcmedia/scss/common/_header.scss +++ b/srcmedia/scss/common/_header.scss @@ -78,7 +78,7 @@ @include responsive-banner('/static/img/headers/SCo_banner_about'); } - &.analysis { + &.analysis, &.discoveries { @include responsive-banner('/static/img/headers/SCo_banner_anlys'); } From 987b32b992edce4986bcd2f98bdf69eae77e40d7 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 12:14:02 -0400 Subject: [PATCH 12/13] Update npm package versions with npm audit fix --- package-lock.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6cd5373f..cb81498d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3603,11 +3603,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -5228,9 +5228,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -11500,9 +11500,9 @@ } }, "node_modules/ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "engines": { "node": ">=10.0.0" From 2149a066d574ab7841cfe0944de6bb204e3ead11 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Tue, 13 Aug 2024 12:14:23 -0400 Subject: [PATCH 13/13] Set version to 1.6.2 and document changes --- CHANGELOG.rst | 6 ++++++ mep/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d7dace8b..8562cb68 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ CHANGELOG ========= +1.6.2 +----- + +* bugfix: add an option to prevent VIAF birth/death dates from being populated + on person record save when blank, so incorrect VIAF dates can be removed + 1.6.1 ----- diff --git a/mep/__init__.py b/mep/__init__.py index c99688b4..f758ca7c 100644 --- a/mep/__init__.py +++ b/mep/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.7.0.dev0" +__version__ = "1.6.2" # context processor to add version to the template environment