def serialize_rtip(session, rtip, itip, language): """ Transaction returning a serialized descriptor of a tip :param session: An ORM session :param rtip: A model to be serialized :param itip: A itip object referenced by the model to be serialized :param language: A language of the serialization :return: A serialized description of the model specified """ user_id = rtip.receiver_id ret = serialize_usertip(session, rtip, itip, language) if 'whistleblower_identity' in ret[ 'data'] and not rtip.can_access_whistleblower_identity: del ret['data']['whistleblower_identity'] ret['id'] = rtip.id ret['receiver_id'] = user_id if State.tenant_cache[itip.tid].enable_private_labels: ret['label'] = rtip.label else: ret['label'] = itip.label ret['comments'] = db_get_itip_comment_list(session, itip.id) ret['messages'] = db_get_itip_message_list(session, rtip.id) ret['rfiles'] = db_receiver_get_rfile_list(session, rtip.id) ret['wbfiles'] = db_receiver_get_wbfile_list(session, itip.id) ret['iars'] = db_get_rtip_identityaccessrequest_list(session, rtip.id) ret['enable_notifications'] = bool(rtip.enable_notifications) return ret
def get_rtips(self, store): rtips_desc = [] rtips = store.find(models.ReceiverTip) for r in rtips: itip = serialize_usertip(store, r, 'en') rtips_desc.append({'rtip_id': r.id, 'receiver_id': r.receiver_id, 'itip': itip}) return rtips_desc
def get_wbtips(self, store): wbtips_desc = [] wbtips = store.find(models.WhistleblowerTip) for wbtip in wbtips: rcvrs_ids = [rcvr.id for rcvr in wbtip.internaltip.receivers] itip = serialize_usertip(store, wbtip, 'en') wbtips_desc.append({'wbtip_id': wbtip.id, 'wbtip_receivers': rcvrs_ids, 'itip': itip}) return wbtips_desc
def serialize_wbtip(session, wbtip, itip, language): ret = serialize_usertip(session, itip, itip, language) ret['comments'] = db_get_itip_comment_list(session, itip.id) ret['messages'] = db_get_itip_message_list(session, itip.id) ret['rfiles'] = db_get_rfile_list(session, itip.id) ret['wbfiles'] = db_get_wbfile_list(session, itip.id) return ret
def get_rtip_info(store, rtip_id, language): """ This function return a receiver tip """ rtip = store.find(ReceiverTip, ReceiverTip.id == rtip_id).one() if not rtip: raise errors.TipIdNotFound rtip_dict = serialize_usertip(store, rtip, language) return rtip_dict
def serialize_rtip(store, rtip, language): user_id = rtip.receiver.user.id ret = serialize_usertip(store, rtip, language) ret['id'] = rtip.id ret['receiver_id'] = user_id ret['label'] = rtip.label ret['export'] = '/rtip/' + rtip.id + '/export' ret['files'] = db_get_files_receiver(store, user_id, rtip.id) return ret
def serialize_rtip(store, rtip, language): user_id = rtip.receiver.user.id ret = serialize_usertip(store, rtip, language) ret["id"] = rtip.id ret["receiver_id"] = user_id ret["label"] = rtip.label ret["collection"] = "/rtip/" + rtip.id + "/collection" ret["files"] = db_get_files_receiver(store, user_id, rtip.id) return ret
def serialize_wbtip(store, wbtip, language): ret = serialize_usertip(store, wbtip, language) # filter submission progressive # to prevent a fake whistleblower to assess every day how many # submissions are received by the platform. del ret["progressive"] ret["id"] = wbtip.id ret["files"] = db_get_file_list(store, wbtip.id) return ret
def serialize_rtip(store, rtip, language): user_id = rtip.receiver.user.id ret = serialize_usertip(store, rtip, language) ret['id'] = rtip.id ret['receiver_id'] = user_id ret['label'] = rtip.label ret['files'] = db_get_files_receiver(store, user_id, rtip.id) ret['enable_notifications'] = bool(rtip.enable_notifications) return ret
def serialize_wbtip(store, wbtip, language): ret = serialize_usertip(store, wbtip, language) # filter submission progressive # to prevent a fake whistleblower to assess every day how many # submissions are received by the platform. del ret['progressive'] ret['id'] = wbtip.id ret['comments'] = db_get_itip_comment_list(store, wbtip.internaltip) ret['files'] = db_get_file_list(store, wbtip.id) return ret
def serialize_wbtip(session, wbtip, itip, language): ret = serialize_usertip(session, itip, itip, language) ret['comments'] = db_get_itip_comment_list(session, itip.id) ret['messages'] = db_get_itip_message_list(session, itip.id) ret['rfiles'] = db_get_rfile_list(session, itip.id) ret['wbfiles'] = db_get_wbfile_list(session, itip.id) if not State.tenant_cache[itip.tid].do_not_expose_users_names: for x in ret['comments'] + ret['messages']: if x['author'] != 'Whistleblower': x['author'] = State.tenant_cache[itip.tid].name return ret
def serialize_rtip(store, rtip, language): user_id = rtip.receiver.id ret = serialize_usertip(store, rtip, language) ret['id'] = rtip.id ret['receiver_id'] = user_id ret['label'] = rtip.label ret['comments'] = db_get_itip_comment_list(store, rtip.internaltip) ret['messages'] = db_get_itip_message_list(rtip) ret['files'] = db_get_files_receiver(store, user_id, rtip.id) ret['iars'] = db_get_identityaccessrequest_list(store, rtip.id, language) ret['enable_notifications'] = bool(rtip.enable_notifications) return ret
def serialize_rtip(session, rtip, itip, language): user_id = rtip.receiver_id ret = serialize_usertip(session, rtip, itip, language) if(not rtip.can_access_whistleblower_identity and 'whistleblower_identity' in ret['data']): del ret['data']['whistleblower_identity'] ret['id'] = rtip.id ret['receiver_id'] = user_id ret['label'] = rtip.label ret['comments'] = db_get_itip_comment_list(session, itip.id) ret['messages'] = db_get_itip_message_list(session, rtip.id) ret['rfiles'] = db_receiver_get_rfile_list(session, rtip.id) ret['wbfiles'] = db_receiver_get_wbfile_list(session, itip.id) ret['iars'] = db_get_rtip_identityaccessrequest_list(session, rtip.id) ret['enable_notifications'] = bool(rtip.enable_notifications) return ret
def serialize_rtip(session, rtip, itip, language, is_sensitive_data_visible=False): user_id = rtip.receiver_id #ottengo record da tabella Receiver receiver = session.query(models.Receiver).filter(models.Receiver.id == user_id).one() ret = serialize_usertip(session, rtip, itip, language, is_sensitive_data_visible) ret['id'] = rtip.id ret['receiver_id'] = user_id ret['label'] = rtip.label ret['comments'] = db_get_itip_comment_list(session, itip.tid, itip) ret['messages'] = db_get_itip_message_list(session, itip.tid, rtip) ret['rfiles'] = db_receiver_get_rfile_list(session, itip.tid, rtip.id) ret['wbfiles'] = db_receiver_get_wbfile_list(session, itip.tid, itip.id) ret['iars'] = db_get_identityaccessrequest_list(session, itip.tid, rtip.id) ret['enable_notifications'] = bool(rtip.enable_notifications) if receiver.two_step_login_enabled: ret['control_mail_list'] = receiver.control_mail_1+";"+receiver.control_mail_2+";"+receiver.control_mail_3 else: ret['control_mail_list'] = None