예제 #1
0
def create_submission(store, request, finalize, language=GLSetting.memory_copy.default_language):

    context = store.find(Context, Context.id == unicode(request['context_gus'])).one()
    if not context:
        log.err("Context requested: [%s] not found!" % request['context_gus'])
        raise errors.ContextGusNotFound

    submission = InternalTip()

    submission.escalation_threshold = context.escalation_threshold
    submission.access_limit = context.tip_max_access
    submission.download_limit = context.file_max_download
    submission.expiration_date = utc_future_date(seconds=context.tip_timetolive)
    submission.pertinence_counter = 0
    submission.context_id = context.id
    submission.creation_date = datetime_now()

    if finalize:
        submission.mark = InternalTip._marker[1] # Finalized
    else:
        submission.mark = InternalTip._marker[0] # Submission

    try:
        store.add(submission)
    except Exception as excep:
        log.err("Storm/SQL Error: %s (create_submission)" % excep)
        raise errors.InternalServerError("Unable to commit on DB")

    files = request.get('files', [])
    try:
        import_files(store, submission, files, finalize)
    except Exception as excep:
        log.err("Submission create: files import fail: %s" % excep)
        store.remove(submission)
        store.commit()
        raise excep

    wb_fields = request.get('wb_fields', {})
    try:
        fo = Fields(context.localized_fields, context.unique_fields)
        fo.validate_fields(wb_fields, strict_validation=finalize)
        submission.wb_fields = wb_fields
    except Exception as excep:
        log.err("Submission create: fields validation fail: %s" % excep)
        store.remove(submission)
        store.commit()
        raise excep

    receivers = request.get('receivers', [])
    try:
        import_receivers(store, submission, receivers, required=finalize)
    except Exception as excep:
        log.err("Submission reate: receivers import fail: %s" % excep)
        store.remove(submission)
        store.commit()
        raise excep

    submission_dict = wb_serialize_internaltip(submission)
    return submission_dict
예제 #2
0
def update_submission(store, submission_id, request, finalize, language=GLSetting.memory_copy.default_language):

    context = store.find(Context, Context.id == unicode(request['context_id'])).one()
    if not context:
        log.err("Context requested: [%s] not found!" % request['context_id'])
        raise errors.ContextIdNotFound

    submission = store.find(InternalTip, InternalTip.id == unicode(submission_id)).one()
    if not submission:
        log.err("Invalid Submission requested %s in PUT" % submission_id)
        raise errors.SubmissionIdNotFound

    # this may happen if a submission try to update a context
    if submission.context_id != context.id:
        log.err("Can't be changed context in a submission update")
        raise errors.ContextIdNotFound("Context are immutable")

    if submission.mark != InternalTip._marker[0]:
        log.err("Submission %s do not permit update (status %s)" % (submission_id, submission.mark))
        raise errors.SubmissionConcluded

    try:
        import_files(store, submission, request['files'], finalize)
    except Exception as excep:
        log.err("Submission update: files import fail: %s" % excep)
        log.exception(excep)
        raise excep

    try:
        wb_fields = request['wb_fields']
        fo = Fields(context.localized_fields, context.unique_fields)
        fo.validate_fields(wb_fields, language, strict_validation=finalize)
        submission.wb_fields = wb_fields
    except Exception as excep:
        log.err("Submission update: fields validation fail: %s" % excep)
        log.exception(excep)
        raise excep

    try:
        import_receivers(store, submission, request['receivers'], required=finalize)
    except Exception as excep:
        log.err("Submission update: receiver import fail: %s" % excep)
        log.exception(excep)
        raise excep

    if finalize:
        submission.mark = InternalTip._marker[1] # Finalized

    submission_dict = wb_serialize_internaltip(submission)
    return submission_dict
