Skip to content

Commit

Permalink
Only generate hash for linked only datasets,
Browse files Browse the repository at this point in the history
not any other form media files uploaded

fixes #1411

Signed-off-by: Lincoln Simba <[email protected]>
  • Loading branch information
lincmba committed Dec 17, 2018
1 parent f7863f3 commit 18a6ab9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions onadata/libs/serializers/xform_serializer.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import os
import logging
import os
from hashlib import md5
from future.moves.urllib.parse import urlparse
from future.utils import listvalues

from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.db.models import Count
from future.moves.urllib.parse import urlparse
from future.utils import listvalues
from requests.exceptions import ConnectionError
from rest_framework import serializers
from rest_framework.reverse import reverse

from onadata.apps.logger.models import DataView, Instance, XForm
from onadata.apps.main.models.meta_data import MetaData
from onadata.libs.exceptions import EnketoError
from onadata.libs.permissions import get_role, is_organization
from onadata.libs.serializers.dataview_serializer import \
DataViewMinimalSerializer
Expand All @@ -25,12 +26,11 @@
ENKETO_PREVIEW_URL_CACHE, ENKETO_URL_CACHE, XFORM_DATA_VERSIONS,
XFORM_LINKED_DATAVIEWS, XFORM_METADATA_CACHE, XFORM_PERMISSIONS_CACHE,
XFORM_COUNT)
from onadata.libs.utils.common_tags import (GROUP_DELIMETER_TAG,
REPEAT_INDEX_TAGS)
from onadata.libs.utils.decorators import check_obj
from onadata.libs.utils.viewer_tools import (
enketo_url, get_enketo_preview_url, get_form_url)
from onadata.libs.exceptions import EnketoError
from onadata.libs.utils.common_tags import (GROUP_DELIMETER_TAG,
REPEAT_INDEX_TAGS)


def _create_enketo_url(request, xform):
Expand Down Expand Up @@ -394,7 +394,8 @@ def get_hash(self, obj):
parts = filename.split(' ')
# filtered dataset is of the form "xform PK name", xform pk is the
# second item
if len(parts) > 2:
# other file uploads other than linked datasets have a data_file
if len(parts) > 2 and obj.data_file == '':
dataset_type = parts[0]
pk = parts[1]
xform = None
Expand Down

0 comments on commit 18a6ab9

Please sign in to comment.