From 1cf93a6a4014986bcd0705747abc76c00808cbf0 Mon Sep 17 00:00:00 2001 From: Yahia Elsherbini Date: Fri, 1 May 2020 19:33:45 +0200 Subject: [PATCH 1/4] Removed all traces of stadsarchief --- Jenkinsfile | 4 +- Makefile | 14 +++--- README.md | 12 ++--- deploy/import/docker-compose.yml | 16 +++---- deploy/import/empty-database.sh | 4 +- deploy/import/import.sh | 22 ++++----- docker-compose.yml | 10 ++-- src/bouwdossiers/batch.py | 6 +-- .../management/commands/run_import.py | 2 +- src/bouwdossiers/models.py | 4 +- src/bouwdossiers/tests/test_api.py | 48 +++++++++---------- src/health/views.py | 2 +- src/main/settings.py | 8 ++-- src/main/urls.py | 8 ++-- src/main/wsgi.py | 2 +- 15 files changed, 81 insertions(+), 81 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5400382..374dc7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ #!groovy -def PROJECT_NAME = "stadsarchief" +def PROJECT_NAME = "iiif-metadata-server" def SLACK_CHANNEL = '#opdrachten-deployments' -def PLAYBOOK = 'deploy-stadsarchief.yml' +def PLAYBOOK = 'deploy-iiif-metadata-server.yml' def SLACK_MESSAGE = [ "title_link": BUILD_URL, "fields": [ diff --git a/Makefile b/Makefile index aef0327..2d769e3 100644 --- a/Makefile +++ b/Makefile @@ -54,10 +54,10 @@ env: ## Print current env env | sort import_bag: ## Populate database with Bag data - ${dc} exec database update-table.sh bag bag_verblijfsobject public stadsarchief - ${dc} exec database update-table.sh bag bag_ligplaats public stadsarchief - ${dc} exec database update-table.sh bag bag_standplaats public stadsarchief - ${dc} exec database update-table.sh bag bag_nummeraanduiding public stadsarchief - ${dc} exec database update-table.sh bag bag_pand public stadsarchief - ${dc} exec database update-table.sh bag bag_verblijfsobjectpandrelatie public stadsarchief - ${dc} exec database update-table.sh bag bag_openbareruimte public stadsarchief + ${dc} exec database update-table.sh bag bag_verblijfsobject public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_ligplaats public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_standplaats public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_nummeraanduiding public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_pand public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_openbareruimte public iiif-metadata-server diff --git a/README.md b/README.md index 5fa8bee..3a7500a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Stadsarchief +# iiif-metadata-server -Provide API and import for datasets from stadsarchief such as bouwdossiers +Provide API and import for datasets from iiif-metadata-server such as bouwdossiers # Pre_wabo and wabo dossiers @@ -70,11 +70,11 @@ Disable login requirement for local development Test API -`http://localhost:8000/stadsarchief/bouwdossier` +`http://localhost:8000/iiif-metadata-server/bouwdossier` or -`http://localhost:8000/stadsarchief/docs/swagger` +`http://localhost:8000/iiif-metadata-server/docs/swagger` @@ -82,10 +82,10 @@ or Test API login in acceptance with SWAGGER : -`https://acc.api.data.amsterdam.nl/api/swagger/?url=/stadsarchief/docs/swagger.json` +`https://acc.api.data.amsterdam.nl/api/swagger/?url=/iiif-metadata-server/docs/swagger.json` # Import database from acceptance -docker-compose exec database update-db.sh stadsarchief +docker-compose exec database update-db.sh iiif-metadata-server diff --git a/deploy/import/docker-compose.yml b/deploy/import/docker-compose.yml index 17bd98e..395e7f7 100644 --- a/deploy/import/docker-compose.yml +++ b/deploy/import/docker-compose.yml @@ -3,14 +3,14 @@ services: database: image: amsterdam/postgres11 environment: - POSTGRES_DB: stadsarchief - POSTGRES_USER: stadsarchief + POSTGRES_DB: iiif-metadata-server + POSTGRES_USER: iiif-metadata-server POSTGRES_PASSWORD: insecure volumes: - ./backups:/tmp/backups importer: - image: docker-registry.data.amsterdam.nl/datapunt/stadsarchief:${RELEASE} + image: docker-registry.data.amsterdam.nl/datapunt/iiif-metadata-server:${RELEASE} # build: ../.. links: - database @@ -19,15 +19,15 @@ services: BOUWDOSSIERS_OBJECTSTORE_PASSWORD: ${BOUWDOSSIERS_OBJECTSTORE_PASSWORD} DATABASE_HOST: database DATABASE_PORT: 5432 - DATABASE_NAME: stadsarchief - DATABASE_USER: stadsarchief + DATABASE_NAME: iiif-metadata-server + DATABASE_USER: iiif-metadata-server DATABASE_PASSWORD: insecure MIN_BOUWDOSSIERS_COUNT: command: > bash -c "/deploy/import/docker-import-db.sh" empty_db: - image: docker-registry.data.amsterdam.nl/datapunt/stadsarchief:${RELEASE} + image: docker-registry.data.amsterdam.nl/datapunt/iiif-metadata-server:${RELEASE} # build: ../.. links: - database @@ -36,8 +36,8 @@ services: BOUWDOSSIERS_OBJECTSTORE_PASSWORD: ${BOUWDOSSIERS_OBJECTSTORE_PASSWORD} DATABASE_HOST: database DATABASE_PORT: 5432 - DATABASE_NAME: stadsarchief - DATABASE_USER: stadsarchief + DATABASE_NAME: iiif-metadata-server + DATABASE_USER: iiif-metadata-server DATABASE_PASSWORD: insecure command: > bash -c "/deploy/import/docker-empty-db.sh" diff --git a/deploy/import/empty-database.sh b/deploy/import/empty-database.sh index f0962c8..c35fc95 100644 --- a/deploy/import/empty-database.sh +++ b/deploy/import/empty-database.sh @@ -6,7 +6,7 @@ set -u DIR="$(dirname $0)" dc() { - docker-compose -p stadsarchief -f ${DIR}/docker-compose.yml $* + docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml $* } echo "Removing any previous backups" @@ -26,6 +26,6 @@ echo "Emptying db" dc run --rm empty_db echo "Running backups" -dc exec -T database backup-db.sh stadsarchief +dc exec -T database backup-db.sh iiif-metadata-server dc down -v echo "Done" diff --git a/deploy/import/import.sh b/deploy/import/import.sh index fe0d1b1..fe4ae39 100755 --- a/deploy/import/import.sh +++ b/deploy/import/import.sh @@ -6,7 +6,7 @@ set -u DIR="$(dirname $0)" dc() { - docker-compose -p stadsarchief -f ${DIR}/docker-compose.yml $* + docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml $* } echo "Removing any previous backups" @@ -25,25 +25,25 @@ dc run importer /deploy/docker-migrate.sh # load latest bag into database -echo "Load latest verblijfsobjecten, ligplaatsen, standplaatsen, nummeraanduidingen en panden in stadsarchief database" +echo "Load latest verblijfsobjecten, ligplaatsen, standplaatsen, nummeraanduidingen en panden in iiif-metadata-server database" # dc exec -T database update-db.sh atlas -dc exec -T database update-table.sh bag bag_verblijfsobject public stadsarchief -dc exec -T database update-table.sh bag bag_ligplaats public stadsarchief -dc exec -T database update-table.sh bag bag_standplaats public stadsarchief -dc exec -T database update-table.sh bag bag_nummeraanduiding public stadsarchief -dc exec -T database update-table.sh bag bag_pand public stadsarchief -dc exec -T database update-table.sh bag bag_verblijfsobjectpandrelatie public stadsarchief -dc exec -T database update-table.sh bag bag_openbareruimte public stadsarchief +dc exec -T database update-table.sh bag bag_verblijfsobject public iiif-metadata-server +dc exec -T database update-table.sh bag bag_ligplaats public iiif-metadata-server +dc exec -T database update-table.sh bag bag_standplaats public iiif-metadata-server +dc exec -T database update-table.sh bag bag_nummeraanduiding public iiif-metadata-server +dc exec -T database update-table.sh bag bag_pand public iiif-metadata-server +dc exec -T database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif-metadata-server +dc exec -T database update-table.sh bag bag_openbareruimte public iiif-metadata-server echo "Importing data" dc run --rm importer echo "Drop bag tables used for importing" -docker-compose -p stadsarchief -f ${DIR}/docker-compose.yml exec -T database psql -U stadsarchief -c 'DROP TABLE bag_openbareruimte, bag_verblijfsobjectpandrelatie, bag_pand, bag_nummeraanduiding, bag_standplaats, bag_ligplaats, bag_verblijfsobject' stadsarchief +docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml exec -T database psql -U stadsarchief -c 'DROP TABLE bag_openbareruimte, bag_verblijfsobjectpandrelatie, bag_pand, bag_nummeraanduiding, bag_standplaats, bag_ligplaats, bag_verblijfsobject' stadsarchief echo "Running backups" -dc exec -T database backup-db.sh stadsarchief +dc exec -T database backup-db.sh iiif-metadata-server dc down -v echo "Done" diff --git a/docker-compose.yml b/docker-compose.yml index 5999867..adac278 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: ports: - "5432:5432" environment: - POSTGRES_DB: stadsarchief - POSTGRES_USER: stadsarchief + POSTGRES_DB: iiif-metadata-server + POSTGRES_USER: iiif-metadata-server POSTGRES_PASSWORD: insecure volumes: - "~/.ssh/datapunt.key:/root/.ssh/datapunt.key" @@ -15,7 +15,7 @@ services: build: context: . target: app - image: docker-registry.data.amsterdam.nl/datapunt/stadsarchief:${VERSION:-latest} + image: docker-registry.data.amsterdam.nl/datapunt/iiif-metadata-server:${VERSION:-latest} ports: - 8000:8000 environment: @@ -58,8 +58,8 @@ services: environment: - DATAPUNT_API_URL=${DATAPUNT_API_URL:-https://api.data.amsterdam.nl/} - SECRET_KEY=insecure - - DATABASE_NAME=stadsarchief - - DATABASE_USER=stadsarchief + - DATABASE_NAME=iiif-metadata-server + - DATABASE_USER=iiif-metadata-server - DATABASE_PASSWORD=insecure entrypoint: /deploy/wait-for-it.sh database:5432 -- diff --git a/src/bouwdossiers/batch.py b/src/bouwdossiers/batch.py index d3c26e4..8a81d6e 100644 --- a/src/bouwdossiers/batch.py +++ b/src/bouwdossiers/batch.py @@ -10,14 +10,14 @@ log = logging.getLogger(__name__) -# This project now only uses the STADSDEEL codes received from the stadsarchief xml files. +# This project now only uses the STADSDEEL codes received from the metadata xml files. # The decision was made to avoid confusion especially because the STADSDEEL # codes are used in the document names. -# The below mapping was used earlier to map the STADSDEEl codes received from the stadsarchief xml files +# The below mapping was used earlier to map the STADSDEEl codes received from the metadata xml files # To the codes in bag api. It is kept for reference. -# Stadsarchief stadsdeel codes +# stadsdeel codes # MAP_STADSDEEL_XML_CODE = { # 'SA': 'Centrum', # 'SU': 'Oost', diff --git a/src/bouwdossiers/management/commands/run_import.py b/src/bouwdossiers/management/commands/run_import.py index 19f3840..434dad0 100644 --- a/src/bouwdossiers/management/commands/run_import.py +++ b/src/bouwdossiers/management/commands/run_import.py @@ -81,7 +81,7 @@ def import_dossiers(self, options): import_pre_wabo_dossiers(max_files_count) def handle(self, *args, **options): - log.info('Stadsarchief import started') + log.info('Metadata import started') if not options['skipgetfiles']: log.info('Get files from objectstore') diff --git a/src/bouwdossiers/models.py b/src/bouwdossiers/models.py index 481fcf0..7a726cb 100644 --- a/src/bouwdossiers/models.py +++ b/src/bouwdossiers/models.py @@ -55,7 +55,7 @@ class BouwDossier(models.Model): id = models.AutoField(primary_key=True) importfile = models.ForeignKey(ImportFile, related_name='bouwdossiers', on_delete=CASCADE) dossiernr = models.IntegerField(null=False) - stadsdeel = models.CharField(max_length=3, db_index=True) # stadsarchief stadsdeel + stadsdeel = models.CharField(max_length=3, db_index=True) titel = models.CharField(max_length=512, null=False, db_index=True) datering = models.DateField(null=True) dossier_type = models.CharField(max_length=64, null=True) @@ -98,7 +98,7 @@ class Adres(models.Model): huisnummer_van = models.IntegerField(null=True) huisnummer_tot = models.IntegerField(null=True) openbareruimte_id = models.CharField(max_length=16, db_index=True, null=True) # landelijk_id - stadsdeel = models.CharField(max_length=3, db_index=True) # stadsarchief stadsdeel + stadsdeel = models.CharField(max_length=3, db_index=True) nummeraanduidingen = ArrayField(models.CharField(max_length=16, null=False), blank=True) nummeraanduidingen_label = ArrayField(models.CharField(max_length=256, null=False), blank=True) panden = ArrayField(models.CharField(max_length=16, null=False), blank=True) diff --git a/src/bouwdossiers/tests/test_api.py b/src/bouwdossiers/tests/test_api.py index a227dc5..67e9f91 100644 --- a/src/bouwdossiers/tests/test_api.py +++ b/src/bouwdossiers/tests/test_api.py @@ -16,19 +16,19 @@ def setUpClass(cls): factories.AdresFactory() def test_api_list(self): - url = '/stadsarchief/bouwdossier/' + url = '/iiif-metadata-server/bouwdossier/' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertGreaterEqual(response.data['count'], 1) def test_api_malformed_code(self): - url = '/stadsarchief/bouwdossier/1/' + url = '/iiif-metadata-server/bouwdossier/1/' response = self.client.get(url) self.assertEqual(response.status_code, 400) def test_api_one_using_stadsdeel_and_dossier(self): - url = '/stadsarchief/bouwdossier/AA12345/' + url = '/iiif-metadata-server/bouwdossier/AA12345/' response = self.client.get(url) self.assertEqual(response.data['stadsdeel'], 'AA') self.assertEqual(response.data['dossiernr'], 12345) @@ -38,14 +38,14 @@ def test_api_one_using_stadsdeel_3_letters(self): dossier.stadsdeel = 'AAA' dossier.save() - url = '/stadsarchief/bouwdossier/AAA12345/' + url = '/iiif-metadata-server/bouwdossier/AAA12345/' response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(response.data['stadsdeel'], 'AAA') self.assertEqual(response.data['dossiernr'], 12345) def test_dossiernr_stadsdeel(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=AA' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -62,21 +62,21 @@ def test_dossiernr_stadsdeel(self): self.assertEqual(response.data['results'][0]['adressen'][0]['panden'][0], '0363100012165490') def test_dossiernr_stadsdeel_None1(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=CC' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=CC' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_None2(self): - url = '/stadsarchief/bouwdossier/?dossiernr=54321&stadsdeel=AA' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=54321&stadsdeel=AA' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_nummeraanduiding(self): - url = '/stadsarchief/bouwdossier/?nummeraanduiding=0363200000406187' + url = '/iiif-metadata-server/bouwdossier/?nummeraanduiding=0363200000406187' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -84,14 +84,14 @@ def test_nummeraanduiding(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_nummeraanduiding_no(self): - url = '/stadsarchief/bouwdossier/?nummeraanduiding=0363200000406188' + url = '/iiif-metadata-server/bouwdossier/?nummeraanduiding=0363200000406188' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_pand(self): - url = '/stadsarchief/bouwdossier/?pand=0363100012165490' + url = '/iiif-metadata-server/bouwdossier/?pand=0363100012165490' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -99,7 +99,7 @@ def test_pand(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_vbo(self): - url = '/stadsarchief/bouwdossier/?verblijfsobject=036301000xxxxxxx' + url = '/iiif-metadata-server/bouwdossier/?verblijfsobject=036301000xxxxxxx' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -107,7 +107,7 @@ def test_vbo(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_openbareruimte(self): - url = '/stadsarchief/bouwdossier/?openbareruimte=0363300000004835' + url = '/iiif-metadata-server/bouwdossier/?openbareruimte=0363300000004835' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -115,14 +115,14 @@ def test_openbareruimte(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossiernr_stadsdeel_max_datering_none(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=A&max_datering=1997' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=A&max_datering=1997' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_max_datering(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=AA&max_datering=2000' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA&max_datering=2000' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -130,14 +130,14 @@ def test_dossiernr_stadsdeel_max_datering(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossiernr_stadsdeel_min_datering_none(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=A&min_datering=1999' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=A&min_datering=1999' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_min_datering(self): - url = '/stadsarchief/bouwdossier/?dossiernr=12345&stadsdeel=AA&min_datering=1997' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA&min_datering=1997' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -148,7 +148,7 @@ def test_filter_subdossier(self): """ subdossier should match with case insensitive start of titel of subdossier """ - url = '/stadsarchief/bouwdossier/?subdossier=tekeningen' + url = '/iiif-metadata-server/bouwdossier/?subdossier=tekeningen' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -156,14 +156,14 @@ def test_filter_subdossier(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_subdossier_none(self): - url = '/stadsarchief/bouwdossier/?subdossier=dit_match_niet' + url = '/iiif-metadata-server/bouwdossier/?subdossier=dit_match_niet' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossier_type(self): - url = '/stadsarchief/bouwdossier/?dossier_type=verbouwing' + url = '/iiif-metadata-server/bouwdossier/?dossier_type=verbouwing' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -171,14 +171,14 @@ def test_dossier_type(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossier_type_none(self): - url = '/stadsarchief/bouwdossier/?dossier_type=geen_type' + url = '/iiif-metadata-server/bouwdossier/?dossier_type=geen_type' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossier_with_stadsdeel(self): - url = '/stadsarchief/bouwdossier/?dossier=AA12345' + url = '/iiif-metadata-server/bouwdossier/?dossier=AA12345' response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertIn('results', response.data) @@ -196,12 +196,12 @@ def test_dossier_with_stadsdeel(self): self.assertEqual(response.data['results'][0]['adressen'][0]['panden'][0], '0363100012165490') def test_wrong_dossier_with_stadsdeel(self): - url = '/stadsarchief/bouwdossier/?dossier=12345' + url = '/iiif-metadata-server/bouwdossier/?dossier=12345' response = self.client.get(url) self.assertEqual(response.status_code, 400) def test_invalid_dossiernr(self): - url = '/stadsarchief/bouwdossier/?dossiernr=wrong' + url = '/iiif-metadata-server/bouwdossier/?dossiernr=wrong' response = self.client.get(url) self.assertEqual(response.status_code, 400) @@ -222,7 +222,7 @@ def test_dossier_wabo_fields(self): adres.huisnummer_toevoeging = 'B' adres.save() - url = '/stadsarchief/bouwdossier/AA12345/' + url = '/iiif-metadata-server/bouwdossier/AA12345/' response = self.client.get(url) documents = response.data.get('documenten') adressen = response.data['adressen'] diff --git a/src/health/views.py b/src/health/views.py index 2873e8e..912ecd0 100644 --- a/src/health/views.py +++ b/src/health/views.py @@ -45,7 +45,7 @@ def health(_request): def check_data(request): if model.objects.all().count() < 100: return HttpResponse( - "Too few stadsarchief data in the database", + "Too few metadata in the database", content_type="text/plain", status=500) return HttpResponse( diff --git a/src/main/settings.py b/src/main/settings.py index 01e1b32..58b9095 100644 --- a/src/main/settings.py +++ b/src/main/settings.py @@ -75,8 +75,8 @@ DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'NAME': os.getenv('DATABASE_NAME', 'stadsarchief'), - 'USER': os.getenv('DATABASE_USER', 'stadsarchief'), + 'NAME': os.getenv('DATABASE_NAME', 'iiif-metadata-server'), + 'USER': os.getenv('DATABASE_USER', 'iiif-metadata-server'), 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'insecure'), 'HOST': os.getenv('DATABASE_HOST', 'database'), 'PORT': os.getenv('DATABASE_PORT', '5432'), @@ -140,10 +140,10 @@ DATA_DIR = '/tmp/bouwdossiers' # SWAGGER -SWAG_PATH = 'acc.api.data.amsterdam.nl/stadsarchief/docs' +SWAG_PATH = 'acc.api.data.amsterdam.nl/iiif-metadata-server/docs' if DEBUG: - SWAG_PATH = '127.0.0.1:8000/stadsarchief/docs' + SWAG_PATH = '127.0.0.1:8000/iiif-metadata-server/docs' SWAGGER_SETTINGS = { 'exclude_namespaces': [], diff --git a/src/main/urls.py b/src/main/urls.py index 4bdf527..5c3dc2e 100644 --- a/src/main/urls.py +++ b/src/main/urls.py @@ -11,7 +11,7 @@ url(r'^status/', include('health.urls')), ], 'bouwdossiers_patterns': [ - url(r'^stadsarchief/', include(bouwdossiers_urls.urls)), + url(r'^iiif-metadata-server/', include(bouwdossiers_urls.urls)), ], } @@ -30,17 +30,17 @@ urlpatterns = [ url( - r'^stadsarchief/docs/swagger(?P\.json|\.yaml)$', + r'^iiif-metadata-server/docs/swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=None), name='schema-json' ), url( - r'^stadsarchief/docs/swagger/$', + r'^iiif-metadata-server/docs/swagger/$', schema_view.with_ui('swagger', cache_timeout=None), name='schema-swagger-ui' ), url( - r'^stadsarchief/docs/redoc/$', + r'^iiif-metadata-server/docs/redoc/$', schema_view.with_ui('redoc', cache_timeout=None), name='schema-redoc' ), diff --git a/src/main/wsgi.py b/src/main/wsgi.py index 61c6259..afd7d08 100644 --- a/src/main/wsgi.py +++ b/src/main/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for stadsarchief project. +WSGI config for iiif-metadata-server project. It exposes the WSGI callable as a module-level variable named ``application``. From 02e2b2ffe4f9ce52321f4c5d24de6ebebdf6cd9c Mon Sep 17 00:00:00 2001 From: Yahia Elsherbini Date: Wed, 6 May 2020 14:22:47 +0200 Subject: [PATCH 2/4] Changed urls to iiif-metadata --- README.md | 6 ++-- src/bouwdossiers/tests/test_api.py | 50 ++++++++++++++++-------------- src/main/urls.py | 8 ++--- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 3a7500a..61fafd4 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,11 @@ Disable login requirement for local development Test API -`http://localhost:8000/iiif-metadata-server/bouwdossier` +`http://localhost:8000/iiif-metadata/bouwdossier` or -`http://localhost:8000/iiif-metadata-server/docs/swagger` +`http://localhost:8000/iiif-metadata/docs/swagger` @@ -82,7 +82,7 @@ or Test API login in acceptance with SWAGGER : -`https://acc.api.data.amsterdam.nl/api/swagger/?url=/iiif-metadata-server/docs/swagger.json` +`https://acc.api.data.amsterdam.nl/api/swagger/?url=/iiif-metadata/docs/swagger.json` # Import database from acceptance diff --git a/src/bouwdossiers/tests/test_api.py b/src/bouwdossiers/tests/test_api.py index 67e9f91..b788752 100644 --- a/src/bouwdossiers/tests/test_api.py +++ b/src/bouwdossiers/tests/test_api.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.urls import reverse from rest_framework.test import APITestCase from bouwdossiers.models import SOURCE_WABO, BouwDossier @@ -16,19 +17,19 @@ def setUpClass(cls): factories.AdresFactory() def test_api_list(self): - url = '/iiif-metadata-server/bouwdossier/' + url = reverse('bouwdossier-list') response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertGreaterEqual(response.data['count'], 1) def test_api_malformed_code(self): - url = '/iiif-metadata-server/bouwdossier/1/' + url = reverse('bouwdossier-detail', kwargs={'pk': 1}) response = self.client.get(url) self.assertEqual(response.status_code, 400) def test_api_one_using_stadsdeel_and_dossier(self): - url = '/iiif-metadata-server/bouwdossier/AA12345/' + url = reverse('bouwdossier-detail', kwargs={'pk': 'AA12345'}) response = self.client.get(url) self.assertEqual(response.data['stadsdeel'], 'AA') self.assertEqual(response.data['dossiernr'], 12345) @@ -38,14 +39,14 @@ def test_api_one_using_stadsdeel_3_letters(self): dossier.stadsdeel = 'AAA' dossier.save() - url = '/iiif-metadata-server/bouwdossier/AAA12345/' + url = reverse('bouwdossier-detail', kwargs={'pk': 'AAA12345'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(response.data['stadsdeel'], 'AAA') self.assertEqual(response.data['dossiernr'], 12345) def test_dossiernr_stadsdeel(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=AA' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -62,21 +63,21 @@ def test_dossiernr_stadsdeel(self): self.assertEqual(response.data['results'][0]['adressen'][0]['panden'][0], '0363100012165490') def test_dossiernr_stadsdeel_None1(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=CC' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=CC' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_None2(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=54321&stadsdeel=AA' + url = reverse('bouwdossier-list') + '?dossiernr=54321&stadsdeel=AA' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_nummeraanduiding(self): - url = '/iiif-metadata-server/bouwdossier/?nummeraanduiding=0363200000406187' + url = reverse('bouwdossier-list') + '?nummeraanduiding=0363200000406187' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -84,14 +85,14 @@ def test_nummeraanduiding(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_nummeraanduiding_no(self): - url = '/iiif-metadata-server/bouwdossier/?nummeraanduiding=0363200000406188' + url = reverse('bouwdossier-list') + '?nummeraanduiding=0363200000406188' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_pand(self): - url = '/iiif-metadata-server/bouwdossier/?pand=0363100012165490' + url = reverse('bouwdossier-list') + '?pand=0363100012165490' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -99,7 +100,7 @@ def test_pand(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_vbo(self): - url = '/iiif-metadata-server/bouwdossier/?verblijfsobject=036301000xxxxxxx' + url = reverse('bouwdossier-list') + '?verblijfsobject=036301000xxxxxxx' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -107,7 +108,7 @@ def test_vbo(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_openbareruimte(self): - url = '/iiif-metadata-server/bouwdossier/?openbareruimte=0363300000004835' + url = reverse('bouwdossier-list') + '?verblijfsobject=036301000xxxxxxx/?openbareruimte=0363300000004835' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -115,14 +116,15 @@ def test_openbareruimte(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossiernr_stadsdeel_max_datering_none(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=A&max_datering=1997' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=A&max_datering=1997' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_max_datering(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA&max_datering=2000' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=AA&max_datering=2000' + print(url) response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -130,14 +132,14 @@ def test_dossiernr_stadsdeel_max_datering(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossiernr_stadsdeel_min_datering_none(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=A&min_datering=1999' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=A&min_datering=1999' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossiernr_stadsdeel_min_datering(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=12345&stadsdeel=AA&min_datering=1997' + url = reverse('bouwdossier-list') + '?dossiernr=12345&stadsdeel=AA&min_datering=1997' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -148,7 +150,7 @@ def test_filter_subdossier(self): """ subdossier should match with case insensitive start of titel of subdossier """ - url = '/iiif-metadata-server/bouwdossier/?subdossier=tekeningen' + url = reverse('bouwdossier-list') + '?subdossier=tekeningen' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -156,14 +158,14 @@ def test_filter_subdossier(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_subdossier_none(self): - url = '/iiif-metadata-server/bouwdossier/?subdossier=dit_match_niet' + url = reverse('bouwdossier-list') + '?subdossier=dit_match_niet' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossier_type(self): - url = '/iiif-metadata-server/bouwdossier/?dossier_type=verbouwing' + url = reverse('bouwdossier-list') + '?dossier_type=verbouwing' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) @@ -171,14 +173,14 @@ def test_dossier_type(self): self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') def test_dossier_type_none(self): - url = '/iiif-metadata-server/bouwdossier/?dossier_type=geen_type' + url = reverse('bouwdossier-list') + '?dossier_type=geen_type' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) def test_dossier_with_stadsdeel(self): - url = '/iiif-metadata-server/bouwdossier/?dossier=AA12345' + url = reverse('bouwdossier-list') + '?dossier=AA12345' response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertIn('results', response.data) @@ -196,12 +198,12 @@ def test_dossier_with_stadsdeel(self): self.assertEqual(response.data['results'][0]['adressen'][0]['panden'][0], '0363100012165490') def test_wrong_dossier_with_stadsdeel(self): - url = '/iiif-metadata-server/bouwdossier/?dossier=12345' + url = reverse('bouwdossier-list') + '?dossier=12345' response = self.client.get(url) self.assertEqual(response.status_code, 400) def test_invalid_dossiernr(self): - url = '/iiif-metadata-server/bouwdossier/?dossiernr=wrong' + url = reverse('bouwdossier-list') + '?dossiernr=wrong' response = self.client.get(url) self.assertEqual(response.status_code, 400) @@ -222,7 +224,7 @@ def test_dossier_wabo_fields(self): adres.huisnummer_toevoeging = 'B' adres.save() - url = '/iiif-metadata-server/bouwdossier/AA12345/' + url = reverse('bouwdossier-detail', kwargs={'pk': 'AA12345'}) response = self.client.get(url) documents = response.data.get('documenten') adressen = response.data['adressen'] diff --git a/src/main/urls.py b/src/main/urls.py index 5c3dc2e..2b5241c 100644 --- a/src/main/urls.py +++ b/src/main/urls.py @@ -11,7 +11,7 @@ url(r'^status/', include('health.urls')), ], 'bouwdossiers_patterns': [ - url(r'^iiif-metadata-server/', include(bouwdossiers_urls.urls)), + url(r'^iiif-metadata/', include(bouwdossiers_urls.urls)), ], } @@ -30,17 +30,17 @@ urlpatterns = [ url( - r'^iiif-metadata-server/docs/swagger(?P\.json|\.yaml)$', + r'^iiif-metadata/docs/swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=None), name='schema-json' ), url( - r'^iiif-metadata-server/docs/swagger/$', + r'^iiif-metadata/docs/swagger/$', schema_view.with_ui('swagger', cache_timeout=None), name='schema-swagger-ui' ), url( - r'^iiif-metadata-server/docs/redoc/$', + r'^iiif-metadata/docs/redoc/$', schema_view.with_ui('redoc', cache_timeout=None), name='schema-redoc' ), From c10bad77a7e5322dd70462858295c10a34416c78 Mon Sep 17 00:00:00 2001 From: Yahia Elsherbini Date: Thu, 7 May 2020 15:09:13 +0200 Subject: [PATCH 3/4] Changed db name to iiif_metadata_server because hyphens aren't allowed --- Makefile | 14 +++++++------- deploy/import/docker-compose.yml | 12 ++++++------ deploy/import/empty-database.sh | 2 +- deploy/import/import.sh | 16 ++++++++-------- docker-compose.yml | 8 ++++---- src/main/settings.py | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 2d769e3..abb15c6 100644 --- a/Makefile +++ b/Makefile @@ -54,10 +54,10 @@ env: ## Print current env env | sort import_bag: ## Populate database with Bag data - ${dc} exec database update-table.sh bag bag_verblijfsobject public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_ligplaats public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_standplaats public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_nummeraanduiding public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_pand public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif-metadata-server - ${dc} exec database update-table.sh bag bag_openbareruimte public iiif-metadata-server + ${dc} exec database update-table.sh bag bag_verblijfsobject public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_ligplaats public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_standplaats public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_nummeraanduiding public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_pand public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif_metadata_server + ${dc} exec database update-table.sh bag bag_openbareruimte public iiif_metadata_server diff --git a/deploy/import/docker-compose.yml b/deploy/import/docker-compose.yml index 395e7f7..95f0b6c 100644 --- a/deploy/import/docker-compose.yml +++ b/deploy/import/docker-compose.yml @@ -3,8 +3,8 @@ services: database: image: amsterdam/postgres11 environment: - POSTGRES_DB: iiif-metadata-server - POSTGRES_USER: iiif-metadata-server + POSTGRES_DB: iiif_metadata_server + POSTGRES_USER: iiif_metadata_server POSTGRES_PASSWORD: insecure volumes: - ./backups:/tmp/backups @@ -19,8 +19,8 @@ services: BOUWDOSSIERS_OBJECTSTORE_PASSWORD: ${BOUWDOSSIERS_OBJECTSTORE_PASSWORD} DATABASE_HOST: database DATABASE_PORT: 5432 - DATABASE_NAME: iiif-metadata-server - DATABASE_USER: iiif-metadata-server + DATABASE_NAME: iiif_metadata_server + DATABASE_USER: iiif_metadata_server DATABASE_PASSWORD: insecure MIN_BOUWDOSSIERS_COUNT: command: > @@ -36,8 +36,8 @@ services: BOUWDOSSIERS_OBJECTSTORE_PASSWORD: ${BOUWDOSSIERS_OBJECTSTORE_PASSWORD} DATABASE_HOST: database DATABASE_PORT: 5432 - DATABASE_NAME: iiif-metadata-server - DATABASE_USER: iiif-metadata-server + DATABASE_NAME: iiif_metadata_server + DATABASE_USER: iiif_metadata_server DATABASE_PASSWORD: insecure command: > bash -c "/deploy/import/docker-empty-db.sh" diff --git a/deploy/import/empty-database.sh b/deploy/import/empty-database.sh index c35fc95..c6e65d8 100644 --- a/deploy/import/empty-database.sh +++ b/deploy/import/empty-database.sh @@ -26,6 +26,6 @@ echo "Emptying db" dc run --rm empty_db echo "Running backups" -dc exec -T database backup-db.sh iiif-metadata-server +dc exec -T database backup-db.sh iiif_metadata_server dc down -v echo "Done" diff --git a/deploy/import/import.sh b/deploy/import/import.sh index fe4ae39..73cf048 100755 --- a/deploy/import/import.sh +++ b/deploy/import/import.sh @@ -28,13 +28,13 @@ dc run importer /deploy/docker-migrate.sh echo "Load latest verblijfsobjecten, ligplaatsen, standplaatsen, nummeraanduidingen en panden in iiif-metadata-server database" # dc exec -T database update-db.sh atlas -dc exec -T database update-table.sh bag bag_verblijfsobject public iiif-metadata-server -dc exec -T database update-table.sh bag bag_ligplaats public iiif-metadata-server -dc exec -T database update-table.sh bag bag_standplaats public iiif-metadata-server -dc exec -T database update-table.sh bag bag_nummeraanduiding public iiif-metadata-server -dc exec -T database update-table.sh bag bag_pand public iiif-metadata-server -dc exec -T database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif-metadata-server -dc exec -T database update-table.sh bag bag_openbareruimte public iiif-metadata-server +dc exec -T database update-table.sh bag bag_verblijfsobject public iiif_metadata_server +dc exec -T database update-table.sh bag bag_ligplaats public iiif_metadata_server +dc exec -T database update-table.sh bag bag_standplaats public iiif_metadata_server +dc exec -T database update-table.sh bag bag_nummeraanduiding public iiif_metadata_server +dc exec -T database update-table.sh bag bag_pand public iiif_metadata_server +dc exec -T database update-table.sh bag bag_verblijfsobjectpandrelatie public iiif_metadata_server +dc exec -T database update-table.sh bag bag_openbareruimte public iiif_metadata_server echo "Importing data" @@ -44,6 +44,6 @@ echo "Drop bag tables used for importing" docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml exec -T database psql -U stadsarchief -c 'DROP TABLE bag_openbareruimte, bag_verblijfsobjectpandrelatie, bag_pand, bag_nummeraanduiding, bag_standplaats, bag_ligplaats, bag_verblijfsobject' stadsarchief echo "Running backups" -dc exec -T database backup-db.sh iiif-metadata-server +dc exec -T database backup-db.sh iiif_metadata_server dc down -v echo "Done" diff --git a/docker-compose.yml b/docker-compose.yml index adac278..dfddb00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: ports: - "5432:5432" environment: - POSTGRES_DB: iiif-metadata-server - POSTGRES_USER: iiif-metadata-server + POSTGRES_DB: iiif_metadata_server + POSTGRES_USER: iiif_metadata_server POSTGRES_PASSWORD: insecure volumes: - "~/.ssh/datapunt.key:/root/.ssh/datapunt.key" @@ -58,8 +58,8 @@ services: environment: - DATAPUNT_API_URL=${DATAPUNT_API_URL:-https://api.data.amsterdam.nl/} - SECRET_KEY=insecure - - DATABASE_NAME=iiif-metadata-server - - DATABASE_USER=iiif-metadata-server + - DATABASE_NAME=iiif_metadata_server + - DATABASE_USER=iiif_metadata_server - DATABASE_PASSWORD=insecure entrypoint: /deploy/wait-for-it.sh database:5432 -- diff --git a/src/main/settings.py b/src/main/settings.py index 58b9095..beb4280 100644 --- a/src/main/settings.py +++ b/src/main/settings.py @@ -75,8 +75,8 @@ DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'NAME': os.getenv('DATABASE_NAME', 'iiif-metadata-server'), - 'USER': os.getenv('DATABASE_USER', 'iiif-metadata-server'), + 'NAME': os.getenv('DATABASE_NAME', 'iiif_metadata_server'), + 'USER': os.getenv('DATABASE_USER', 'iiif_metadata_server'), 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'insecure'), 'HOST': os.getenv('DATABASE_HOST', 'database'), 'PORT': os.getenv('DATABASE_PORT', '5432'), From e35c94f816eee8a9589b0ebe74c208905402bd6e Mon Sep 17 00:00:00 2001 From: Yahia Elsherbini Date: Fri, 8 May 2020 12:56:31 +0200 Subject: [PATCH 4/4] Changed db name in an deploy script that was missed --- deploy/import/import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/import/import.sh b/deploy/import/import.sh index 73cf048..1aa3d6d 100755 --- a/deploy/import/import.sh +++ b/deploy/import/import.sh @@ -41,7 +41,7 @@ echo "Importing data" dc run --rm importer echo "Drop bag tables used for importing" -docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml exec -T database psql -U stadsarchief -c 'DROP TABLE bag_openbareruimte, bag_verblijfsobjectpandrelatie, bag_pand, bag_nummeraanduiding, bag_standplaats, bag_ligplaats, bag_verblijfsobject' stadsarchief +docker-compose -p iiif-metadata-server -f ${DIR}/docker-compose.yml exec -T database psql -U iiif_metadata_server -c 'DROP TABLE bag_openbareruimte, bag_verblijfsobjectpandrelatie, bag_pand, bag_nummeraanduiding, bag_standplaats, bag_ligplaats, bag_verblijfsobject' iiif_metadata_server echo "Running backups" dc exec -T database backup-db.sh iiif_metadata_server