예제 #3
0
def update_submission(store, submission_id, request, finalize, language=GLSetting.memory_copy.default_language):

    context = store.find(Context, Context.id == unicode(request["context_id"])).one()
    if not context:
        log.err("Context requested: [%s] not found!" % request["context_id"])
        raise errors.ContextIdNotFound

    submission = store.find(InternalTip, InternalTip.id == unicode(submission_id)).one()
    if not submission:
        log.err("Invalid Submission requested %s in PUT" % submission_id)
        raise errors.SubmissionIdNotFound

    # this may happen if a submission try to update a context
    if submission.context_id != context.id:
        log.err("Can't be changed context in a submission update")
        raise errors.ContextIdNotFound("Context are immutable")

    if submission.mark != InternalTip._marker[0]:
        log.err("Submission %s do not permit update (status %s)" % (submission_id, submission.mark))
        raise errors.SubmissionConcluded

    try:
        import_files(store, submission, request["files"], finalize)
    except Exception as excep:
        log.err("Submission update: files import fail: %s" % excep)
        log.exception(excep)
        raise excep

    try:
        wb_fields = request["wb_fields"]
        fo = Fields(context.localized_fields, context.unique_fields)
        fo.validate_fields(wb_fields, language, strict_validation=finalize)
        submission.wb_fields = wb_fields
    except Exception as excep:
        log.err("Submission update: fields validation fail: %s" % excep)
        log.exception(excep)
        raise excep

    try:
        import_receivers(store, submission, request["receivers"], required=finalize)
    except Exception as excep:
        log.err("Submission update: receiver import fail: %s" % excep)
        log.exception(excep)
        raise excep

    if finalize:
        submission.mark = InternalTip._marker[1]  # Finalized

    submission_dict = wb_serialize_internaltip(submission)
    return submission_dict
예제 #4
0
def create_submission(store, request, finalize, language=GLSetting.memory_copy.default_language):
    context = store.find(Context, Context.id == unicode(request['context_id'])).one()
    if not context:
        log.err("Context requested: [%s] not found!" % request['context_id'])
        raise errors.ContextIdNotFound

    submission = InternalTip()

    submission.escalation_threshold = context.escalation_threshold
    submission.access_limit = context.tip_max_access
    submission.download_limit = context.file_max_download
    submission.expiration_date = utc_future_date(seconds=context.tip_timetolive)
    submission.pertinence_counter = 0
    submission.context_id = context.id
    submission.creation_date = datetime_now()

    if finalize:
        submission.mark = InternalTip._marker[1] # Finalized
    else:
        submission.mark = InternalTip._marker[0] # Submission

    try:
        store.add(submission)
    except Exception as excep:
        log.err("Storm/SQL Error: %s (create_submission)" % excep)
        raise errors.InternalServerError("Unable to commit on DB")

    try:
        import_files(store, submission, request['files'], finalize)
    except Exception as excep:
        log.err("Submission create: files import fail: %s" % excep)
        raise excep

    try:
        wb_fields = request['wb_fields']
        fo = Fields(context.localized_fields, context.unique_fields)
        fo.validate_fields(wb_fields, language, strict_validation=finalize)
        submission.wb_fields = wb_fields
    except Exception as excep:
        log.err("Submission create: fields validation fail: %s" % excep)
        raise excep

    try:
        import_receivers(store, submission, request['receivers'], required=finalize)
    except Exception as excep:
        log.err("Submission create: receivers import fail: %s" % excep)
        raise excep

    submission_dict = wb_serialize_internaltip(submission)
    return submission_dict
예제 #5
0
    def create_context_with_receivers(self, store):
        c = self.localization_set(self.dummyContext, Context, 'en')
        r = self.localization_set(self.dummyReceiver, Receiver, 'en')

        receiver_user1 = User(self.dummyReceiverUser)
        receiver_user1.last_login = self.dummyReceiverUser['last_login']

        receiver_user2 = User(self.dummyReceiverUser)
        receiver_user2.last_login = self.dummyReceiverUser['last_login']

        # Avoid receivers with the same username!
        receiver_user1.username = unicode("xxx")
        receiver_user2.username = unicode("yyy")

        store.add(receiver_user1)
        store.add(receiver_user2)

        context = Context(c)

        fo = Fields()
        fo.update_fields('en', self.dummyContext['fields'])
        fo.context_import(context)

        context.tags = self.dummyContext['tags']
        context.submission_timetolive = context.tip_timetolive = 1000
        context.description = context.name =\
            context.submission_disclaimer = context.submission_introduction =\
            context.receipt_description = { "en" : u'Localized76w' }
        context.receipt_regexp = u"unipop09876"

        receiver1 = Receiver(r)
        receiver2 = Receiver(r)

        receiver1.user = receiver_user1
        receiver2.user = receiver_user2
        receiver1.gpg_key_status = receiver2.gpg_key_status = Receiver._gpg_types[0]
        receiver1.notification_fields = receiver2.notification_fields = {'mail_address': '*****@*****.**'}

        context.receivers.add(receiver1)
        context.receivers.add(receiver2)

        store.add(context)

        return context.id
