Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
640583b
Adds link resolver to request broker API
kcloud Oct 4, 2021
0ba8820
Merge branch 'development' into islandora_link_resolver
kcloud Mar 14, 2022
c34be9e
Update views.py
kcloud Mar 14, 2022
d23e379
linting
helrond Mar 21, 2022
4f19f13
update dependencies
helrond Jun 13, 2022
f511e81
updates django
helrond Jun 13, 2022
b8e876d
Merge pull request #193 from RockefellerArchiveCenter/depends
helrond Jun 13, 2022
2f30077
Merge pull request #194 from RockefellerArchiveCenter/development
helrond Jun 13, 2022
76f4470
add gh-actions file, remove dependabot
helrond Jul 6, 2022
9807133
update requirements
helrond Jul 6, 2022
bbbc060
use upgrade flag
helrond Jul 6, 2022
3056c70
Merge pull request #199 from RockefellerArchiveCenter/actions
helrond Jul 6, 2022
6fe30e9
update vcrpy
helrond Jul 6, 2022
f269e51
Merge pull request #200 from RockefellerArchiveCenter/development
helrond Jul 6, 2022
955a1f5
update setup URL
helrond Jul 6, 2022
7158d96
Merge pull request #201 from RockefellerArchiveCenter/development
helrond Jul 6, 2022
2c3b85e
formatting
helrond Jul 7, 2022
3365b09
fix typo
helrond Jul 7, 2022
d70455c
add test for LinkResolver view
helrond Jul 7, 2022
ab4e5d6
renaming and consistently using hostname variables
helrond Jul 7, 2022
74a99d3
linting
helrond Jul 7, 2022
577bee3
Merge pull request #184 from RockefellerArchiveCenter/islandora_link_…
helrond Jul 7, 2022
ad0bc3c
Merge pull request #202 from RockefellerArchiveCenter/development
helrond Jul 7, 2022
515cd88
add config for restricted in box
helrond Jul 26, 2022
ef7ee32
fetch restricted material in same box
helrond Jul 26, 2022
dc6f333
add tests
helrond Jul 26, 2022
cc12aa1
add to ItemInfo5
helrond Jul 26, 2022
294b9d5
add format check
helrond Jul 26, 2022
220f645
update fixture
helrond Jul 26, 2022
e2ee56f
Dependency updates
helrond Aug 1, 2022
ff267f1
Merge pull request #205 from RockefellerArchiveCenter/dependency-updates
helrond Aug 2, 2022
c167e8f
Merge pull request #206 from RockefellerArchiveCenter/development
helrond Aug 2, 2022
2ae2ad2
add offsite buildings config
helrond Aug 3, 2022
45cc1cb
return building for offsite requests only
helrond Aug 3, 2022
705acd2
Merge pull request #208 from RockefellerArchiveCenter/issue-207
helrond Aug 3, 2022
50e872d
Merge pull request #209 from RockefellerArchiveCenter/development
helrond Aug 3, 2022
3780095
handle cases where item is missing
helrond Aug 4, 2022
773d714
Merge pull request #210 from RockefellerArchiveCenter/development
helrond Aug 4, 2022
aacfafd
merging
helrond Aug 8, 2022
d0c2a17
Merge pull request #204 from RockefellerArchiveCenter/issue-203
helrond Aug 8, 2022
2ab3892
Merge pull request #211 from RockefellerArchiveCenter/development
helrond Aug 8, 2022
ea7c2a6
add grouping option
helrond Aug 8, 2022
b256a99
use repository search endpoint
helrond Aug 8, 2022
63b2522
Merge pull request #212 from RockefellerArchiveCenter/development
helrond Aug 8, 2022
440899b
handle cases where there is no type_2
helrond Aug 9, 2022
73deb49
Merge pull request #213 from RockefellerArchiveCenter/development
helrond Aug 9, 2022
5546ad5
always return string
helrond Aug 10, 2022
14a7b55
Merge pull request #214 from RockefellerArchiveCenter/development
helrond Aug 10, 2022
8323e76
use get_url method in resolver view
helrond Aug 15, 2022
96e8f34
use search endpoint to get names
helrond Aug 16, 2022
cf63f38
Merge pull request #219 from RockefellerArchiveCenter/creator-names
helrond Aug 16, 2022
9fc3719
Merge pull request #220 from RockefellerArchiveCenter/development
helrond Aug 16, 2022
94a5aed
#221: strip xml/html from data to POST to Aeon
ctgraham Aug 26, 2022
8d69d04
Merge pull request #225 from RockefellerArchiveCenter/issue-221
helrond Aug 27, 2022
75070e5
Merge pull request #226 from RockefellerArchiveCenter/development
helrond Aug 27, 2022
9da2277
Dependency updates
helrond Sep 1, 2022
cb13986
#227: Pass along reading room and site if provided
ctgraham Sep 1, 2022
dff37cc
#230: Add EADNumber via ead_id
ctgraham Sep 1, 2022
bf91c78
use configured repo id
helrond Sep 1, 2022
5809e67
#227: Eager add possible site, strip missing values on get
ctgraham Sep 1, 2022
97d8d5f
#222: Use ASnake to format the resource id
ctgraham Sep 1, 2022
eedb096
Merge pull request #237 from RockefellerArchiveCenter/issue-233
helrond Sep 1, 2022
b25a53c
Merge pull request #231 from RockefellerArchiveCenter/issue-230
helrond Sep 1, 2022
97d565c
Merge pull request #232 from RockefellerArchiveCenter/issue-227
helrond Sep 1, 2022
dba476d
linting
helrond Sep 1, 2022
228a2ce
adds test
helrond Sep 1, 2022
a5bbc13
Merge pull request #236 from RockefellerArchiveCenter/issue-222
helrond Sep 1, 2022
cb16e92
Merge pull request #238 from RockefellerArchiveCenter/development
helrond Sep 1, 2022
11deda7
merging
helrond Sep 1, 2022
fd9bbae
string
helrond Sep 1, 2022
b42f943
Merge pull request #239 from RockefellerArchiveCenter/development
helrond Sep 1, 2022
1317fde
update pinning
helrond Sep 6, 2022
d89594b
Merge pull request #229 from RockefellerArchiveCenter/dependency-updates
helrond Sep 6, 2022
073d09b
Merge pull request #242 from RockefellerArchiveCenter/development
helrond Sep 6, 2022
f46ae51
honor path in else statement, improve docstring
helrond Sep 26, 2022
c390653
remove unused function
helrond Sep 26, 2022
22d0286
replace hostname config with baseurl config
helrond Sep 26, 2022
2c97ed0
Dependency updates
helrond Oct 1, 2022
275cc41
Merge pull request #217 from RockefellerArchiveCenter/issue-216
helrond Oct 4, 2022
37c4433
Merge pull request #246 from RockefellerArchiveCenter/dependency-updates
helrond Oct 4, 2022
5632770
Merge pull request #247 from RockefellerArchiveCenter/development
helrond Oct 4, 2022
533ebba
simplify dockerfile
helrond Oct 4, 2022
794f783
Merge pull request #249 from RockefellerArchiveCenter/issue-248
helrond Oct 6, 2022
e78c38f
Merge pull request #250 from RockefellerArchiveCenter/development
helrond Oct 6, 2022
1159f2e
Dependency updates
helrond Nov 1, 2022
0b371f2
Merge pull request #251 from RockefellerArchiveCenter/dependency-updates
helrond Nov 7, 2022
b3de6b4
Merge pull request #252 from RockefellerArchiveCenter/development
helrond Nov 7, 2022
1d91158
Dependency updates
helrond Dec 1, 2022
433107a
Merge pull request #253 from RockefellerArchiveCenter/dependency-updates
helrond Dec 5, 2022
9c368a5
Merge pull request #254 from RockefellerArchiveCenter/development
helrond Dec 5, 2022
5038e76
security patch
p-galligan Dec 9, 2022
a3f339a
Merge pull request #256 from RockefellerArchiveCenter/security-patch
p-galligan Dec 9, 2022
02a7724
Merge pull request #257 from RockefellerArchiveCenter/development
p-galligan Dec 9, 2022
9f6aae8
install django-csp
helrond Dec 12, 2022
3da24c9
add and configure SCP headers
helrond Dec 12, 2022
3c53f87
Merge pull request #259 from RockefellerArchiveCenter/issue-258
helrond Dec 12, 2022
442c17b
Merge pull request #260 from RockefellerArchiveCenter/development
helrond Dec 12, 2022
355a15e
Dependency updates
helrond Jan 1, 2023
a5f6499
update hook versions
helrond Jan 3, 2023
d1d07cd
Merge pull request #261 from RockefellerArchiveCenter/dependency-updates
helrond Jan 3, 2023
d9f04a0
Merge pull request #262 from RockefellerArchiveCenter/development
helrond Jan 3, 2023
c9d3e76
Dependency updates
helrond Feb 1, 2023
c10be87
keep pre-commit hooks up to date
helrond Feb 1, 2023
e784d74
update django
p-galligan Feb 6, 2023
d3a3268
Merge pull request #263 from RockefellerArchiveCenter/dependency-updates
p-galligan Feb 6, 2023
1e47f95
Merge pull request #265 from RockefellerArchiveCenter/development
p-galligan Feb 6, 2023
62a9df6
upgrade django
helrond Feb 15, 2023
cf15e0b
Merge pull request #267 from RockefellerArchiveCenter/django
helrond Feb 16, 2023
56c5508
Merge pull request #268 from RockefellerArchiveCenter/development
helrond Feb 16, 2023
cffe6b8
account for missing subcontainer key
helrond Feb 17, 2023
3128fe4
Merge pull request #270 from RockefellerArchiveCenter/issue-269
helrond Feb 17, 2023
d8fbf4a
Merge pull request #271 from RockefellerArchiveCenter/development
helrond Feb 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: update dependencies
on:

