예제 #1
0
def get_receivertip_list(store, receiver_id, language):
    rtip_summary_list = []

    for rtip in store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id):
        mo = Rosetta(rtip.internaltip.context.localized_keys)
        mo.acquire_storm_object(rtip.internaltip.context)

        rtip_summary_list.append(
            {
                "id": rtip.id,
                "creation_date": datetime_to_ISO8601(rtip.internaltip.creation_date),
                "last_access": datetime_to_ISO8601(rtip.last_access),
                "update_date": datetime_to_ISO8601(rtip.internaltip.update_date),
                "expiration_date": datetime_to_ISO8601(rtip.internaltip.expiration_date),
                "timetolive": rtip.internaltip.context.tip_timetolive,
                "progressive": rtip.internaltip.progressive,
                "new": rtip.access_counter == 0 or rtip.last_access < rtip.internaltip.update_date,
                "context_name": mo.dump_localized_key("name", language),
                "access_counter": rtip.access_counter,
                "file_counter": rtip.internaltip.internalfiles.count(),
                "comment_counter": rtip.internaltip.comments.count(),
                "message_counter": rtip.messages.count(),
                "tor2web": rtip.internaltip.tor2web,
                "questionnaire_hash": rtip.internaltip.questionnaire_hash,
                "preview_schema": db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash, language),
                "preview": rtip.internaltip.preview,
                "total_score": rtip.internaltip.total_score,
                "label": rtip.label,
            }
        )

    return rtip_summary_list
예제 #2
0
def get_receivertip_list(store, receiver_id, language):
    rtip_summary_list = []

    for rtip in store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id):
        mo = Rosetta(rtip.internaltip.context.localized_keys)
        mo.acquire_storm_object(rtip.internaltip.context)

        rtip_summary_list.append({
            'id': rtip.id,
            'creation_date': datetime_to_ISO8601(rtip.internaltip.creation_date),
            'last_access': datetime_to_ISO8601(rtip.last_access),
            'update_date': datetime_to_ISO8601(rtip.internaltip.update_date),
            'expiration_date': datetime_to_ISO8601(rtip.internaltip.expiration_date),
            'progressive': rtip.internaltip.progressive,
            'new': rtip.access_counter == 0 or rtip.last_access < rtip.internaltip.update_date,
            'context_name': mo.dump_localized_key('name', language),
            'access_counter': rtip.access_counter,
            'file_counter': rtip.internaltip.internalfiles.count(),
            'comment_counter': rtip.internaltip.comments.count(),
            'message_counter': rtip.messages.count(),
            'tor2web': rtip.internaltip.tor2web,
            'questionnaire_hash': rtip.internaltip.questionnaire_hash,
            'preview_schema': db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash, language),
            'preview': rtip.internaltip.preview,
            'total_score': rtip.internaltip.total_score,
            'label': rtip.label
        })

    return rtip_summary_list
예제 #3
0
def get_receivertip_list(store, receiver_id, language):
    rtip_summary_list = []

    for rtip in store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id):
        mo = Rosetta(rtip.internaltip.context.localized_keys)
        mo.acquire_storm_object(rtip.internaltip.context)

        rtip_summary_list.append({
            'id': rtip.id,
            'creation_date': datetime_to_ISO8601(rtip.internaltip.creation_date),
            'last_access': datetime_to_ISO8601(rtip.last_access),
            'update_date': datetime_to_ISO8601(rtip.internaltip.update_date),
            'expiration_date': datetime_to_ISO8601(rtip.internaltip.expiration_date),
            'timetolive': rtip.internaltip.context.tip_timetolive,
            'progressive': rtip.internaltip.progressive,
            'new': rtip.access_counter == 0 or rtip.last_access < rtip.internaltip.update_date,
            'context_name': mo.dump_localized_key('name', language),
            'access_counter': rtip.access_counter,
            'file_counter': rtip.internaltip.internalfiles.count(),
            'comment_counter': rtip.internaltip.comments.count(),
            'message_counter': rtip.messages.count(),
            'tor2web': rtip.internaltip.tor2web,
            'questionnaire_hash': rtip.internaltip.questionnaire_hash,
            'preview_schema': db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash, language),
            'preview': rtip.internaltip.preview,
            'total_score': rtip.internaltip.total_score,
            'label': rtip.label
        })

    return rtip_summary_list
예제 #4
0
def get_receivertip_list(store, receiver_id, language):
    rtiplist = store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id)

    rtip_summary_list = []

    for rtip in rtiplist:
        # TODO this store find in a potentially long loop is bad, is easier store in
        # InternalTip the file counter number...
        rfiles_n = store.find(
            ReceiverFile, (ReceiverFile.internaltip_id == rtip.internaltip.id,
                           ReceiverFile.receiver_id == receiver_id)).count()

        message_counter = store.find(
            Message, Message.receivertip_id == rtip.id).count()
        single_tip_sum = dict({
            'id':
            rtip.id,
            'creation_date':
            datetime_to_ISO8601(rtip.internaltip.creation_date),
            'last_access':
            datetime_to_ISO8601(rtip.last_access),
            'expiration_date':
            datetime_to_ISO8601(rtip.internaltip.expiration_date),
            'access_counter':
            rtip.access_counter,
            'file_counter':
            rfiles_n,
            'comment_counter':
            rtip.internaltip.comments.count(),
            'message_counter':
            message_counter,
            'tor2web':
            rtip.internaltip.tor2web,
            'questionnaire_hash':
            rtip.internaltip.questionnaire_hash,
            'preview_schema':
            db_get_archived_preview_schema(store,
                                           rtip.internaltip.questionnaire_hash,
                                           language),
            'preview':
            rtip.internaltip.preview,
            'label':
            rtip.label,
        })

        mo = Rosetta(rtip.internaltip.context.localized_strings)
        mo.acquire_storm_object(rtip.internaltip.context)
        single_tip_sum["context_name"] = mo.dump_localized_key(
            'name', language)

        rtip_summary_list.append(single_tip_sum)

    return rtip_summary_list