예제 #6
0
def do_appdata_init(store):

    try:
        appdata = store.find(models.ApplicationData).one()

        if not appdata:
            raise Exception

    except Exception as xxx:
        appdata = models.ApplicationData()
        source = opportunistic_appdata_init()
        appdata.version = source['version']
        appdata.fields = source['fields']
        store.add(appdata)

    fo = Fields()
    fo.noisy = True
    fo.default_fields(appdata.fields)
    (unique_fields, localized_fields) = fo.extensive_dump()

    return unique_fields, localized_fields
예제 #7
0
def anon_serialize_context(context,
                           language=GLSetting.memory_copy.default_language):
    """
    @param context: a valid Storm object
    @return: a dict describing the contexts available for submission,
        (e.g. checks if almost one receiver is associated)
    """

    mo = Rosetta()
    mo.acquire_storm_object(context)
    fo = Fields(context.localized_fields, context.unique_fields)

    context_dict = {
        "id": context.id,
        "escalation_threshold": 0,
        "file_max_download": context.file_max_download,
        "file_required": context.file_required,
        "selectable_receiver": context.selectable_receiver,
        "tip_max_access": context.tip_max_access,
        "tip_timetolive": context.tip_timetolive,
        "submission_introduction":
        u'NYI',  # unicode(context.submission_introduction), # optlang
        "submission_disclaimer":
        u'NYI',  # unicode(context.submission_disclaimer), # optlang
        "select_all_receivers": context.select_all_receivers,
        "maximum_selectable_receivers": context.maximum_selectable_receivers,
        'require_pgp': context.require_pgp,
        "show_small_cards": context.show_small_cards,
        "presentation_order": context.presentation_order,
        # list is needed because .values returns a generator
        "receivers": list(context.receivers.values(models.Receiver.id)),
        'name': mo.dump_translated('name', language),
        "description": mo.dump_translated('description', language),
        "fields": fo.dump_fields(language)
    }

    if not len(context_dict['receivers']):
        return None

    return context_dict
예제 #8
0
def get_receiver_tip_list(store, user_id):

    receiver = store.find(Receiver, Receiver.id == unicode(user_id)).one()
    rtiplist = store.find(ReceiverTip, ReceiverTip.receiver_id == receiver.id)
    rtiplist.order_by(Desc(ReceiverTip.creation_date))

    rtip_summary_list = []

    for rtip in rtiplist:

        rfiles_n = store.find(ReceiverFile,
            (ReceiverFile.internaltip_id == rtip.internaltip.id,
             ReceiverFile.receiver_id == user_id)).count()

        single_tip_sum = dict({
            # expiry time ?
            # context_id ?
            'access_counter': rtip.access_counter,
            'expressed_pertinence': rtip.expressed_pertinence,
            'creation_date' : unicode(pretty_date_time(rtip.creation_date)),
            'last_access' : unicode(pretty_date_time(rtip.last_access)),
            'id' : rtip.id,
            'files_number': rfiles_n,
        })

        preview_data = []

        fo = Fields(rtip.internaltip.context.localized_fields, rtip.internaltip.context.unique_fields)
        for preview_key in fo.get_preview_keys():

            # preview in a format angular.js likes
            entry = dict({'key' : preview_key,
                          'text': rtip.internaltip.wb_fields[preview_key] })
            preview_data.append(entry)

        single_tip_sum.update({ 'preview' : preview_data })
        rtip_summary_list.append(single_tip_sum)

    return rtip_summary_list
예제 #9
0
def anon_serialize_context(context, language=GLSetting.memory_copy.default_language):
    """
    @param context: a valid Storm object
    @return: a dict describing the contexts available for submission,
        (e.g. checks if almost one receiver is associated)
    """
    context_dict = {
        "receivers": []
    }

    for receiver in context.receivers:
        context_dict['receivers'].append(unicode(receiver.id))

    if not len(context_dict['receivers']):
        return None

    context_dict.update({
        "context_gus": unicode(context.id),
        "escalation_threshold": None,
        "file_max_download": int(context.file_max_download),
        "file_required": context.file_required,
        "selectable_receiver": bool(context.selectable_receiver),
        "tip_max_access": int(context.tip_max_access),
        "tip_timetolive": int(context.tip_timetolive),
        "receipt_description": u'NYI', # unicode(context.receipt_description), # optlang
        "submission_introduction": u'NYI', # unicode(context.submission_introduction), # optlang
        "submission_disclaimer": u'NYI', # unicode(context.submission_disclaimer), # optlang
        "select_all_receivers": context.select_all_receivers
    })

    mo = Rosetta()
    mo.acquire_storm_object(context)
    context_dict['name'] = mo.dump_translated('name', language)
    context_dict['description'] = mo.dump_translated('description', language)

    fo = Fields(context.localized_fields, context.unique_fields)
    context_dict['fields'] = fo.dump_fields(language)

    return context_dict
