(request, rowData, cache, upload_type="File Upload")
return bound_md5_sample_form
Parse a mass upload row into an UploadFileForm.

    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :param rowData: The data in the row.
    :type rowData: dict
    :param cache: Cached data, typically for performance enhancements
                  during bulk operations.
    :type cache: dict
    :param upload_type: The type of upload.
    :type upload_type: str
    :returns: :class:`crits.samples.forms.UploadFileForm`
Parse a mass upload row into an UploadFileForm.
Parse a mass upload row into an UploadFileForm .
def parse_row_to_bound_sample_form(request, rowData, cache, upload_type="File Upload"):
    """
    Parse a mass upload row into an UploadFileForm.

    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :param rowData: The data in the row.
    :type rowData: dict
    :param cache: Cached data, typically for performance enhancements
                  during bulk operations.
    :type cache: dict
    :param upload_type: The type of upload.
    :type upload_type: str
    :returns: :class:`crits.samples.forms.UploadFileForm`
    """

    filedata = None
    fileformat = None
    password = None
    filename = None
    md5 = None
    sha1 = None
    sha256 = None
    size = None
    mimetype = None

    if not upload_type:
        upload_type = rowData.get(form_consts.Sample.UPLOAD_TYPE, "")

    if upload_type == form_consts.Sample.UploadType.FILE_UPLOAD:
        filedata = rowData.get(form_consts.Sample.FILE_DATA, "")
        fileformat = rowData.get(form_consts.Sample.FILE_FORMAT, "")
        password = rowData.get(form_consts.Sample.PASSWORD, "")
    elif upload_type == form_consts.Sample.UploadType.METADATA_UPLOAD:
        filename = rowData.get(form_consts.Sample.FILE_NAME, "")
        md5 = rowData.get(form_consts.Sample.MD5, "")
        sha1 = rowData.get(form_consts.Sample.SHA1, "")
        sha256 = rowData.get(form_consts.Sample.SHA256, "")
        size = rowData.get(form_consts.Sample.SIZE, 0)
        mimetype = rowData.get(form_consts.Sample.MIMETYPE, "")

    campaign = rowData.get(form_consts.Sample.CAMPAIGN, "")
    confidence = rowData.get(form_consts.Sample.CAMPAIGN_CONFIDENCE, "")
    is_email_results = convert_string_to_bool(rowData.get(form_consts.Sample.EMAIL_RESULTS, ""))
    related_md5 = rowData.get(form_consts.Sample.RELATED_MD5, "")
    source = rowData.get(form_consts.Sample.SOURCE, "")
    method = rowData.get(form_consts.Sample.SOURCE_METHOD, "")
    reference = rowData.get(form_consts.Sample.SOURCE_REFERENCE, "")
    tlp = rowData.get(form_consts.Sample.SOURCE_TLP, "")
    bucket_list = rowData.get(form_consts.Sample.BUCKET_LIST, "")
    ticket = rowData.get(form_consts.Common.TICKET, "")
    description = rowData.get(form_consts.Sample.DESCRIPTION, "")
    related_id = rowData.get(form_consts.Common.RELATED_ID, "")
    related_type = rowData.get(form_consts.Common.RELATED_TYPE, "")
    relationship_type = rowData.get(form_consts.Common.RELATIONSHIP_TYPE, "")

    data = {
        'upload_type': upload_type,
        'filedata': filedata,
        'filename': filename,
        'md5': md5,
        'sha1': sha1,
        'sha256': sha256,
        'size': size,
        'mimetype': mimetype,
        'file_format': fileformat,
        'campaign': campaign,
        'confidence': confidence,
        'password': password,
        'email': is_email_results,
        'related_md5': related_md5,
        'source_name': source,
        'source_method': method,
        'source_tlp': tlp,
        'source_reference': reference,
        'bucket_list': bucket_list,
        'ticket': ticket,
        'description': description,
        'related_id': related_id,
        'related_type': related_type,
        'relationship_type': relationship_type
    }

    bound_md5_sample_form = cache.get('sample_form')

    if bound_md5_sample_form == None:
        bound_md5_sample_form = UploadFileForm(request.user, data, request.FILES)
        cache['sample_form'] = bound_md5_sample_form
    else:
        bound_md5_sample_form.data = data

    bound_md5_sample_form.full_clean()
    return bound_md5_sample_form
