Skip to content

Commit

Permalink
Merge branch 'release/1.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 14, 2024
2 parents 646962d + 2149a06 commit e5241fb
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 118 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -115,19 +115,17 @@ 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@v3
uses: actions/download-artifact@v4
with:
name: webpack-stats.json

Expand All @@ -140,7 +138,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

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
45 changes: 15 additions & 30 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,18 @@ 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 <https://github.com/pyenv/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::

# 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::

Expand All @@ -83,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

Expand Down Expand Up @@ -118,7 +105,6 @@ docs <http://django-admin-tools.readthedocs.io/en/latest/dashboard.html#>`_.

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.
Expand All @@ -129,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
Expand Down Expand Up @@ -162,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 <http://doc.pytest.org/>`__ but use
Python unit tests are written with `py.test <http://doc.pytest.org/>`_ 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::

Expand Down Expand Up @@ -198,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 <https://github.com/psf/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 <FILE> --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

Expand Down Expand Up @@ -239,4 +224,4 @@ License
-------
This project is licensed under the `Apache 2.0 License <https://github.com/Princeton-CDH/mep-django/blob/main/LICENSE>`_.

©2020 Trustees of Princeton University. Permission granted via Princeton Docket #21-3743-1 for distribution online under a standard Open Source license.
©2024 Trustees of Princeton University. Permission granted via Princeton Docket #21-3743-1 for distribution online under a standard Open Source license.
9 changes: 0 additions & 9 deletions dev-requirements.txt

This file was deleted.

8 changes: 1 addition & 7 deletions mep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
__version_info__ = (1, 6, 1, None)


# 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.6.2"


# context processor to add version to the template environment
Expand Down
2 changes: 1 addition & 1 deletion mep/people/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions mep/people/migrations/0023_person_viaf_date_override.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
13 changes: 12 additions & 1 deletion mep/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -537,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()

Expand Down
9 changes: 9 additions & 0 deletions mep/people/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e5241fb

Please sign in to comment.