Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into release-2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
obdulia-losantos committed Oct 13, 2021
2 parents 3a78cc3 + 7532ffc commit 30eb037
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 67 deletions.
16 changes: 8 additions & 8 deletions aether-entity-extraction-module/conf/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
aether.python==1.3.0
attrs==21.2.0
avro-python3==1.10.2
certifi==2021.5.30
charset-normalizer==2.0.6
coverage==6.0
certifi==2021.10.8
charset-normalizer==2.0.7
coverage==6.0.2
decorator==5.1.0
eha-jsonpath==0.6.0
fakeredis==1.6.1
flake8==3.9.2
flake8==4.0.1
flake8-quotes==3.3.0
gevent==21.8.0
greenlet==1.1.2
idna==3.2
idna==3.3
iniconfig==1.1.1
jsonpath-ng==1.5.3
jsonschema==4.0.1
jsonschema==4.1.0
mccabe==0.6.1
packaging==21.0
pluggy==1.0.0
ply==3.11
py==1.10.0
pycodestyle==2.7.0
pyflakes==2.3.1
pycodestyle==2.8.0
pyflakes==2.4.0
pyparsing==2.4.7
pyrsistent==0.18.0
pytest==6.2.5
Expand Down
38 changes: 19 additions & 19 deletions aether-kernel/conf/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ asgiref==3.4.1
attrs==21.2.0
autopep8==1.5.7
avro-python3==1.10.2
boto3==1.18.54
botocore==1.21.54
boto3==1.18.60
botocore==1.21.60
cachetools==4.2.4
certifi==2021.5.30
charset-normalizer==2.0.6
certifi==2021.10.8
charset-normalizer==2.0.7
configparser==5.0.2
coreapi==2.3.3
coreschema==0.0.4
coverage==6.0
coverage==6.0.2
decorator==5.1.0
Django==3.2.8
django-cacheops==6.0
django-cleanup==5.2.0
django-cors-headers==3.9.0
django-cors-headers==3.10.0
django-debug-toolbar==3.2.2
django-dynamic-fixture==3.1.2
django-filter==21.1
Expand All @@ -41,32 +41,32 @@ django-postgrespool2==2.0.1
django-prometheus==2.1.0
django-redis==5.0.0
django-silk==4.1.0
django-storages==1.11.1
django-storages==1.12.1
django-uwsgi==0.2.2
djangorestframework==3.12.4
drf-dynamic-fields==0.3.1
drf-yasg==1.20.0
eha-jsonpath==0.6.0
et-xmlfile==1.1.0
flake8==3.9.2
flake8==4.0.1
flake8-quotes==3.3.0
funcy==1.16
google-api-core==2.0.1
google-auth==2.2.1
google-cloud-core==2.0.0
google-api-core==2.1.0
google-auth==2.3.0
google-cloud-core==2.1.0
google-cloud-storage==1.42.3
google-crc32c==1.2.0
google-crc32c==1.3.0
google-resumable-media==2.0.3
googleapis-common-protos==1.53.0
gprof2dot==2021.2.21
greenlet==1.1.2
idna==3.2
idna==3.3
inflection==0.5.1
itypes==1.2.0
Jinja2==3.0.2
jmespath==0.10.0
jsonpath-ng==1.5.3
jsonschema==4.0.1
jsonschema==4.1.0
lxml==4.6.3
Markdown==3.3.4
MarkupSafe==2.0.1
Expand All @@ -76,12 +76,12 @@ openpyxl==3.0.9
packaging==21.0
ply==3.11
prometheus-client==0.11.0
protobuf==3.18.0
protobuf==3.18.1
psycopg2-binary==2.9.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pyflakes==2.3.1
pycodestyle==2.8.0
pyflakes==2.4.0
Pygments==2.10.0
pyparsing==2.4.7
pyrsistent==0.18.0
Expand All @@ -101,6 +101,6 @@ SQLAlchemy==1.4.25
sqlparse==0.4.2
tblib==1.7.0
toml==0.10.2
uritemplate==3.0.1
uritemplate==4.1.0
urllib3==1.26.7
uWSGI==2.0.19.1
uWSGI==2.0.20
25 changes: 25 additions & 0 deletions aether-odk-module/aether/odk/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
# specific language governing permissions and limitations
# under the License.

from django.http import FileResponse
from django.test import override_settings
from django.urls import reverse

from rest_framework import status

from . import CustomTestCase
Expand Down Expand Up @@ -152,3 +154,26 @@ def test__is_surveyor(self):

response = self.client.get('/projects.json')
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

def test__project__download(self):
xform = self.helper_create_xform()