예제 #5
0
def get_receivertip_list(store, receiver_id, language):
    node = store.find(Node).one()

    rtiplist = store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id)

    rtip_summary_list = []

    for rtip in rtiplist:
        rfiles_n = store.find(
            ReceiverFile, (ReceiverFile.internaltip_id == rtip.internaltip.id, ReceiverFile.receiver_id == receiver_id)
        ).count()

        message_counter = store.find(Message, Message.receivertip_id == rtip.id).count()
        single_tip_sum = dict(
            {
                "id": rtip.id,
                "creation_date": datetime_to_ISO8601(rtip.internaltip.creation_date),
                "last_access": datetime_to_ISO8601(rtip.last_access),
                "expiration_date": datetime_to_ISO8601(rtip.internaltip.expiration_date),
                "access_counter": rtip.access_counter,
                "file_counter": rfiles_n,
                "comment_counter": rtip.internaltip.comments.count(),
                "message_counter": message_counter,
                "tor2web": rtip.internaltip.tor2web,
                "questionnaire_hash": rtip.internaltip.questionnaire_hash,
                "preview_schema": db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash, language),
                "preview": rtip.internaltip.preview,
            }
        )

        mo = Rosetta(rtip.internaltip.context.localized_strings)
        mo.acquire_storm_object(rtip.internaltip.context)
        single_tip_sum["context_name"] = mo.dump_localized_key("name", language)

        rtip_summary_list.append(single_tip_sum)

    return rtip_summary_list
예제 #6
0
def get_receivertip_list(store, receiver_id, language):
    rtip_summary_list = []

    user = store.find(Custodian, Custodian.id == receiver_id).one()

    if not user:
        for rtip in store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id):
            mo = Rosetta(rtip.internaltip.context.localized_keys)
            mo.acquire_storm_object(rtip.internaltip.context)

            rtip_summary_list.append({
                'id': rtip.id,
                'creation_date': datetime_to_ISO8601(rtip.internaltip.creation_date),
                'last_access': datetime_to_ISO8601(rtip.last_access),
                'update_date': datetime_to_ISO8601(rtip.internaltip.update_date),
                'expiration_date': datetime_to_ISO8601(rtip.internaltip.expiration_date),
                'progressive': rtip.internaltip.progressive,
                'context_name': mo.dump_localized_key('name', language),
                'access_counter': rtip.access_counter,
                'file_counter': rtip.internaltip.internalfiles.count(),
                'comment_counter': rtip.internaltip.comments.count(),
                'message_counter': rtip.messages.count(),
                'tor2web': rtip.internaltip.tor2web,
                'questionnaire_hash': rtip.internaltip.questionnaire_hash,
                'preview_schema': db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash,
                                                                 language),
                'preview': rtip.internaltip.preview,
                'total_score': rtip.internaltip.total_score,
                'label': rtip.label,
                'status': rtip.internaltip.status.description,
                'identity_provided': rtip.internaltip.identity_provided
            })
    else:
        for rtip in store.find(ReceiverTip):
            mo = Rosetta(rtip.internaltip.context.localized_keys)
            mo.acquire_storm_object(rtip.internaltip.context)
            iar = store.find(IdentityAccessRequest, IdentityAccessRequest.receivertip_id == rtip.id).one()
            if iar.reply == 'pending':
                rtip_summary_list.append({
                    'id': rtip.id,
                    'creation_date': datetime_to_ISO8601(rtip.internaltip.creation_date),
                    'last_access': datetime_to_ISO8601(rtip.last_access),
                    'update_date': datetime_to_ISO8601(rtip.internaltip.update_date),
                    'expiration_date': datetime_to_ISO8601(rtip.internaltip.expiration_date),
                    'progressive': rtip.internaltip.progressive,
                    'context_name': mo.dump_localized_key('name', language),
                    'access_counter': rtip.access_counter,
                    'file_counter': rtip.internaltip.internalfiles.count(),
                    'comment_counter': rtip.internaltip.comments.count(),
                    'message_counter': rtip.messages.count(),
                    'tor2web': rtip.internaltip.tor2web,
                    'questionnaire_hash': rtip.internaltip.questionnaire_hash,
                    'preview_schema': db_get_archived_preview_schema(store, rtip.internaltip.questionnaire_hash,
                                                                     language),
                    'preview': rtip.internaltip.preview,
                    'total_score': rtip.internaltip.total_score,
                    'label': rtip.label,
                    'status': rtip.internaltip.status.description,
                    'identity_provided': rtip.internaltip.identity_provided
                })

    return rtip_summary_list