예제 #10
0
def anon_serialize_context(context, language=GLSetting.memory_copy.default_language):
    """
    @param context: a valid Storm object
    @return: a dict describing the contexts available for submission,
        (e.g. checks if almost one receiver is associated)
    """

    mo = Rosetta()
    mo.acquire_storm_object(context)
    fo = Fields(context.localized_fields, context.unique_fields)

    context_dict = {
        "id": context.id,
        "escalation_threshold": 0,
        "file_max_download": context.file_max_download,
        "file_required": context.file_required,
        "selectable_receiver": context.selectable_receiver,
        "tip_max_access": context.tip_max_access,
        "tip_timetolive": context.tip_timetolive,
        "submission_introduction": u'NYI', # unicode(context.submission_introduction), # optlang
        "submission_disclaimer": u'NYI', # unicode(context.submission_disclaimer), # optlang
        "select_all_receivers": context.select_all_receivers,
        "maximum_selectable_receivers": context.maximum_selectable_receivers,
        'require_pgp': context.require_pgp,
        "show_small_cards": context.show_small_cards,
        "show_receivers": context.show_receivers,
        "enable_private_messages": context.enable_private_messages,
        "presentation_order": context.presentation_order,
                     # list is needed because .values returns a generator
        "receivers": list(context.receivers.values(models.Receiver.id)),
        'name': mo.dump_translated('name', language),
        "description": mo.dump_translated('description', language),
        "fields": fo.dump_fields(language)
    }

    if not len(context_dict['receivers']):
        return None

    return context_dict
예제 #11
0
def default_context_fields():

    source = opportunistic_appdata_init()
    if not source.has_key('fields'):
        raise Exception("Invalid Application Data initialization")

    f = source['fields']
    fo = Fields()
    fo.noisy = True
    fo.default_fields(f)
    default_fields_unhappy = fo.dump_fields('en')

    ret_fields = []
    the_first_is_required = False

    for field in default_fields_unhappy:

        if not the_first_is_required:
            field['required'] = True
            the_first_is_required = True

        ret_fields.append(field)

    return ret_fields
예제 #12
0
    def create_receiver_with_contexts(self, store):
        c = self.localization_set(self.dummyContext, Context, 'en')
        r = self.localization_set(self.dummyReceiver, Receiver, 'en')

        receiver_user = User(self.dummyReceiverUser)
        receiver_user.last_login = self.dummyReceiverUser['last_login']

        # Avoid receivers with the same username!
        receiver_user.username = unicode("xxx")

        store.add(receiver_user)

        receiver = Receiver(r)
        receiver.user = receiver_user
        receiver.gpg_key_status = Receiver._gpg_types[0]
        receiver.notification_fields = {'mail_address': '*****@*****.**'}

        context1 = Context(c)

        fo = Fields()
        fo.update_fields('en', self.dummyContext['fields'])
        fo.context_import(context1)

        context1.tags = self.dummyContext['tags']
        context1.submission_timetolive = context1.tip_timetolive = 1000
        context1.description = context1.name =\
            context1.submission_disclaimer = context1.submission_introduction =\
            context1.receipt_description = { "en" : u'Valar Morghulis' }
        context1.receipt_regexp = u"unipop254"

        context2 = Context(c)

        fo.context_import(context2)

        context2.tags = self.dummyContext['tags']
        context2.submission_timetolive = context2.tip_timetolive = 1000
        context2.description = context2.name =\
            context2.submission_disclaimer = context2.submission_introduction =\
            context2.receipt_description = { "en" : u'Valar Dohaeris' }
        context2.receipt_regexp = u"unipop43423"

        receiver.contexts.add(context1)
        receiver.contexts.add(context2)
        store.add(receiver)
        return receiver.id
예제 #13
0
    def _transact_ro_add_context(self, store):
        c = self.localization_set(self.dummyContext, Context, 'en')
        context = Context(c)

        fo = Fields()
        fo.update_fields('en', self.dummyContext['fields'])
        fo.context_import(context)

        context.tags = self.dummyContext['tags']
        context.submission_timetolive = context.tip_timetolive = 1000
        context.description = context.name = \
            context.submission_disclaimer = \
            context.submission_introduction = { "en" : u'Localized723' }
        store.add(context)
        return context.id
