Example #1
0
def parse_row_to_bound_email_form(request, rowData, cache):
    """
    Parse a row out of mass object email adder into the
    :class:`cripts.email_addresses.forms.EmailForm`.
    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :param rowData: The data for that row.
    :type rowData: dict
    :param cache: Cached data, typically for performance enhancements
                  during bulk operations.
    :type cache: dict
    :returns: :class:`cripts.email_addresses.forms.EmailForm`.
    """

    address = rowData.get(form_consts.EmailAddress.EMAIL_ADDRESS, "")
    description = rowData.get(form_consts.EmailAddress.DESCRIPTION, "")
    analyst = request.user
    source = rowData.get(form_consts.EmailAddress.SOURCE, "")
    source_method = rowData.get(form_consts.EmailAddress.SOURCE_METHOD, "")
    source_reference = rowData.get(form_consts.EmailAddress.SOURCE_REFERENCE,
                                   "")
    bucket_list = rowData.get(form_consts.Common.BUCKET_LIST, "")
    ticket = rowData.get(form_consts.Common.TICKET, "")
    data = {
        'address': address,
        'description': description,
        'analyst': analyst,
        'source': source,
        'source_method': source_method,
        'source_reference': source_reference,
        'bucket_list': bucket_list,
        'ticket': ticket
    }

    bound_form = cache.get('email_form')

    if bound_form == None:
        bound_form = EmailAddressForm(request.user, None, data)
        bound_form.data = data
        cache['email_form'] = bound_form
    else:
        bound_form.data = data

    bound_form.full_clean()
    return bound_form
Example #2
0
def parse_row_to_bound_email_form(request, rowData, cache):
    """
    Parse a row out of mass object email adder into the
    :class:`cripts.email_addresses.forms.EmailForm`.
    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :param rowData: The data for that row.
    :type rowData: dict
    :param cache: Cached data, typically for performance enhancements
                  during bulk operations.
    :type cache: dict
    :returns: :class:`cripts.email_addresses.forms.EmailForm`.
    """

    address = rowData.get(form_consts.EmailAddress.EMAIL_ADDRESS, "")
    description = rowData.get(form_consts.EmailAddress.DESCRIPTION, "")
    analyst = request.user
    source = rowData.get(form_consts.EmailAddress.SOURCE, "")
    source_method = rowData.get(form_consts.EmailAddress.SOURCE_METHOD, "")
    source_reference = rowData.get(form_consts.EmailAddress.SOURCE_REFERENCE, "")
    bucket_list = rowData.get(form_consts.Common.BUCKET_LIST, "")
    ticket = rowData.get(form_consts.Common.TICKET, "")
    data = {
        'address': address,
        'description': description,
        'analyst': analyst,
        'source': source,
        'source_method': source_method,
        'source_reference': source_reference,
        'bucket_list': bucket_list,
        'ticket': ticket}

    bound_form = cache.get('email_form')

    if bound_form == None:
        bound_form = EmailAddressForm(request.user, None, data)
        bound_form.data = data
        cache['email_form'] = bound_form
    else:
        bound_form.data = data

    bound_form.full_clean()
    return bound_form