schedule:
- cron: '0 0 1 * *'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: development

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip

- name: Install pre-commit and pip-tools
run: pip install pre-commit pip-tools

- name: Run pre-commit autoupdate
run: pre-commit autoupdate

- name: Run pip-compile
run: pip-compile --upgrade

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: development
branch: dependency-updates
delete-branch: true
title: Dependency Updates
commit-message: Dependency updates
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.6.0
rev: v2.0.1
hooks:
- id: autopep8
args:
- --in-place
- --aggressive
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.4
hooks:
- id: isort
- repo: https://github.com/jazzband/pip-tools
rev: 6.5.1
rev: 6.12.1
hooks:
- id: pip-compile
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
FROM python:3.10-buster
FROM python:3.10

ENV PYTHONUNBUFFERED 1
RUN apt-get update \
&& apt-get install -y \
postgresql \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /code
ADD requirements.txt /code/
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
request-broker-db:
image: postgres:10.4
image: postgres:14.4
environment:
- POSTGRES_USER=postgres # name of the application database user
- POSTGRES_PASSWORD=postgres # name of the application database user
Expand Down
2 changes: 2 additions & 0 deletions fixtures/as_data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ead_id": "",
"creators": "Ford Foundation",
"collection_name": "Ford Foundation records, General Correspondence",
"parent": "General Correspondence",
Expand All @@ -18,5 +19,6 @@
"title": "Adler, Mortimer J.",
"restrictions": "closed",
"restrictions_text": "Closed until further notice due to personally identifying information.",
"restricted_in_container": null,
"uri": "/repositories/2/archival_objects/986296"
}
1 change: 1 addition & 0 deletions fixtures/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"container_locations": [
{
"_resolved": {
"building": "Rockefeller Archive Center",
"title": "Rockefeller Archive Center, Blue Level, Vault 106 [Unit: 66, Shelf: 7]",
"room": "Vault 106",
"coordinate_1_indicator": "66",
Expand Down
16 changes: 16 additions & 0 deletions fixtures/locations_offsite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "box",
"indicator": "2",
"barcode": "A12345",
"container_locations": [
{
"_resolved": {
"building": "Armonk",
"title": "Armonk, Vault 1 [Unit: 66, Shelf: 7]",
"room": "Vault 1",
"coordinate_1_indicator": "66",
"coordinate_2_indicator": "7"
}
}
]
}
1,590 changes: 1,590 additions & 0 deletions fixtures/restricted_search.json

Large diffs are not rendered by default.

985 changes: 985 additions & 0 deletions fixtures/unrestricted_search.json

Large diffs are not rendered by default.

91 changes: 78 additions & 13 deletions process_request/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import json
import re

import inflect
import shortuuid
from asnake.utils import get_date_display, get_note_text, text_in_note
from asnake.utils import (format_resource_id, get_date_display, get_note_text,
text_in_note)
from django.conf import settings
from ordered_set import OrderedSet

CONFIDENCE_RATIO = 97 # Minimum confidence ratio to match against.
Expand Down Expand Up @@ -50,6 +53,8 @@ def get_file_versions(digital_object):
def get_locations(top_container_info):
"""Gets a string representation of a location for an ArchivesSpace top container.

Adds the building name for offsite locations only.

Args:
top_container_info (dict): json for a top container (with resolved container locations)

Expand All @@ -58,10 +63,12 @@ def get_locations(top_container_info):
"""

def make_short_location(loc_data):
return ".".join([
loc_data.get("room", "").strip().replace("Vault ", ""),
loc_data.get("coordinate_1_indicator", "").strip(),
loc_data.get("coordinate_2_indicator", "").strip()])
location_list = [loc_data.get("room", "").strip().replace("Vault ", ""),
loc_data.get("coordinate_1_indicator", "").strip(),
loc_data.get("coordinate_2_indicator", "").strip()]
if loc_data.get("building") in settings.OFFSITE_BUILDINGS:
location_list.insert(0, loc_data["building"])
return ".".join(location_list)

locations = None
if top_container_info.get("container_locations"):
Expand Down Expand Up @@ -154,6 +161,43 @@ def get_preferred_format(item_json):
return preferred


def get_restricted_in_container(container_uri, client):
"""Fetches information about other restricted items in the same container.

Args:
container_uri (string): A URI for an ArchivesSpace Top Container.

Returns:
restricted (string): a comma-separated list of other restricted items in
the same container.
"""
restricted = []
this_page = 1
more = True
while more:
escaped_url = container_uri.replace('/', '\\/')
search_uri = f"repositories/{settings.ARCHIVESSPACE['repo_id']}/search?q=top_container_uri_u_sstr:{escaped_url}&page={this_page}&fields[]=uri,json,ancestors&resolve[]=ancestors:id&type[]=archival_object&page_size=25"
items_in_container = client.get(search_uri).json()
for item in items_in_container["results"]:
item_json = json.loads(item["json"])
status = get_rights_status(item_json, client)
if not status:
for ancestor_uri in item["_resolved_ancestors"]:
for ancestor in item["_resolved_ancestors"][ancestor_uri]:
status = get_rights_status(json.loads(ancestor["json"]), client)
if status:
break
if status in ["closed", "conditional"]:
for instance in item_json["instances"]:
sub_container = instance.get("sub_container", [])
if all(["type_2" in sub_container, "indicator_2" in sub_container]):
restricted.append(f"{sub_container['type_2'].capitalize()} {sub_container['indicator_2']}")
this_page += 1
if this_page > items_in_container["last_page"]:
more = False
return ", ".join(restricted)


def get_rights_info(item_json, client):
"""Gets rights status and text for an archival object.

Expand Down Expand Up @@ -238,7 +282,7 @@ def get_rights_text(item_json, client):
return text


def get_resource_creators(resource):
def get_resource_creators(resource, client):
"""Gets all creators of a resource record and concatenate them into a string
separated by commas.

Expand All @@ -250,10 +294,12 @@ def get_resource_creators(resource):
"""
creators = []
if resource.get("linked_agents"):
for linked_agent in resource.get("linked_agents"):
if linked_agent.get("role") == "creator":
creators.append(linked_agent.get("_resolved").get('display_name').get('sort_name'))
return ", ".join(creators)
linked_agent_uris = [a["ref"].replace("/", "\\/") for a in resource["linked_agents"] if a["role"] == "creator"]
search_uri = f"/repositories/{settings.ARCHIVESSPACE['repo_id']}/search?fields[]=title&type[]=agent_person&type[]=agent_corporate_entity&type[]=agent_family&page=1&q={' OR '.join(linked_agent_uris)}"
resp = client.get(search_uri)
resp.raise_for_status()
creators = resp.json()["results"]
return ", ".join([a["title"] for a in creators])


def get_dates(archival_object, client):
Expand Down Expand Up @@ -329,10 +375,11 @@ def get_parent_title(obj_json):
return title


def get_url(obj_json, host, client):
"""Returns a full URL for an object."""
def get_url(obj_json, client, host=None):
"""Returns a full or relative URL for an object, depending on if a host is provided."""
uuid = shortuuid.uuid(name=obj_json["uri"])
return "{}/collections/{}".format(host, uuid) if has_children(obj_json, client) else "{}/objects/{}".format(host, uuid)
path = "collections" if has_children(obj_json, client) else "objects"
return f"{host}/{path}/{uuid}" if host else f"/{path}/{uuid}"


def has_children(obj_json, client):
Expand Down Expand Up @@ -366,3 +413,21 @@ def list_chunks(lst, n):
"""
for i in range(0, len(lst), n):
yield lst[i:i + n]


def resolve_ref_id(repo_id, ref_id, client):
""" Accepts options to find archival objects using find_by_id method.

Generates and returns a DIMES URI from an ArchiveSpace URI.
"""
aspace_objs = client.get('/repositories/{}/find_by_id/archival_objects?ref_id[]={}&resolve[]=archival_objects'.format(repo_id, ref_id)).json()
aspace_obj = aspace_objs['archival_objects'][0]['_resolved']
return get_url(aspace_obj, client)


def get_formatted_resource_id(resource, client):
"""Gets a formatted resource id from the resource

Concatenates the resource id parts using the separator from the config
"""
return format_resource_id(resource, client, settings.RESOURCE_ID_SEPARATOR)
Loading