def parse_row_to_bound_sample_form ( request , rowData , cache , upload_type = "File Upload" ) : filedata = None fileformat = None password = None filename = None md5 = None sha1 = None sha256 = None size = None mimetype = None if not upload_type : upload_type = rowData . get ( form_consts . Sample . UPLOAD_TYPE , "" ) if upload_type == form_consts . Sample . UploadType . FILE_UPLOAD : filedata = rowData . get ( form_consts . Sample . FILE_DATA , "" ) fileformat = rowData . get ( form_consts . Sample . FILE_FORMAT , "" ) password = rowData . get ( form_consts . Sample . PASSWORD , "" ) elif upload_type == form_consts . Sample . UploadType . METADATA_UPLOAD : filename = rowData . get ( form_consts . Sample . FILE_NAME , "" ) md5 = rowData . get ( form_consts . Sample . MD5 , "" ) sha1 = rowData . get ( form_consts . Sample . SHA1 , "" ) sha256 = rowData . get ( form_consts . Sample . SHA256 , "" ) size = rowData . get ( form_consts . Sample . SIZE , 0 ) mimetype = rowData . get ( form_consts . Sample . MIMETYPE , "" ) campaign = rowData . get ( form_consts . Sample . CAMPAIGN , "" ) confidence = rowData . get ( form_consts . Sample . CAMPAIGN_CONFIDENCE , "" ) is_email_results = convert_string_to_bool ( rowData . get ( form_consts . Sample . EMAIL_RESULTS , "" ) ) related_md5 = rowData . get ( form_consts . Sample . RELATED_MD5 , "" ) source = rowData . get ( form_consts . Sample . SOURCE , "" ) method = rowData . get ( form_consts . Sample . SOURCE_METHOD , "" ) reference = rowData . get ( form_consts . Sample . SOURCE_REFERENCE , "" ) tlp = rowData . get ( form_consts . Sample . SOURCE_TLP , "" ) bucket_list = rowData . get ( form_consts . Sample . BUCKET_LIST , "" ) ticket = rowData . get ( form_consts . Common . TICKET , "" ) description = rowData . get ( form_consts . Sample . DESCRIPTION , "" ) related_id = rowData . get ( form_consts . Common . RELATED_ID , "" ) related_type = rowData . get ( form_consts . Common . RELATED_TYPE , "" ) relationship_type = rowData . get ( form_consts . Common . RELATIONSHIP_TYPE , "" ) data = { 'upload_type' : upload_type , 'filedata' : filedata , 'filename' : filename , 'md5' : md5 , 'sha1' : sha1 , 'sha256' : sha256 , 'size' : size , 'mimetype' : mimetype , 'file_format' : fileformat , 'campaign' : campaign , 'confidence' : confidence , 'password' : password , 'email' : is_email_results , 'related_md5' : related_md5 , 'source_name' : source , 'source_method' : method , 'source_tlp' : tlp , 'source_reference' : reference , 'bucket_list' : bucket_list , 'ticket' : ticket , 'description' : description , 'related_id' : related_id , 'related_type' : related_type , 'relationship_type' : relationship_type } bound_md5_sample_form = cache . get ( 'sample_form' ) if bound_md5_sample_form == None : bound_md5_sample_form = UploadFileForm ( request . user , data , request . FILES ) cache [ 'sample_form' ] = bound_md5_sample_form else : bound_md5_sample_form . data = data bound_md5_sample_form . full_clean ( ) return bound_md5_sample_form