Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/utils.py

Issue 5242593268989952: Issue 2340 - Don`t generate pages if less than 30% have been translated (Closed)
Patch Set: Created April 17, 2015, 5:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cms/bin/generate_static_pages.py ('K') | « cms/converters.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/utils.py
===================================================================
--- a/cms/utils.py
+++ b/cms/utils.py
@@ -54,25 +54,35 @@ def get_page_params(source, locale, page
# Note: The converter might change some parameters so we can only read in
# template data here.
params["templatedata"] = source.read_template(params["template"])
defaultlocale = params["config"].get("general", "defaultlocale")
params["defaultlocale"] = defaultlocale
locales = [
- locale
- for locale in source.list_locales()
+ l
+ for l in source.list_locales()
Wladimir Palant 2015/04/17 17:22:31 Parameter being overwritten here isn't quite relat
if source.has_locale(locale, localefile)
]
if defaultlocale not in locales:
locales.append(defaultlocale)
locales.sort()
params["available_locales"] = locales
params["head"], params["body"] = converter()
+ if converter.total_translations:
Sebastian Noack 2015/04/17 17:32:27 Nit: total_translation > 0 I know 0 evaluates to
+ params["translation_ratio"] = (1 -
+ float(converter.missing_translations) / converter.total_translations)
+ else:
+ params["translation_ratio"] = 1
Wladimir Palant 2015/04/17 17:22:31 Note that having this in params means that default
+
return params
-def process_page(source, locale, page, format, site_url_override=None):
- return TemplateConverter(
- get_page_params(source, locale, page, format, site_url_override),
- key="templatedata"
- )()
+def process_page(source, locale, page, format, site_url_override=None, min_translated=0):
+ params = get_page_params(source, locale, page, format, site_url_override)
+ if params["translation_ratio"] < min_translated:
+ return None
+ else:
Sebastian Noack 2015/04/17 17:32:27 Nit: Redundant else statement.
Wladimir Palant 2015/04/17 18:21:15 I thought you would object to this, but I actually
+ return TemplateConverter(
+ params,
+ key="templatedata"
+ )()
« cms/bin/generate_static_pages.py ('K') | « cms/converters.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld