本文整理汇总了Python中globaleaks.utils.structures.Rosetta.dump_localized_key方法的典型用法代码示例。如果您正苦于以下问题:Python Rosetta.dump_localized_key方法的具体用法?Python Rosetta.dump_localized_key怎么用?Python Rosetta.dump_localized_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.structures.Rosetta
的用法示例。
在下文中一共展示了Rosetta.dump_localized_key方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serialize_itip
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def serialize_itip(store, internaltip, language):
context = internaltip.context
mo = Rosetta(context.localized_keys)
mo.acquire_storm_object(context)
return {
'id': internaltip.id,
'creation_date': datetime_to_ISO8601(internaltip.creation_date),
'update_date': datetime_to_ISO8601(internaltip.update_date),
'expiration_date': datetime_to_ISO8601(internaltip.expiration_date),
'progressive': internaltip.progressive,
'sequence_number': get_submission_sequence_number(internaltip),
'context_id': internaltip.context_id,
'context_name': mo.dump_localized_key('name', language),
'questionnaire': db_get_archived_questionnaire_schema(store, internaltip.questionnaire_hash, language),
'tor2web': internaltip.tor2web,
'timetolive': context.tip_timetolive,
'enable_comments': context.enable_comments,
'enable_messages': context.enable_messages,
'enable_two_way_comments': internaltip.enable_two_way_comments,
'enable_two_way_messages': internaltip.enable_two_way_messages,
'enable_attachments': internaltip.enable_attachments,
'enable_whistleblower_identity': internaltip.enable_whistleblower_identity,
'identity_provided': internaltip.identity_provided,
'identity_provided_date': datetime_to_ISO8601(internaltip.identity_provided_date),
'show_recipients_details': context.show_recipients_details,
'status_page_message': mo.dump_localized_key('status_page_message', language),
'assigned_date': datetime_to_ISO8601(internaltip.assigned_date),
'working_date': datetime_to_ISO8601(internaltip.working_date)
}
示例2: get_receivertip_list
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
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
示例3: get_receivertip_list
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
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
示例4: get_receiver_list_wb
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def get_receiver_list_wb(store, wb_tip_id, language):
"""
@return:
This function contain the serialization of the receiver, this function is
used only by /wbtip/receivers API
The returned struct contain information on read/unread messages
"""
receiver_list = []
wb_tip = store.find(WhistleblowerTip,
WhistleblowerTip.id == unicode(wb_tip_id)).one()
if not wb_tip:
raise errors.TipReceiptNotFound
for rtip in wb_tip.internaltip.receivertips:
message_counter = store.find(Message,
Message.receivertip_id == rtip.id).count()
receiver_desc = {
"name": rtip.receiver.name,
"id": rtip.receiver.id,
"pgp_key_status": rtip.receiver.pgp_key_status,
"access_counter": rtip.access_counter,
"message_counter": message_counter,
"creation_date": datetime_to_ISO8601(datetime_now()),
}
mo = Rosetta(rtip.receiver.localized_strings)
mo.acquire_storm_object(rtip.receiver)
receiver_desc["description"] = mo.dump_localized_key("description", language)
receiver_list.append(receiver_desc)
return receiver_list
示例5: serialize_itip
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def serialize_itip(store, internaltip, language):
context = internaltip.context
mo = Rosetta(context.localized_keys)
mo.acquire_storm_object(context)
return {
"id": internaltip.id,
"creation_date": datetime_to_ISO8601(internaltip.creation_date),
"update_date": datetime_to_ISO8601(internaltip.update_date),
"expiration_date": datetime_to_ISO8601(internaltip.expiration_date),
"progressive": internaltip.progressive,
"context_id": internaltip.context_id,
"context_name": mo.dump_localized_key("name", language),
"questionnaire": db_get_archived_questionnaire_schema(store, internaltip.questionnaire_hash, language),
"tor2web": internaltip.tor2web,
"timetolive": context.tip_timetolive,
"enable_comments": context.enable_comments,
"enable_messages": context.enable_messages,
"enable_two_way_comments": internaltip.enable_two_way_comments,
"enable_two_way_messages": internaltip.enable_two_way_messages,
"enable_attachments": internaltip.enable_attachments,
"enable_whistleblower_identity": internaltip.enable_whistleblower_identity,
"identity_provided": internaltip.identity_provided,
"identity_provided_date": datetime_to_ISO8601(internaltip.identity_provided_date),
"show_receivers": context.show_receivers,
}
示例6: collect_tip_overview
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def collect_tip_overview(store, language):
tip_description_list = []
all_itips = store.find(models.InternalTip)
for itip in all_itips:
tip_description = {
'id': itip.id,
'creation_date': datetime_to_ISO8601(itip.creation_date),
'creation_lifetime': datetime_to_ISO8601(itip.creation_date),
'expiration_date': datetime_to_ISO8601(itip.expiration_date),
'context_id': itip.context_id,
'receivertips': [],
'internalfiles': [],
'comments': [],
'wb_access_counter': 0,
'wb_last_access': u'Never'
}
mo = Rosetta(itip.context.localized_strings)
mo.acquire_storm_object(itip.context)
tip_description['context_name'] = mo.dump_localized_key('name', language)
for rtip in itip.receivertips:
tip_description['receivertips'].append({
'access_counter': rtip.access_counter,
'notification_date': datetime_to_ISO8601(rtip.notification_date),
'receiver_id': rtip.receiver.id,
'receiver_username': rtip.receiver.user.username,
'receiver_name': rtip.receiver.name,
# last_access censored willingly
})
for ifile in itip.internalfiles:
tip_description['internalfiles'].append({
'name': ifile.name,
'size': ifile.size,
'content_type': ifile.content_type
})
for comment in itip.comments:
tip_description['comments'].append({
'type': comment.type,
'lifetime': datetime_to_ISO8601(comment.creation_date),
})
# whistleblower tip has not a reference from itip, then:
wbtip = store.find(models.WhistleblowerTip,
models.WhistleblowerTip.internaltip_id == itip.id).one()
if wbtip is not None:
tip_description.update({
'wb_access_counter': wbtip.access_counter,
'wb_last_access': datetime_to_ISO8601(wbtip.last_access)
})
tip_description_list.append(tip_description)
return tip_description_list
示例7: collect_tip_overview
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def collect_tip_overview(store, language):
tip_description_list = []
all_itips = store.find(models.InternalTip)
for itip in all_itips:
tip_description = {
'id': itip.id,
'creation_date': datetime_to_ISO8601(itip.creation_date),
'expiration_date': datetime_to_ISO8601(itip.expiration_date),
'context_id': itip.context_id
}
mo = Rosetta(itip.context.localized_keys)
mo.acquire_storm_object(itip.context)
tip_description['context_name'] = mo.dump_localized_key('name', language)
tip_description_list.append(tip_description)
return tip_description_list
示例8: serialize_ahmia
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def serialize_ahmia(store, language):
"""
Serialize Ahmia.fi descriptor.
"""
node = store.find(models.Node).one()
mo = Rosetta(node.localized_keys)
mo.acquire_storm_object(node)
ret_dict = {
'title': node.name,
'description': mo.dump_localized_key('description', language),
'keywords': '%s (GlobaLeaks instance)' % node.name,
'relation': node.public_site,
'language': node.default_language,
'contactInformation': u'',
'type': 'GlobaLeaks'
}
return ret_dict
示例9: serialize_identityaccessrequest
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def serialize_identityaccessrequest(identityaccessrequest, language):
iar = {
'id': identityaccessrequest.id,
'receivertip_id': identityaccessrequest.receivertip_id,
'request_date': datetime_to_ISO8601(identityaccessrequest.request_date),
'request_user_name': identityaccessrequest.receivertip.receiver.user.name,
'request_motivation': identityaccessrequest.request_motivation,
'reply_date': datetime_to_ISO8601(identityaccessrequest.reply_date),
'reply_user_name': identityaccessrequest.reply_user.name \
if identityaccessrequest.reply_user is not None else '',
'reply': identityaccessrequest.reply,
'reply_motivation': identityaccessrequest.reply_motivation,
'submission_date': datetime_to_ISO8601(identityaccessrequest.receivertip.internaltip.creation_date)
}
mo = Rosetta(identityaccessrequest.receivertip.internaltip.context.localized_keys)
mo.acquire_storm_object(identityaccessrequest.receivertip.internaltip.context)
iar["submission_context"] = mo.dump_localized_key('name', language)
return iar
示例10: serialize_ahmia
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def serialize_ahmia(store, language):
"""
Serialize Ahmia.fi descriptor.
"""
node = store.find(models.Node).one()
mo = Rosetta(node.localized_keys)
mo.acquire_storm_object(node)
ret_dict = {
"title": node.name,
"description": mo.dump_localized_key("description", language),
"keywords": "%s (GlobaLeaks instance)" % node.name,
"relation": node.public_site,
"language": node.default_language,
"contactInformation": u"",
"type": "GlobaLeaks",
}
return ret_dict
示例11: get_receiver_list_receiver
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
def get_receiver_list_receiver(store, user_id, tip_id, language):
rtip = db_access_tip(store, user_id, tip_id)
receiver_list = []
for rtip in rtip.internaltip.receivertips:
receiver_desc = {
"pgp_key_status": rtip.receiver.pgp_key_status,
"can_delete_submission": rtip.receiver.can_delete_submission,
"name": unicode(rtip.receiver.name),
"receiver_id": unicode(rtip.receiver.id),
"access_counter": rtip.access_counter,
}
mo = Rosetta(rtip.receiver.localized_strings)
mo.acquire_storm_object(rtip.receiver)
receiver_desc["description"] = mo.dump_localized_key("description", language)
receiver_list.append(receiver_desc)
return receiver_list
示例12: wb_serialize_tip
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
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
示例13: get_receivertip_list
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import dump_localized_key [as 别名]
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