예제 #14
0
def do_appdata_init(store):

    try:
        appdata = store.find(models.ApplicationData).one()

        if not appdata:
            raise Exception

    except Exception as xxx:
        appdata = models.ApplicationData()
        source = opportunistic_appdata_init()
        appdata.version = source['version']
        appdata.fields = source['fields']
        store.add(appdata)

    fo = Fields()
    fo.noisy = True
    fo.default_fields(appdata.fields)
    (unique_fields, localized_fields) = fo.extensive_dump()

    return unique_fields, localized_fields
예제 #15
0
def default_context_fields():

    source = opportunistic_appdata_init()
    if not source.has_key('fields'):
        raise Exception("Invalid Application Data initialization")

    f = source['fields']
    fo = Fields()
    fo.noisy = True
    fo.default_fields(f)
    default_fields_unhappy = fo.dump_fields('en')

    ret_fields = []
    the_first_is_required = False

    for field in default_fields_unhappy:

        if not the_first_is_required:
            field['required'] = True
            the_first_is_required = True

        ret_fields.append(field)

    return ret_fields
예제 #16
0
def get_receiver_tip_list(store, receiver_id, language=GLSetting.memory_copy.default_language):

    rtiplist = store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id)
    rtiplist.order_by(Desc(ReceiverTip.creation_date))

    node = store.find(Node).one()

    rtip_summary_list = []

    for rtip in rtiplist:

        postpone_superpower = (node.postpone_superpower or
                               rtip.internaltip.context.postpone_superpower or
                               rtip.receiver.postpone_superpower)

        can_delete_submission = (node.can_delete_submission or
                                 rtip.internaltip.context.can_delete_submission or
                                 rtip.receiver.can_delete_submission)

        rfiles_n = store.find(ReceiverFile,
            (ReceiverFile.internaltip_id == rtip.internaltip.id,
             ReceiverFile.receiver_id == receiver_id)).count()

        your_messages = store.find(Message,
                                   Message.receivertip_id == rtip.id,
                                   Message.type == u'receiver').count()

        unread_messages = store.find(Message,
                                     Message.receivertip_id == rtip.id,
                                     Message.type == u'whistleblower',
                                     Message.visualized == False).count()

        read_messages = store.find(Message,
                                   Message.receivertip_id == rtip.id,
                                   Message.type == u'whistleblower',
                                   Message.visualized == True).count()

        single_tip_sum = dict({
            'id' : rtip.id,
            'expressed_pertinence': rtip.expressed_pertinence,
            'creation_date' : datetime_to_ISO8601(rtip.creation_date),
            'last_access' : datetime_to_ISO8601(rtip.last_access),
            'expiration_date' : datetime_to_ISO8601(rtip.internaltip.expiration_date),
            'access_counter': rtip.access_counter,
            'files_number': rfiles_n,
            'comments_number': rtip.internaltip.comments.count(),
            'unread_messages' : unread_messages,
            'read_messages' : read_messages,
            'your_messages' : your_messages,
            'postpone_superpower': postpone_superpower,
            'can_delete_submission': can_delete_submission,
        })

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

        preview_data = []

        fo = Fields(rtip.internaltip.context.localized_fields, rtip.internaltip.context.unique_fields)
        for preview_key, preview_label in fo.get_preview_keys(language).iteritems():

            # preview in a format angular.js likes
            try:
                entry = dict({'label' : preview_label,
                              'text': rtip.internaltip.wb_fields[preview_key] })

            except KeyError as xxx:
                log.err("Legacy error: suppressed 'preview_keys' %s" % xxx.message )
                continue

            preview_data.append(entry)

        single_tip_sum.update({ 'preview' : preview_data })
        rtip_summary_list.append(single_tip_sum)

    return rtip_summary_list
