bcgov / gwells

Groundwater Wells and Aquifers application for the Ministry of Environment
https://apps.nrs.gov.bc.ca/gwells/
Apache License 2.0
29 stars 36 forks source link

Get List of GWELLS Attachments #1875

Open carmenriddel opened 1 year ago

carmenriddel commented 1 year ago

There is a file called manage.py located in gwells/app/backend You will need to have your env setup before you can run. I found it easiest to install Django version 3 (3.2.15) instead of 4.

First set the following env vars depending on whether you want private or public documents

# private documents
export WATER_1651_GWELLS_URL_PREFIX=https://apps.nrs.gov.bc.ca/gwells/well/
export WATER_1651_GWELLS_S3_PREFIX=https://gwells-docs-production.apps.silver.devops.gov.bc.ca/
export S3_HOST=gwells-docs-production.apps.silver.devops.gov.bc.ca
export S3_PUBLIC_ACCESS_KEY=<S3_PUBLIC_ACCESS_KEY>
export S3_PUBLIC_SECRET_KEY=<S3_PUBLIC_SECRET_KEY>
export S3_WELL_BUCKET=gwells-private

# public documents
export WATER_1651_GWELLS_URL_PREFIX=https://apps.nrs.gov.bc.ca/gwells/well/
export WATER_1651_GWELLS_S3_PREFIX=https://s3.ca-central-1.amazonaws.com/
export S3_HOST=s3.ca-central-1.amazonaws.com
export S3_PUBLIC_ACCESS_KEY=<MINIO ACCESS KEY>
export S3_PUBLIC_SECRET_KEY=<MINIO_SECRET_KEY>
export S3_WELL_BUCKET=gwells-private

Then run the manage.py file:

python manage.py export_wtn_documents_csv --cleanup=1 --upload=1

This will upload a csv list of either public or private GWELLS attachments to the associated bucket

Note: Don't set these variables on staging on prod, and be careful setting them on a dev environment. Make sure it clear them once you're done to remove the link.

carmenriddel commented 1 year ago

Previous JIRA ticket: https://apps.nrs.gov.bc.ca/int/jira/browse/WATER-1651

carmenriddel commented 1 year ago

EDIT: for public documents, export S3_WELL_BUCKET=gwells-docs

carmenriddel commented 1 year ago

EDIT: S3_PUBLIC_ACCESS_KEY and S3_PUBLIC_SECRET_KEY are mixed up for Private/Public (Minio associated with Private).

QSu-2023 commented 1 month ago

Can be closed.

If a list of private/public attachments is needed in the future, we can request then. It will be useful to make the attachments searchable in GWELLS --we can leave this for future enhancement.