Repository: translate/pootle

Issue:
Non critical checks in Pootle editor are shown in red
We're only exposing critical errors in the overview.  And exposing all checks in the editor.  We only block submission on critical errors, we don't block on other error classes.

However, we show all errors in Red.

For non-critical errors we should choose a cooler colour from the UI so that translators will know what are the critical errors.



Discussion:
I already mentioned before but I agree with Evernote's philosophy that all checks should be critical. If we can get check "levels" out of the way entirely and get rid of any distinction, then this becomes a non-issue.

Great in theory.  But [not even Evernote](https://translate.evernote.com/projects/support_evernote/translate/ZendeskDynamicContent/#filter=checks&checks=doublequoting) actually subscribes to that as a completely hard and fast rule.


Resolving patch:
diff --git a/pootle/apps/pootle_misc/checks.py b/pootle/apps/pootle_misc/checks.py
--- a/pootle/apps/pootle_misc/checks.py
+++ b/pootle/apps/pootle_misc/checks.py
@@ -21,14 +21,21 @@
 from .util import import_func
 
 
-category_ids = {
+CATEGORY_IDS = {
     'critical': Category.CRITICAL,
     'cosmetic': Category.COSMETIC,
     'functional': Category.FUNCTIONAL,
     'extraction': Category.EXTRACTION,
     'other': Category.NO_CATEGORY,
 }
-
+CATEGORY_CODES = {v: k for k, v in CATEGORY_IDS.iteritems()}
+CATEGORY_NAMES = {
+    Category.CRITICAL: _("Critical"),
+    Category.COSMETIC: _("Cosmetic"),
+    Category.FUNCTIONAL: _("Functional"),
+    Category.EXTRACTION: _("Extraction"),
+    Category.NO_CATEGORY: _("Other"),
+}
 
 check_names = {
     'accelerators': _(u"Accelerators"),  # fixme duplicated
@@ -234,6 +241,18 @@ def get_checker(unit):
     return unit.store.translation_project.checker
 
 
+def get_category_id(code):
+    return CATEGORY_IDS.get(code)
+
+
+def get_category_code(cid):
+    return CATEGORY_CODES.get(cid)
+
+
+def get_category_name(code):
+    return unicode(CATEGORY_NAMES.get(code))
+
+
 class SkipCheck(Exception):
     pass
 
@@ -1000,22 +1019,17 @@ def get_qualitychecks():
 
 
 def get_qualitycheck_schema(path_obj=None):
+    # TODO: add tests
+
     d = {}
     checks = get_qualitychecks()
 
-    category_names = {
-        Category.CRITICAL: _("Critical"),
-        Category.COSMETIC: _("Cosmetic"),
-        Category.FUNCTIONAL: _("Functional"),
-        Category.EXTRACTION: _("Extraction"),
-        Category.NO_CATEGORY: _("Other"),
-    }
-
     for check, cat in checks.items():
         if cat not in d:
             d[cat] = {
                 'code': cat,
-                'title': u"%s" % category_names[cat],
+                'name': get_category_code(cat),
+                'title': get_category_name(cat),
                 'checks': []
             }
         d[cat]['checks'].append({
diff --git a/pootle/apps/pootle_store/models.py b/pootle/apps/pootle_store/models.py
--- a/pootle/apps/pootle_store/models.py
+++ b/pootle/apps/pootle_store/models.py
@@ -832,6 +832,15 @@ def update_qualitychecks(self, keep_false_positives=False,
     def get_qualitychecks(self):
         return self.qualitycheck_set.all()
 
+    def get_critical_qualitychecks(self):
+        return self.get_qualitychecks().filter(category=Category.CRITICAL)
+
+    def get_active_critical_qualitychecks(self):
+        return self.get_active_qualitychecks().filter(category=Category.CRITICAL)
+
+    def get_warning_qualitychecks(self):
+        return self.get_qualitychecks().exclude(category=Category.CRITICAL)
+
     def get_active_qualitychecks(self):
         return self.qualitycheck_set.filter(false_positive=False)
 
diff --git a/pootle/apps/pootle_store/views.py b/pootle/apps/pootle_store/views.py
--- a/pootle/apps/pootle_store/views.py
+++ b/pootle/apps/pootle_store/views.py
@@ -34,11 +34,11 @@
 from pootle.core.http import JsonResponse, JsonResponseBadRequest
 from pootle_app.models.directory import Directory
 from pootle_app.models.permissions import check_user_permission
-from pootle_misc.checks import category_ids, check_names
 from pootle_misc.forms import make_search_form
 from pootle_misc.util import ajax_required, to_int, get_date_interval
 from pootle_statistics.models import (Submission, SubmissionFields,
                                       SubmissionTypes)
+from pootle_misc import checks
 
 from .decorators import get_unit_context
 from .fields import to_python
@@ -263,7 +263,7 @@ def get_step_query(request, units_queryset):
                 elif 'category' in request.GET:
                     category_name = request.GET['category']
                     try:
-                        category = category_ids[category_name]
+                        category = checks.get_category_id(category_name)
                     except KeyError:
                         raise Http404
 
@@ -636,7 +636,7 @@ def timeline(request, unit):
                 check_name = item.quality_check.name
                 entry.update({
                     'check_name': check_name,
-                    'check_display_name': check_names[check_name],
+                    'check_display_name': checks.check_names[check_name],
                     'checks_url': reverse('pootle-checks-descriptions'),
                     'action': {
                                 SubmissionTypes.MUTE_CHECK: 'Muted',


Test patch: