(email_address, user)
return template, args
Generate the data to render the Target details template.

    :param email_address: The email address of the target.
    :type email_address: str
    :param user: The user requesting this information.
    :type user: CRITsUser
    :returns: template (str), arguments (dict)
Generate the data to render the Target details template.
Generate the data to render the Target details template .
def get_target_details(email_address, user):
    """
    Generate the data to render the Target details template.

    :param email_address: The email address of the target.
    :type email_address: str
    :param user: The user requesting this information.
    :type user: CRITsUser
    :returns: template (str), arguments (dict)
    """

    template = None
    if not email_address:
        template = "error.html"
        args = {'error': "Must provide an email address."}
        return template, args

    # check for exact match first
    target = Target.objects(email_address=email_address).first()

    if not target: # if no exact match, look for case-insensitive match
        target = Target.objects(email_address__iexact=email_address).first()
    if not target:
        target = Target()
        target.email_address = email_address.strip().lower()
        form = TargetInfoForm(analyst, initial={'email_address': email_address})
    email_list = target.find_emails(user)
    form = TargetInfoForm(user, initial=target.to_dict())

    if form.fields.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME) != None:
        form.fields.pop(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)

    if form.fields.get(form_consts.Common.TICKET_VARIABLE_NAME) != None:
        form.fields.pop(form_consts.Common.TICKET_VARIABLE_NAME)

    subscription = {
        'type': 'Target',
        'id': target.id,
        'subscribed': is_user_subscribed("%s" % user,
                                            'Target',
                                            target.id)
    }

    #objects
    objects = target.sort_objects()

    #relationships
    relationships = target.sort_relationships("%s" % user,
                                                meta=True)

    # relationship
    relationship = {
            'type': 'Target',
            'value': target.id
    }

    #comments
    if target.id:
        comments = {'comments': target.get_comments(),
                    'url_key': email_address}
    else:
        comments = {'comments': [],
                    'url_key': email_address}

    #screenshots
    screenshots = target.get_screenshots(user)

    # favorites
    favorite = is_user_favorite("%s" % user, 'Target', target.id)

    # analysis results
    service_results = target.get_analysis_results()

    args = {'objects': objects,
            'relationships': relationships,
            'relationship': relationship,
            'comments': comments,
            'favorite': favorite,
            'subscription': subscription,
            'screenshots': screenshots,
            'email_list': email_list,
            'target_detail': target,
            'service_results': service_results,
            'form': form,
            'TargetACL': TargetACL}

    return template, args
def get_target_details ( email_address , user ) : template = None if not email_address : template = "error.html" args = { 'error' : "Must provide an email address." } return template , args # check for exact match first target = Target . objects ( email_address = email_address ) . first ( ) if not target : # if no exact match, look for case-insensitive match target = Target . objects ( email_address__iexact = email_address ) . first ( ) if not target : target = Target ( ) target . email_address = email_address . strip ( ) . lower ( ) form = TargetInfoForm ( analyst , initial = { 'email_address' : email_address } ) email_list = target . find_emails ( user ) form = TargetInfoForm ( user , initial = target . to_dict ( ) ) if form . fields . get ( form_consts . Common . BUCKET_LIST_VARIABLE_NAME ) != None : form . fields . pop ( form_consts . Common . BUCKET_LIST_VARIABLE_NAME ) if form . fields . get ( form_consts . Common . TICKET_VARIABLE_NAME ) != None : form . fields . pop ( form_consts . Common . TICKET_VARIABLE_NAME ) subscription = { 'type' : 'Target' , 'id' : target . id , 'subscribed' : is_user_subscribed ( "%s" % user , 'Target' , target . id ) } #objects objects = target . sort_objects ( ) #relationships relationships = target . sort_relationships ( "%s" % user , meta = True ) # relationship relationship = { 'type' : 'Target' , 'value' : target . id } #comments if target . id : comments = { 'comments' : target . get_comments ( ) , 'url_key' : email_address } else : comments = { 'comments' : [ ] , 'url_key' : email_address } #screenshots screenshots = target . get_screenshots ( user ) # favorites favorite = is_user_favorite ( "%s" % user , 'Target' , target . id ) # analysis results service_results = target . get_analysis_results ( ) args = { 'objects' : objects , 'relationships' : relationships , 'relationship' : relationship , 'comments' : comments , 'favorite' : favorite , 'subscription' : subscription , 'screenshots' : screenshots , 'email_list' : email_list , 'target_detail' : target , 'service_results' : service_results , 'form' : form , 'TargetACL' : TargetACL } return template , args