Skip to content

Commit

Permalink
Fix get_form_url when using KOBOCAT_ROOT_URI_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunwicks authored and jeverling committed Dec 18, 2017
1 parent 9431a44 commit 11dbcd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions onadata/apps/logger/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def enter_data(request, username, id_string):
if not has_edit_permission(xform, owner, request, xform.shared):
return HttpResponseForbidden(_(u'Not shared.'))

form_url = _get_form_url(request, username, settings.ENKETO_PROTOCOL)
form_url = _get_form_url(request, username)

try:
url = enketo_url(form_url, xform.id_string)
Expand Down Expand Up @@ -571,7 +571,7 @@ def edit_data(request, username, id_string, data_id):
'username': username,
'id_string': id_string}
) + "#/" + str(instance.id))
form_url = _get_form_url(request, username, settings.ENKETO_PROTOCOL)
form_url = _get_form_url(request, username)

try:
url = enketo_url(
Expand Down
12 changes: 5 additions & 7 deletions onadata/libs/utils/viewer_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.core.files.storage import get_storage_class
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.core.mail import mail_admins
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from onadata.libs.utils import common_tags
Expand Down Expand Up @@ -222,20 +223,17 @@ def create_attachments_zipfile(attachments, temporary_file=None):
return temporary_file


def _get_form_url(request, username, protocol='https'):
def _get_form_url(request, username):
if settings.TESTING_MODE:
http_host = settings.TEST_HTTP_HOST
username = settings.TEST_USERNAME
else:
http_host = request.META.get('HTTP_HOST', 'ona.io')

return '%s://%s/%s' % (protocol, http_host, username)
return request.build_absolute_uri(
reverse('user_profile', kwargs={'username': username}))


def get_enketo_edit_url(request, instance, return_url):
form_url = _get_form_url(request,
request.user.username,
settings.ENKETO_PROTOCOL)
request.user.username)
url = enketo_url(
form_url, instance.xform.id_string, instance_xml=instance.xml,
instance_id=instance.uuid, return_url=return_url)
Expand Down

0 comments on commit 11dbcd0

Please sign in to comment.