Beispiel #1
0
def serialize_receivertip(store, rtip, language):
    rtip_dict = {
        'id': rtip.id,
        'creation_date': datetime_to_ISO8601(rtip.internaltip.creation_date),
        'last_access': datetime_to_ISO8601(rtip.last_access),
        'access_counter': rtip.access_counter,
        'questionnaire': db_get_archived_questionnaire_schema(store, rtip.internaltip.questionnaire_hash, language),
        'answers': db_serialize_questionnaire_answers(store, rtip.internaltip),
        'context_id': rtip.internaltip.context.id,
        'expiration_date': datetime_to_ISO8601(rtip.internaltip.expiration_date)
    }

    return rtip_dict
Beispiel #2
0
def update_identity_information(store, tip_id, identity_field_id, identity_field_answers, language):
    wbtip = db_access_wbtip(store, tip_id)
    internaltip = wbtip.internaltip
    identity_provided = internaltip.identity_provided

    if not identity_provided:
        questionnaire = db_get_archived_questionnaire_schema(store, internaltip.questionnaire_hash, language)
        for step in questionnaire:
            for field in step['children']:
                if field['id'] == identity_field_id and field['key'] == 'whistleblower_identity':
                    db_save_questionnaire_answers(store, internaltip.id,
                                                  {identity_field_id: [identity_field_answers]})
                    now = datetime_now()
                    internaltip.update_date = now
                    internaltip.identity_provided = True
                    internaltip.identity_provided_date = now
                    return
Beispiel #3
0
def update_identity_information(store, tip_id, identity_field_id, identity_field_answers, language):
    wbtip = db_access_wbtip(store, tip_id)
    internaltip = wbtip.internaltip
    identity_provided = internaltip.identity_provided

    if not identity_provided:
        questionnaire = db_get_archived_questionnaire_schema(store, internaltip.questionnaire_hash, language)
        for step in questionnaire:
            for field in step['children']:
                if field['id'] == identity_field_id and field['key'] == 'whistleblower_identity':
                    db_save_questionnaire_answers(store, internaltip.id,
                                                  {identity_field_id: [identity_field_answers]})
                    now = datetime_now()
                    internaltip.update_date = now
                    internaltip.identity_provided = True
                    internaltip.identity_provided_date = now
                    return
Beispiel #4
0
def wb_serialize_tip(store, internaltip, language):
    ret_dict = {
        'id': internaltip.id,
        'context_id': internaltip.context.id,
        'show_receivers': internaltip.context.show_receivers,
        'creation_date': datetime_to_ISO8601(internaltip.creation_date),
        'expiration_date': datetime_to_ISO8601(internaltip.expiration_date),
        'questionnaire': db_get_archived_questionnaire_schema(store, internaltip.questionnaire_hash, language),
        'answers': db_serialize_questionnaire_answers(store, internaltip),
        'tor2web': internaltip.tor2web,
        'enable_comments': internaltip.context.enable_comments,
        'enable_private_messages': internaltip.context.enable_private_messages
    }

    # context_name and context_description are localized fields
    mo = Rosetta(internaltip.context.localized_strings)
    mo.acquire_storm_object(internaltip.context)
    for attr in ['name', 'description']:
        key = "context_%s" % attr
        ret_dict[key] = mo.dump_localized_key(attr, language)

    return ret_dict