Skip to content

Commit

Permalink
Merge pull request #78 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Merging development to base
  • Loading branch information
helrond authored Dec 21, 2020
2 parents aa01c61 + 78a0646 commit 3cff029
Show file tree
Hide file tree
Showing 45 changed files with 4,525 additions and 664 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[report]
show_missing = True
omit =
*/settings.py
*/config.py
*/__init__.py
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.DS_Store
.archivessnake.yml
*.pickle
*/config.py
*.env*
.coverage


### Django ###
*.log
Expand All @@ -11,3 +13,4 @@ __pycache__/
local_settings.py
db.sqlite3
media
static/
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ before_install:
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- cp request_broker/config.py.example request_broker/config.py
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose up -d
- sleep 20s
- docker-compose exec request-broker-web pip install coverage pre-commit
- docker-compose exec request-broker-web pip install pre-commit
- docker-compose exec request-broker-web pre-commit install
install: true
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- docker-compose exec request-broker-web pre-commit run --all-files --show-diff-on-failure
- docker-compose exec request-broker-web coverage run manage.py test
after_script:
- docker-compose exec request-broker-web coverage xml
- ./cc-test-reporter after-build --debug --exit-code $TRAVIS_TEST_RESULT
- docker-compose exec request-broker-web python manage.py test
24 changes: 21 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
FROM python:3.6
FROM python:3.7-buster

ENV PYTHONUNBUFFERED 1
RUN mkdir /code
RUN apt-get update \
&& apt-get install -y \
postgresql \
netcat \
apache2 \
apache2-dev \
libapache2-mod-wsgi-py3 \
&& rm -rf /var/lib/apt/lists/*

RUN a2dissite 000-default

COPY apache/django.conf /etc/apache2/sites-available/request-broker.conf
RUN a2ensite request-broker.conf

WORKDIR /code
ADD requirements.txt /code/
RUN pip install --upgrade pip && pip install -r requirements.txt
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt

EXPOSE 8000

ADD . /code/

ENTRYPOINT ["/code/entrypoint.sh"]
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Request Broker

An application to process retrieval and duplication requests from our discovery system, and route relevant item data to our retrieval management system and back to researchers.
An application that accepts requests with lists of ArchivesSpace URIs from users of our discovery system. For each item, the application fetches data from ArchivesSpace, formats that data for delivery to our retrieval management system (Aeon) to enable reading room or duplication requests, or formats the data for email delivery or CSV download. It routes formatted data to the retrieval system or to an email for researcher use. This is a passthrough service; users cannot create requests directly in the application.

The request broker is part of [Project Electron](https://github.com/RockefellerArchiveCenter/project_electron), an initiative to build sustainable, open and user-centered infrastructure for the archival management of digital records at the [Rockefeller Archive Center](http://rockarch.org/).

## Setup

Expand All @@ -26,13 +28,36 @@ Or, if you want to remove all data

## Services

* Request Pre-Processing: Iterates over a list of request URIs, fetches corresponding data from ArchivesSpace, parses the data and marks it as submittable or unsubmittable.
* Mailer: correctly formats the body of an email message and sends an email to an address or list of addresses.
* Aeon Request Submission: creates retrieval and duplication transactions in Aeon by sending data to the Aeon API.
* CSV Download: formats parsed ArchivesSpace data into rows and columns for CSV download.

### Routes

| Method | URL | Parameters | Response | Behavior |
|--------|-----|---|---|---|
|POST|/api/deliver-request/email| |200|Delivers email messages containing data|
|POST|/api/process-request/parse| |200|Parses requests into a submittable and unsubmittable list|
|POST|/api/process-request/email| |200|Processes data in preparation for sending an email|
|POST|/api/download-csv/| |200|Downloads a CSV file of items|

### Authorization

This application uses the [Django REST Framework API Key](https://florimondmanca.github.io/djangorestframework-api-key/) library to limit which external applications are able to use its endpoints. All requests must include a `X-Request-Broker-Key` header key with the value of a valid API Key.

API Keys can be be generated in the Django shell:
```
>>> from rest_framework_api_key.models import APIKey
>>> api_key, key = APIKey.objects.create_key(name="remote-service")
```

For further details on usage, look at Request Broker's tests or [Django REST Framework API Key documentation](https://florimondmanca.github.io/djangorestframework-api-key/).

## Requirements

Using this repo requires having [Docker](https://store.docker.com/search?type=edition&offering=community) installed.


## License

Code is released under an MIT License, as all your code should be. See [LICENSE](LICENSE) for details.
23 changes: 23 additions & 0 deletions apache/django.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Listen 8000
ServerName localhost

<VirtualHost *:8000>

WSGIScriptAlias / /code/request_broker/wsgi.py process-group=request-broker
WSGIDaemonProcess request-broker home=/code

Alias /static /code/static

<Directory /code/static>
Options Includes FollowSymLinks MultiViews
Require all granted
</Directory>

<Directory /code>
WSGIProcessGroup request-broker
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>

</VirtualHost>
10 changes: 10 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2.4'

services:
request-broker-web:
image: rockarch/request_broker:development
command: apachectl -D FOREGROUND
ports:
- "8001:8000"
env_file:
- ./.env.dev
10 changes: 10 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2.4'

services:
request-broker-web:
image: rockarch/request_broker:0.1
command: apachectl -D FOREGROUND
ports:
- "8001:8000"
env_file:
- ./.env.prod
20 changes: 19 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@ services:
image: postgres:10.4
volumes:
- request_broker_dbvolume:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=request_broker_dev
request-broker-web:
build: .
entrypoint: /code/entrypoint.sh
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- request-broker-db
environment:
- DEBUG=1
- SECRET_KEY=obop2gifqn6wncaha^dt!w3an-%vkj_&1a@(w-2ci0))^o%#f4
- DJANGO_ALLOWED_HOSTS=request-broker-web localhost 192.168.1.5
- SQL_ENGINE=django.db.backends.postgresql
- SQL_DATABASE=postgres
- SQL_USER=postgres
- SQL_PASSWORD=postgres
- SQL_HOST=request-broker-db
- SQL_PORT=5432
- AS_BASEURL=http://as.rockarch.org:8089/
- AS_USERNAME=admin
- AS_PASSWORD=admin
- AS_REPO_ID=2

volumes:
request_broker_dbvolume:
18 changes: 13 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/bin/bash

# Apply database migrations
./wait-for-it.sh db:5432 -- echo "Apply database migrations"
echo "Waiting for PostgreSQL..."

while ! nc -z $SQL_HOST $SQL_PORT; do
sleep 0.1
done

echo "Connected to PostgreSQL"

# apply database migrations
python manage.py migrate

#Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000
# collect static files
python manage.py collectstatic --no-input --clear

exec "$@"
19 changes: 19 additions & 0 deletions fixtures/as_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"creators": "Ford Foundation",
"collection_name": "Ford Foundation records, General Correspondence",
"parent": "General Correspondence",
"dates": "1951-1960",
"resource_id": "FA735",
"containers": "Reel C-1138",
"preferred_instance": {
"barcode": "A0000000037985",
"container": "Reel C-1138",
"format": "microfilm",
"location": "Rockefeller Archive Center, Blue Level, Vault 106 [Cabinet: 11a, Drawer: 2]",
"uri": "/top_containers/3314"
},
"title": "Adler, Mortimer J.",
"restrictions": "closed",
"restrictions_text": "Closed until further notice due to personally identifying information.",
"uri": "/repositories/2/archival_objects/986296"
}
Loading

0 comments on commit 3cff029

Please sign in to comment.