예제 #17
0
def update_submission(store, id, request, finalize, language=GLSetting.memory_copy.default_language):

    context = store.find(Context, Context.id == unicode(request['context_gus'])).one()
    if not context:
        log.err("Context requested: [%s] not found!" % request['context_gus'])
        raise errors.ContextGusNotFound

    submission = store.find(InternalTip, InternalTip.id == unicode(id)).one()

    if not submission:

        log.debug("Creating a new submission in update!")
        submission = InternalTip()

        submission.escalation_threshold = context.escalation_threshold
        submission.access_limit = context.tip_max_access
        submission.download_limit = context.file_max_download
        submission.expiration_date = utc_future_date(seconds=context.tip_timetolive)
        submission.pertinence_counter = 0
        submission.context_id = context.id
        submission.creation_date = datetime_now()
        submission.mark = InternalTip._marker[0] # Submission

        try:
            store.add(submission)
        except Exception as excep:
            log.err("Storm/SQL Error: %s (update_submission)" % excep)
            raise errors.InternalServerError("Unable to commit on DB")

    # this may happen if a submission try to update a context
    if submission.context_id != context.id:
        log.err("Can't be changed context in a submission update")
        raise errors.ContextGusNotFound("Context are immutable")

    if submission.mark != InternalTip._marker[0]:
        log.err("Submission %s do not permit update (status %s)" % (id, submission.mark))
        raise errors.SubmissionConcluded

    files = request.get('files', [])
    try:
        import_files(store, submission, files, finalize)
    except Exception as excep:
        log.err("Submission update: files import fail: %s" % excep)
        log.exception(excep)
        raise excep

    wb_fields = request.get('wb_fields', [])
    try:
        fo = Fields(context.localized_fields, context.unique_fields)
        fo.validate_fields(wb_fields, strict_validation=finalize)
        submission.wb_fields = wb_fields
    except Exception as excep:
        log.err("Submission update: fields validation fail: %s" % excep)
        log.exception(excep)
        raise excep

    receivers = request.get('receivers', [])
    try:
        import_receivers(store, submission, receivers, required=finalize)
    except Exception as excep:
        log.err("Submission update: receiver import fail: %s" % excep)
        log.exception(excep)
        raise excep

    if finalize:
        submission.mark = InternalTip._marker[1] # Finalized

    submission_dict = wb_serialize_internaltip(submission)
    return submission_dict
예제 #18
0
def get_receiver_tip_list(store,
                          receiver_id,
                          language=GLSetting.memory_copy.default_language):

    rtiplist = store.find(ReceiverTip, ReceiverTip.receiver_id == receiver_id)
    rtiplist.order_by(Desc(ReceiverTip.creation_date))

    node = store.find(Node).one()

    rtip_summary_list = []

    for rtip in rtiplist:

        postpone_superpower = (node.postpone_superpower
                               or rtip.internaltip.context.postpone_superpower
                               or rtip.receiver.postpone_superpower)

        can_delete_submission = (node.can_delete_submission or
                                 rtip.internaltip.context.can_delete_submission
                                 or rtip.receiver.can_delete_submission)

        rfiles_n = store.find(
            ReceiverFile, (ReceiverFile.internaltip_id == rtip.internaltip.id,
                           ReceiverFile.receiver_id == receiver_id)).count()

        your_messages = store.find(Message, Message.receivertip_id == rtip.id,
                                   Message.type == u'receiver').count()

        unread_messages = store.find(Message,
                                     Message.receivertip_id == rtip.id,
                                     Message.type == u'whistleblower',
                                     Message.visualized == False).count()

        read_messages = store.find(Message, Message.receivertip_id == rtip.id,
                                   Message.type == u'whistleblower',
                                   Message.visualized == True).count()

        single_tip_sum = dict({
            'id':
            rtip.id,
            'expressed_pertinence':
            rtip.expressed_pertinence,
            'creation_date':
            datetime_to_ISO8601(rtip.creation_date),
            'last_access':
            datetime_to_ISO8601(rtip.last_access),
            'expiration_date':
            datetime_to_ISO8601(rtip.internaltip.expiration_date),
            'access_counter':
            rtip.access_counter,
            'files_number':
            rfiles_n,
            'comments_number':
            rtip.internaltip.comments.count(),
            'unread_messages':
            unread_messages,
            'read_messages':
            read_messages,
            'your_messages':
            your_messages,
            'postpone_superpower':
            postpone_superpower,
            'can_delete_submission':
            can_delete_submission,
        })

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

        preview_data = []

        fo = Fields(rtip.internaltip.context.localized_fields,
                    rtip.internaltip.context.unique_fields)
        for preview_key, preview_label in fo.get_preview_keys(
                language).iteritems():

            # preview in a format angular.js likes
            try:
                entry = dict({
                    'label': preview_label,
                    'text': rtip.internaltip.wb_fields[preview_key]
                })

            except KeyError as xxx:
                log.err("Legacy error: suppressed 'preview_keys' %s" %
                        xxx.message)
                continue

            preview_data.append(entry)

        single_tip_sum.update({'preview': preview_data})
        rtip_summary_list.append(single_tip_sum)

    return rtip_summary_list