Skip to content
Snippets Groups Projects
Commit 6875fedb authored by Jan Mach's avatar Jan Mach
Browse files

Fix: Fixed the incorrect informant email section labels.

(Redmine issue: #5101)
parent 45f315ae
No related branches found
No related tags found
No related merge requests found
......@@ -512,9 +512,9 @@ mpybabel-update: FORCE
mpybabel-compile: FORCE
@echo "\n$(GREEN)*** Compiling translations for Mentat ***$(NC)\n"
@$(PYBABEL) compile -d $(DIR_TEMPLATES_INFORMANT)/translations
@$(PYBABEL) compile -d $(DIR_TEMPLATES_REPORTER)/translations
@$(PYBABEL) compile -d $(DIR_TEMPLATES_UTEST)/translations
@$(PYBABEL) compile -d $(DIR_TEMPLATES_INFORMANT)/translations --statistics
@$(PYBABEL) compile -d $(DIR_TEMPLATES_REPORTER)/translations --statistics
@$(PYBABEL) compile -d $(DIR_TEMPLATES_UTEST)/translations --statistics
#
# Compile all available translations.
......
{#-
This helper macro is responsible for rendering section label for each report
section.
-#}
{%- macro section_label_evt(key) -%}
{%-
set labels = {
'ips': _('Number of processed events per source IP'),
'categories': _('Number of processed events per category'),
'detectors': _('Number of processed events per detector'),
'analyzers': _('Number of processed events per analyzer'),
'abuses': _('Number of processed events per abuse group'),
'asns': _('Number of processed events per autonomous system'),
'countries': _('Number of processed events per source country')
}
-%}
{{ labels[key] }}
{%- endmacro -%}
{%- macro section_label_rep(key) -%}
{%-
set labels = {
'emails': _('Number of sent email reports'),
'ips': _('Number of reported events per source IP'),
'categories': _('Number of reported events per category'),
'detectors': _('Number of reported events per detector'),
'analyzers': _('Number of reported events per analyzer'),
'abuses': _('Number of reported events per abuse group'),
'asns': _('Number of reported events per autonomous system'),
'countries': _('Number of reported events per source country')
}
-%}
{{ labels[key] }}
{%- endmacro -%}
......@@ -6,6 +6,8 @@
Author: Jan Mach <jan.mach@cesnet.cz>
#}
{%- import '_labels.j2' as report_labels -%}
{%- macro render_stats_table(chstats, chsection) %}
{%- if chsection in chstats %}
{%- set chdata = chstats[chsection] %}
......@@ -98,7 +100,9 @@
<ol type="1">
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
<li>
<a href="#section-A-{{ loop.index }}">{{ _('Number of processed events per') }} <strong>{{ format_section_name(chsection) }}</strong></a>
<a href="#section-A-{{ loop.index }}">
{{ report_labels.section_label_evt(chsection) }}
</a>
</li>
{%- endfor %}
</ol>
......@@ -106,9 +110,11 @@
<li>
<a href="#section-B">{{ _('Event reporting statistics') }}</a>
<ol type="1">
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{%- for chsection in ('emails', ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
<li>
<a href="#section-A-{{ loop.index }}">{{ _('Number of reported events per') }} <strong>{{ format_section_name(chsection) }}</strong></a>
<a href="#section-A-{{ loop.index }}">
{{ report_labels.section_label_rep(chsection) }}
</a>
</li>
{%- endfor %}
</ol>
......@@ -121,7 +127,9 @@
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
<h3>
<a name="section-A-{{ loop.index }}">{{ 'A.{:d}'.format(loop.index) }} {{ _('Number of processed events per') }} <strong>{{ format_section_name(chsection) }}</strong></a>
<a name="section-A-{{ loop.index }}">
{{ 'A.{:d}'.format(loop.index) }} {{ report_labels.section_label_evt(chsection) }}
</a>
</h3>
{{
render_stats_table(
......@@ -137,7 +145,9 @@
{%- for chsection in ('emails', 'ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
<h3>
<a name="section-B-{{ loop.index }}">{{ 'B.{:d}'.format(loop.index) }} {{ _('Number of reported events per') }} <strong>{{ format_section_name(chsection) }}</strong></a>
<a name="section-B-{{ loop.index }}">
{{ 'B.{:d}'.format(loop.index) }} {{ report_labels.section_label_rep(chsection) }}
</a>
</h3>
{{
render_stats_table(
......
......@@ -6,6 +6,8 @@
Author: Jan Mach <jan.mach@cesnet.cz>
#}
{%- import '_labels.j2' as report_labels -%}
{%- macro render_stats_table(chstats, chsection) %}
{%- if chsection in chstats %}
{%- set chdata = chstats[chsection] %}
......@@ -37,11 +39,11 @@
{{ '{}'.format('=' * 90) }}
A. {{ _('Event processing statistics') }}
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{{ 'A.{:d}'.format(loop.index) }} {{ _('Number of processed events per') }} '{{ format_section_name(chsection) }}':
{{ 'A.{:d}'.format(loop.index) }} {{ report_labels.section_label_evt(chsection) }}:
{%- endfor %}
B. {{ _('Event reporting statistics') }}
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{{ 'B.{:d}'.format(loop.index) }} {{ _('Number of reported events per') }} '{{ format_section_name(chsection) }}':
{%- for chsection in ('emails', 'ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{{ 'B.{:d}'.format(loop.index) }} {{ report_labels.section_label_rep(chsection) }}:
{%- endfor %}
......@@ -49,7 +51,7 @@ A. {{ _('Event processing statistics') }}
{{ '{}'.format('=' * 90) }}
{%- for chsection in ('ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{{ '[A.{:d}]'.format(loop.index) }} {{ _('Number of processed events per') }} '{{ format_section_name(chsection) }}'
{{ '[A.{:d}]'.format(loop.index) }} {{ report_labels.section_label_evt(chsection) }}
{{
render_stats_table(
stats_events['stats_overall'],
......@@ -62,7 +64,7 @@ A. {{ _('Event reporting statistics') }}
{{ '{}'.format('=' * 90) }}
{%- for chsection in ('emails', 'ips', 'categories', 'detectors', 'analyzers', 'abuses', 'asns', 'countries') %}
{{ '[A.{:d}]'.format(loop.index) }} {{ _('Number of reported events per') }} '{{ format_section_name(chsection) }}'
{{ '[A.{:d}]'.format(loop.index) }} {{ report_labels.section_label_rep(chsection) }}
{{
render_stats_table(
stats_reports,
......
......@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-05-22 11:34+0200\n"
"POT-Creation-Date: 2019-05-23 11:43+0200\n"
"PO-Revision-Date: 2017-09-22 15:33+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: cs\n"
......@@ -14,6 +14,51 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.6.0\n"
msgid "Number of processed events per source IP"
msgstr "Počet zpracovaných událostí dle zdrojové IP"
msgid "Number of processed events per category"
msgstr "Počet zpracovaných událostí dle kategorie"
msgid "Number of processed events per detector"
msgstr "Počet zpracovaných událostí dle detektoru"
msgid "Number of processed events per analyzer"
msgstr "Počet zpracovaných událostí dle analyzátoru"
msgid "Number of processed events per abuse group"
msgstr "Počet zpracovaných událostí dle abuse skupiny"
msgid "Number of processed events per autonomous system"
msgstr "Počet zpracovaných událostí dle autonomního systému"
msgid "Number of processed events per source country"
msgstr "Počet zpracovaných událostí dle země původu"
msgid "Number of sent email reports"
msgstr "Počet odeslaných reportů emailem"
msgid "Number of reported events per source IP"
msgstr "Počet reportovaných událostí dle zdrojové IP"
msgid "Number of reported events per category"
msgstr "Počet reportovaných událostí dle kategorie"
msgid "Number of reported events per detector"
msgstr "Počet reportovaných událostí dle detektoru"
msgid "Number of reported events per analyzer"
msgstr "Počet reportovaných událostí dle analyzátoru"
msgid "Number of reported events per abuse group"
msgstr "Počet reportovaných událostí dle abuse skupiny"
msgid "Number of reported events per autonomous system"
msgstr "Počet reportovaných událostí dle autonomního systému"
msgid "Number of reported events per source country"
msgstr "Počet reportovaných událostí dle země původu"
msgid "No data"
msgstr "Žádná data"
......@@ -44,15 +89,9 @@ msgstr "Obsah"
msgid "Event processing statistics"
msgstr "Statistiky zpracování událostí"
msgid "Number of processed events per"
msgstr "Počet zpracovaných událostí dle"
msgid "Event reporting statistics"
msgstr "Statistiky reportování událostí"
msgid "Number of reported events per"
msgstr "Počet reportovaných událostí dle"
msgid "Have a nice day"
msgstr "Hezký den přeje"
......@@ -140,27 +179,6 @@ msgstr "základní"
msgid "advanced"
msgstr "pokročilé"
msgid "source IP"
msgstr "zdrojové IP"
msgid "category"
msgstr "kategorie"
msgid "detector"
msgstr "detektoru"
msgid "abuse group"
msgstr "abuse skupiny"
msgid "analyzer"
msgstr "analyzátoru"
msgid "autonomous system"
msgstr "autonomního systému"
msgid "source country"
msgstr "země původu"
msgid "Periodical statistical summary report"
msgstr "Pravidelný statistický souhrnný report"
......
......@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-05-22 11:35+0200\n"
"POT-Creation-Date: 2019-05-23 11:43+0200\n"
"PO-Revision-Date: 2017-09-22 15:33+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: cs\n"
......
......@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-05-22 11:35+0200\n"
"POT-Creation-Date: 2019-05-23 11:43+0200\n"
"PO-Revision-Date: 2017-09-22 15:33+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: cs\n"
......
......@@ -34,17 +34,6 @@ from mentat.emails.informant import ReportEmail
from mentat.reports.base import BaseReporter
REPORT_SECTION_NAMES = {
'ips': tr_('source IP'),
'categories': tr_('category'),
'detectors': tr_('detector'),
'abuses': tr_('abuse group'),
'analyzers': tr_('analyzer'),
'asns': tr_('autonomous system'),
'countries': tr_('source country')
}
"""Dictionary for translating section identifiers to section names."""
REPORT_SUBJECT = tr_("Periodical statistical summary report")
"""Subject for report emails."""
......@@ -70,8 +59,7 @@ class OverviewReporter(BaseReporter):
"""
renderer = super()._setup_renderer(templates_dir)
renderer.globals['format_section_key'] = lambda x,y: self.format_section_key(x,y)
renderer.globals['format_section_name'] = lambda x: self.format_section_name(x)
renderer.globals['format_section_key'] = self.format_section_key
return renderer
......@@ -89,13 +77,6 @@ class OverviewReporter(BaseReporter):
return 'AS {}'.format(key)
return key
def format_section_name(self, section):
"""
Simple wrapper around :py:func:babel.dates.format_datetime` function
that takes care of figuring out the appropriate locale.
"""
return self.translator.gettext(REPORT_SECTION_NAMES.get(section, section))
#---------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment