Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_form_url when using KOBOCAT_ROOT_URI_PREFIX #300

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions onadata/apps/logger/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,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 @@ -572,7 +572,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