content_url = reverse('project-download', kwargs={'pk': xform.project_id})
self.assertEqual(content_url, f'/projects/{xform.project_id}/download/')
response = self.client.get(content_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertTrue(isinstance(response, FileResponse))
self.assertEqual(
response['Content-Disposition'],
f'attachment; filename="{xform.project.name}.zip"'
)

def test__xform__download(self):
xform = self.helper_create_xform()

content_url = reverse('xform-download', kwargs={'pk': xform.pk})
self.assertEqual(content_url, f'/xforms/{xform.pk}/download/')
response = self.client.get(content_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertTrue(isinstance(response, FileResponse))
self.assertEqual(xform.xml_data, response.getvalue().decode())
46 changes: 46 additions & 0 deletions aether-odk-module/aether/odk/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
# specific language governing permissions and limitations
# under the License.

import tempfile
import zipfile

from django.http import FileResponse

from rest_framework import viewsets, status
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from aether.sdk.multitenancy.views import MtViewSetMixin, MtUserViewSetMixin
from aether.sdk.utils import get_file_content

from .models import Project, XForm, MediaFile
from .serializers import (
Expand Down Expand Up @@ -82,6 +88,27 @@ def propagate(self, request, pk=None, *args, **kwargs):

return self.retrieve(request, pk, *args, **kwargs)

@action(detail=True, methods=['get'])
def download(self, request, pk=None, *args, **kwargs):
'''
Downloads the linked XForm XML definitions.
Reachable at ``.../project/{pk}/download/``
'''

project = self.get_object_or_404(pk=pk)

with tempfile.TemporaryDirectory() as temp_dir:
zip_name = f'{project.name or project.project_id}.zip'
zip_path = f'{temp_dir}/{zip_name}'

with zipfile.ZipFile(zip_path, 'w') as file_zip:
for xform in project.xforms.all():
xml_name = f'{xform.title}.xml'
file_zip.writestr(xml_name, xform.xml_data)

return get_file_content(zip_name, zip_path, as_attachment=True)


class XFormViewSet(MtViewSetMixin, viewsets.ModelViewSet):
'''
Expand Down Expand Up @@ -130,6 +157,25 @@ def propagate(self, request, pk=None, *args, **kwargs):

return self.retrieve(request, pk, *args, **kwargs)

@action(detail=True, methods=['get'])
def download(self, request, pk=None, *args, **kwargs):
'''
Downloads the linked XML definition.
Reachable at ``.../xforms/{pk}/download/``
'''

xform = self.get_object_or_404(pk=pk)

response = FileResponse(
streaming_content=xform.xml_data,
as_attachment=True,
filename=f'{xform.title}.xml',
content_type='text/xml',
)
response['Access-Control-Expose-Headers'] = 'Content-Disposition'
return response


class MediaFileViewSet(MtViewSetMixin, viewsets.ModelViewSet):
'''
Expand Down
32 changes: 16 additions & 16 deletions aether-odk-module/conf/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
aether.sdk==1.4.0
asgiref==3.4.1
autopep8==1.5.7
boto3==1.18.54
botocore==1.21.54
boto3==1.18.60
botocore==1.21.60
cachetools==4.2.4
certifi==2021.5.30
charset-normalizer==2.0.6
certifi==2021.10.8
charset-normalizer==2.0.7
configparser==5.0.2
coverage==6.0
coverage==6.0.2
Django==3.2.8
django-cacheops==6.0
django-cleanup==5.2.0
Expand All @@ -32,24 +32,24 @@ django-postgrespool2==2.0.1
django-prometheus==2.1.0
django-redis==5.0.0
django-silk==4.1.0
django-storages==1.11.1
django-storages==1.12.1
django-uwsgi==0.2.2
djangorestframework==3.12.4
drf-dynamic-fields==0.3.1
flake8==3.9.2
flake8==4.0.1
flake8-quotes==3.3.0
FormEncode==1.3.1
funcy==1.16
google-api-core==2.0.1
google-auth==2.2.1
google-cloud-core==2.0.0
google-api-core==2.1.0
google-auth==2.3.0
google-cloud-core==2.1.0
google-cloud-storage==1.42.3
google-crc32c==1.2.0
google-crc32c==1.3.0
google-resumable-media==2.0.3
googleapis-common-protos==1.53.0
gprof2dot==2021.2.21
greenlet==1.1.2
idna==3.2
idna==3.3
Jinja2==3.0.2
jmespath==0.10.0
linecache2==1.0.0
Expand All @@ -59,12 +59,12 @@ MarkupSafe==2.0.1
mccabe==0.6.1
minio==6.0.2
prometheus-client==0.11.0
protobuf==3.18.0
protobuf==3.18.1
psycopg2-binary==2.9.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pyflakes==2.3.1
pycodestyle==2.8.0
pyflakes==2.4.0
Pygments==2.10.0
python-dateutil==2.8.2
python-json-logger==2.0.2
Expand All @@ -85,5 +85,5 @@ traceback2==1.4.0
unicodecsv==0.14.1
unittest2==1.1.0
urllib3==1.26.7
uWSGI==2.0.19.1
uWSGI==2.0.20
xlrd==1.2.0
16 changes: 8 additions & 8 deletions aether-producer/conf/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
################################################################################

attrs==21.2.0
certifi==2021.5.30
charset-normalizer==2.0.6
click==8.0.1
certifi==2021.10.8
charset-normalizer==2.0.7
click==8.0.3
confluent-kafka==1.7.0
flake8==3.9.2
flake8==4.0.1
flake8-quotes==3.3.0
Flask==2.0.2
gevent==21.8.0
greenlet==1.1.2
idna==3.2
idna==3.3
iniconfig==1.1.1
itsdangerous==2.0.1
Jinja2==3.0.2
Expand All @@ -33,8 +33,8 @@ pluggy==1.0.0
psycogreen==1.0.2
psycopg2-binary==2.9.1
py==1.10.0
pycodestyle==2.7.0
pyflakes==2.3.1
pycodestyle==2.8.0
pyflakes==2.4.0
pyparsing==2.4.7
pytest==6.2.5
requests==2.26.0
Expand All @@ -43,6 +43,6 @@ spavro==1.1.24
SQLAlchemy==1.4.25
toml==0.10.2
urllib3==1.26.7
Werkzeug==2.0.1
Werkzeug==2.0.2
zope.event==4.5.0
zope.interface==5.4.0
Loading

0 comments on commit 30eb037

Please sign in to comment.