diff --git a/onadata/apps/api/__init__.py b/onadata/apps/api/__init__.py index 47057b871..e69de29bb 100644 --- a/onadata/apps/api/__init__.py +++ b/onadata/apps/api/__init__.py @@ -1,54 +0,0 @@ - -import re - -import pyxform.odk_validate - - -############################################################################# -# WARNING -# This is a monkey patch to fix a bug in odk and should be removed as soon as -# the fix is upstream -############################################################################# - -def _cleanup_errors(error_message): - - # this is the same code as the original function - def get_last_item(xpathStr): - l = xpathStr.split("/") - return l[len(l) - 1] - - def replace_function(match): - strmatch = match.group() - if strmatch.startswith("/html/body") \ - or strmatch.startswith("/root/item") \ - or strmatch.startswith("/html/head/model/bind") \ - or strmatch.endswith("/item/value"): - return strmatch - return "${%s}" % get_last_item(match.group()) - pattern = "(/[a-z0-9\-_]+(?:/[a-z0-9\-_]+)+)" - error_message = re.compile(pattern, flags=re.I).sub(replace_function, - error_message) - k = [] - lastline = '' - for line in error_message.splitlines(): - has_java_filename = line.find('.java:') is not -1 - is_a_java_method = line.find('\tat') is not -1 - is_duplicate = (line == lastline) - lastline = line - if not has_java_filename and not is_a_java_method and not is_duplicate: - if line.startswith('java.lang.RuntimeException: '): - line = line.replace('java.lang.RuntimeException: ', '') - if line.startswith('org.javarosa.xpath.XPathUnhandledException: '): - line = line.replace('org.javarosa.xpath.XPathUnhandledException: ', '') - if line.startswith('java.lang.NullPointerException'): - continue - k.append(line) - - # original value causing UnicodeDecodeError - #return u'\n'.join(k) - - # Fix: - return '\n'.join(k).decode('ascii', errors="replace") - - -pyxform.odk_validate._cleanup_errors = _cleanup_errors diff --git a/onadata/apps/logger/views.py b/onadata/apps/logger/views.py index 112fd87f1..778c21321 100644 --- a/onadata/apps/logger/views.py +++ b/onadata/apps/logger/views.py @@ -33,7 +33,6 @@ from django.views.decorators.csrf import csrf_exempt from django_digest import HttpDigestAuthenticator from pyxform import Survey -from pyxform.spss import survey_to_spss_label_zip from wsgiref.util import FileWrapper from onadata.apps.main.models import UserProfile, MetaData @@ -443,37 +442,6 @@ def download_jsonform(request, username, id_string): return response -def download_spss_labels(request, username, form_id_string): - xform = get_object_or_404(XForm, - user__username__iexact=username, - id_string__exact=form_id_string) - owner = User.objects.get(username__iexact=username) - helper_auth_helper(request) - - if not has_permission(xform, owner, request, xform.shared): - return HttpResponseForbidden('Not shared.') - - try: - xlsform_io= xform.to_xlsform() - if not xlsform_io: - messages.add_message(request, messages.WARNING, - _(u'No XLS file for your form ' - u'%(id)s') - % {'id': form_id_string}) - return HttpResponseRedirect("/%s" % username) - except: - return HttpResponseServerError('Error retrieving XLSForm.') - - survey= Survey.from_xls(filelike_obj=xlsform_io) - zip_filename= '{}_spss_labels.zip'.format(xform.id_string) - zip_io= survey_to_spss_label_zip(survey, xform.id_string) - - response = StreamingHttpResponse(FileWrapper(zip_io), - content_type='application/zip; charset=utf-8') - response['Content-Disposition'] = 'attachment; filename={}'.format(zip_filename) - return response - - @is_owner @require_POST def delete_xform(request, username, id_string): diff --git a/onadata/apps/main/urls.py b/onadata/apps/main/urls.py index 4b06b6078..28fd615ee 100644 --- a/onadata/apps/main/urls.py +++ b/onadata/apps/main/urls.py @@ -186,8 +186,6 @@ url(r"^(?P\w+)/exports/(?P[^/]+)/(?P\w+)" "/(?P[^/]+)$", 'onadata.apps.viewer.views.export_download'), - url(r'^(?P\w+)/forms/(?P[^/]+)/spss_labels\.zip$', - 'onadata.apps.logger.views.download_spss_labels', name='download_spss_labels'), url(r'^(?P\w+)/exports/', include('onadata.apps.export.urls')), url(r'^(?P\w+)/reports/', include('onadata.apps.survey_report.urls')), diff --git a/requirements/base.pip b/requirements/base.pip index d7cfcc6d6..9d1d06ce5 100644 --- a/requirements/base.pip +++ b/requirements/base.pip @@ -18,9 +18,7 @@ poster==0.8.1 psycopg2==2.5.4 pymongo==2.7.2 lxml==3.4.0 -#-e git+https://github.com/onaio/pyxform.git@onaio#egg=pyxform -# kobo fork supports csvs with utf, character escaping, etc. --e git+https://github.com/kobotoolbox/pyxform.git@2.017.36#egg=pyxform +pyxform==0.11.5 django-reversion==2.0.8 xlrd==0.9.3 xlwt==0.7.5