Skip to content

Commit 4f4475e

Browse files
CKAN ENV Variables (#58)
* CKAN environment variables * Security - Upgrade Django to version 1.11.27 * Resolve requirements * Test command
1 parent 0618a0b commit 4f4475e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ DEFAULT_OPTIONS = {
149149

150150
Set the enivronment variable `SENSORSAFRICA_SENTRY_DSN`.
151151

152+
### Archiving
153+
154+
Archives are sent to CKAN and require environment configuration:
155+
156+
- CKAN_ARCHIVE_API_KEY=..
157+
- CKAN_ARCHIVE_OWNER_ID=...
158+
- CKAN_ARCHIVE_URL=`<url that supports bulk uploads>`
159+
152160
## Contributing
153161

154162
[opendata-stuttgart/feinstaub-api](https://github.com/opendata-stuttgart/feinstaub-api) prefer generating and applying migration to the database at the point of deployment (probably to reduce the number of changes to be applied).

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
django==1.11.23 #LTS
1+
django==1.11.27 #LTS
22
coreapi==2.3.3
33
dj-database-url==0.5.0
44
timeago==1.0.10

sensorsafrica/management/commands/upload_to_ckan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class Command(BaseCommand):
1515
help = ""
1616

1717
def handle(self, *args, **options):
18-
openAFRICA_API_KEY = os.environ.get("openAFRICA_API_KEY")
19-
openAFRICA_CFA_ID = os.environ.get("openAFRICA_CFA_ID")
20-
openAFRICA_URL = "https://africaopendata.org"
18+
CKAN_ARCHIVE_API_KEY = os.environ.get("CKAN_ARCHIVE_API_KEY")
19+
CKAN_ARCHIVE_OWNER_ID = os.environ.get("CKAN_ARCHIVE_OWNER_ID")
20+
CKAN_ARCHIVE_URL = os.environ.get("CKAN_ARCHIVE_URL")
2121

22-
ckan = ckanapi.RemoteCKAN(openAFRICA_URL, apikey=openAFRICA_API_KEY)
22+
ckan = ckanapi.RemoteCKAN(CKAN_ARCHIVE_URL, apikey=CKAN_ARCHIVE_API_KEY)
2323

2424
city_queryset = (
2525
SensorLocation.objects.all()
@@ -33,7 +33,7 @@ def handle(self, *args, **options):
3333

3434
try:
3535
package = ckan.action.package_create(
36-
owner_org=openAFRICA_CFA_ID,
36+
owner_org=CKAN_ARCHIVE_OWNER_ID,
3737
name="sensorsafrica-airquality-archive-" + slugify(city),
3838
title="sensors.AFRICA Air Quality Archive " + city,
3939
groups=[{"name": "sensorsafrica-airquality-archive"}]

0 commit comments

Comments
 (0)