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" |
+ )() |