prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Silence dev checks in the admin UI as well
  There's the following section in the Pootle dev config:
  
  ``` Python
  # Silence the DEBUG check on dev servers
  SILENCED_SYSTEM_CHECKS = [
      'pootle.W004',  # python-levenstein not installed
      'pootle.W005',  # DEBUG = True
      'pootle.W010',  # DEFAULT_FROM_EMAIL has default setting
      'pootle.W011',  # POOTLE_CONTACT_EMAIL has default setting
  ]
  ```
  
  When running Pootle, I still get these notifications in the admin UI among others:
  
  > `/!\` DEBUG mode is on. Do not do this in production! Set DEBUG = False in Pootle settings
  > 
  > `/!\`  POOTLE_CONTACT_EMAIL is using the following default setting 'info@YOUR_DOMAIN.com'. POOTLE_CONTACT_EMAIL is the address that will receive messages sent by the contact form.
  > 
  > `/!\` DEFAULT_FROM_EMAIL is using the following default setting 'webmaster@localhost'. DEFAULT_FROM_EMAIL is used in all outgoing Pootle email. Don't forget to review your mail server settings.
  
  I think it might make sense to silence them consistently not only in the console, but in the admin UI as well.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pootle/apps/pootle_app/views/admin/dashboard.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 import locale
  10 import os
  11 
  12 from redis.exceptions import ConnectionError
  13 
  14 from django.contrib.auth import get_user_model
  15 from django.core.cache import cache
  16 from django.shortcuts import render
  17 
  18 from django_rq.queues import get_failed_queue, get_queue
  19 from django_rq.workers import Worker
  20 
  21 from pootle.core.decorators import admin_required
  22 from pootle.i18n.gettext import ugettext as _, ungettext
  23 from pootle_statistics.models import Submission
  24 from pootle_store.models import Suggestion
  25 
  26 
  27 def _format_numbers(numbers):
  28     for k in numbers.keys():
  29         formatted_number = locale.format("%d", numbers[k], grouping=True)
  30         # Under Windows, formatted number must be converted to Unicode
  31         if os.name == 'nt':
  32             formatted_number = formatted_number.decode(
  33                 locale.getpreferredencoding()
  34             )
  35         numbers[k] = formatted_number
  36 
  37 
  38 def server_stats():
  39     User = get_user_model()
  40     result = cache.get("server_stats")
  41     if result is None:
  42         result = {}
  43         result['user_count'] = max(User.objects.filter(
  44             is_active=True).count()-2, 0)
  45         # 'default' and 'nobody' might be counted
  46         # FIXME: the special users should not be retuned with is_active
  47         result['submission_count'] = Submission.objects.count()
  48         result['pending_count'] = Suggestion.objects.pending().count()
  49         cache.set("server_stats", result, 86400)
  50     _format_numbers(result)
  51     return result
  52 
  53 
  54 def rq_stats():
  55     queue = get_queue()
  56     failed_queue = get_failed_queue()
  57     try:
  58         workers = Worker.all(queue.connection)
  59     except ConnectionError:
  60         return None
  61 
  62     num_workers = len(workers)
  63     is_running = len(queue.connection.smembers(Worker.redis_workers_keys)) > 0
  64     if is_running:
  65         # Translators: this refers to the status of the background job worker
  66         status_msg = ungettext('Running (%d worker)', 'Running (%d workers)',
  67                                num_workers) % num_workers
  68     else:
  69         # Translators: this refers to the status of the background job worker
  70         status_msg = _('Stopped')
  71 
  72     result = {
  73         'job_count': queue.count,
  74         'failed_job_count': failed_queue.count,
  75         'is_running': is_running,
  76         'status_msg': status_msg,
  77     }
  78 
  79     return result
  80 
  81 
  82 def checks():
  83     from django.core.checks.registry import registry
  84 
  85     return registry.run_checks()
  86 
  87 
  88 @admin_required
  89 def view(request):
  90     ctx = {
  91         'page': 'admin-dashboard',
  92         'server_stats': server_stats(),
  93         'rq_stats': rq_stats(),
  94         'checks': checks(),
  95     }
  96     return render(request, "admin/dashboard.html", ctx)
  97
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pootle/apps/pootle_app/views/admin/dashboard.py b/pootle/apps/pootle_app/views/admin/dashboard.py
  --- a/pootle/apps/pootle_app/views/admin/dashboard.py
  +++ b/pootle/apps/pootle_app/views/admin/dashboard.py
  @@ -82,7 +82,7 @@
   def checks():
       from django.core.checks.registry import registry
   
  -    return registry.run_checks()
  +    return [e for e in registry.run_checks() if not e.is_silenced()]
   
   
   @admin_required
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_app/views/admin/dashboard.py b/pootle/apps/pootle_app/views/admin/dashboard.py\n--- a/pootle/apps/pootle_app/views/admin/dashboard.py\n+++ b/pootle/apps/pootle_app/views/admin/dashboard.py\n@@ -82,7 +82,7 @@\n def checks():\n     from django.core.checks.registry import registry\n \n-    return registry.run_checks()\n+    return [e for e in registry.run_checks() if not e.is_silenced()]\n \n \n @admin_required\n", "issue": "Silence dev checks in the admin UI as well\nThere's the following section in the Pootle dev config:\n\n``` Python\n# Silence the DEBUG check on dev servers\nSILENCED_SYSTEM_CHECKS = [\n    'pootle.W004',  # python-levenstein not installed\n    'pootle.W005',  # DEBUG = True\n    'pootle.W010',  # DEFAULT_FROM_EMAIL has default setting\n    'pootle.W011',  # POOTLE_CONTACT_EMAIL has default setting\n]\n```\n\nWhen running Pootle, I still get these notifications in the admin UI among others:\n\n> `/!\\` DEBUG mode is on. Do not do this in production! Set DEBUG = False in Pootle settings\n> \n> `/!\\`  POOTLE_CONTACT_EMAIL is using the following default setting 'info@YOUR_DOMAIN.com'. POOTLE_CONTACT_EMAIL is the address that will receive messages sent by the contact form.\n> \n> `/!\\` DEFAULT_FROM_EMAIL is using the following default setting 'webmaster@localhost'. DEFAULT_FROM_EMAIL is used in all outgoing Pootle email. Don't forget to review your mail server settings.\n\nI think it might make sense to silence them consistently not only in the console, but in the admin UI as well.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nimport locale\nimport os\n\nfrom redis.exceptions import ConnectionError\n\nfrom django.contrib.auth import get_user_model\nfrom django.core.cache import cache\nfrom django.shortcuts import render\n\nfrom django_rq.queues import get_failed_queue, get_queue\nfrom django_rq.workers import Worker\n\nfrom pootle.core.decorators import admin_required\nfrom pootle.i18n.gettext import ugettext as _, ungettext\nfrom pootle_statistics.models import Submission\nfrom pootle_store.models import Suggestion\n\n\ndef _format_numbers(numbers):\n    for k in numbers.keys():\n        formatted_number = locale.format(\"%d\", numbers[k], grouping=True)\n        # Under Windows, formatted number must be converted to Unicode\n        if os.name == 'nt':\n            formatted_number = formatted_number.decode(\n                locale.getpreferredencoding()\n            )\n        numbers[k] = formatted_number\n\n\ndef server_stats():\n    User = get_user_model()\n    result = cache.get(\"server_stats\")\n    if result is None:\n        result = {}\n        result['user_count'] = max(User.objects.filter(\n            is_active=True).count()-2, 0)\n        # 'default' and 'nobody' might be counted\n        # FIXME: the special users should not be retuned with is_active\n        result['submission_count'] = Submission.objects.count()\n        result['pending_count'] = Suggestion.objects.pending().count()\n        cache.set(\"server_stats\", result, 86400)\n    _format_numbers(result)\n    return result\n\n\ndef rq_stats():\n    queue = get_queue()\n    failed_queue = get_failed_queue()\n    try:\n        workers = Worker.all(queue.connection)\n    except ConnectionError:\n        return None\n\n    num_workers = len(workers)\n    is_running = len(queue.connection.smembers(Worker.redis_workers_keys)) > 0\n    if is_running:\n        # Translators: this refers to the status of the background job worker\n        status_msg = ungettext('Running (%d worker)', 'Running (%d workers)',\n                               num_workers) % num_workers\n    else:\n        # Translators: this refers to the status of the background job worker\n        status_msg = _('Stopped')\n\n    result = {\n        'job_count': queue.count,\n        'failed_job_count': failed_queue.count,\n        'is_running': is_running,\n        'status_msg': status_msg,\n    }\n\n    return result\n\n\ndef checks():\n    from django.core.checks.registry import registry\n\n    return registry.run_checks()\n\n\n@admin_required\ndef view(request):\n    ctx = {\n        'page': 'admin-dashboard',\n        'server_stats': server_stats(),\n        'rq_stats': rq_stats(),\n        'checks': checks(),\n    }\n    return render(request, \"admin/dashboard.html\", ctx)\n", "path": "pootle/apps/pootle_app/views/admin/dashboard.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nimport locale\nimport os\n\nfrom redis.exceptions import ConnectionError\n\nfrom django.contrib.auth import get_user_model\nfrom django.core.cache import cache\nfrom django.shortcuts import render\n\nfrom django_rq.queues import get_failed_queue, get_queue\nfrom django_rq.workers import Worker\n\nfrom pootle.core.decorators import admin_required\nfrom pootle.i18n.gettext import ugettext as _, ungettext\nfrom pootle_statistics.models import Submission\nfrom pootle_store.models import Suggestion\n\n\ndef _format_numbers(numbers):\n    for k in numbers.keys():\n        formatted_number = locale.format(\"%d\", numbers[k], grouping=True)\n        # Under Windows, formatted number must be converted to Unicode\n        if os.name == 'nt':\n            formatted_number = formatted_number.decode(\n                locale.getpreferredencoding()\n            )\n        numbers[k] = formatted_number\n\n\ndef server_stats():\n    User = get_user_model()\n    result = cache.get(\"server_stats\")\n    if result is None:\n        result = {}\n        result['user_count'] = max(User.objects.filter(\n            is_active=True).count()-2, 0)\n        # 'default' and 'nobody' might be counted\n        # FIXME: the special users should not be retuned with is_active\n        result['submission_count'] = Submission.objects.count()\n        result['pending_count'] = Suggestion.objects.pending().count()\n        cache.set(\"server_stats\", result, 86400)\n    _format_numbers(result)\n    return result\n\n\ndef rq_stats():\n    queue = get_queue()\n    failed_queue = get_failed_queue()\n    try:\n        workers = Worker.all(queue.connection)\n    except ConnectionError:\n        return None\n\n    num_workers = len(workers)\n    is_running = len(queue.connection.smembers(Worker.redis_workers_keys)) > 0\n    if is_running:\n        # Translators: this refers to the status of the background job worker\n        status_msg = ungettext('Running (%d worker)', 'Running (%d workers)',\n                               num_workers) % num_workers\n    else:\n        # Translators: this refers to the status of the background job worker\n        status_msg = _('Stopped')\n\n    result = {\n        'job_count': queue.count,\n        'failed_job_count': failed_queue.count,\n        'is_running': is_running,\n        'status_msg': status_msg,\n    }\n\n    return result\n\n\ndef checks():\n    from django.core.checks.registry import registry\n\n    return [e for e in registry.run_checks() if not e.is_silenced()]\n\n\n@admin_required\ndef view(request):\n    ctx = {\n        'page': 'admin-dashboard',\n        'server_stats': server_stats(),\n        'rq_stats': rq_stats(),\n        'checks': checks(),\n    }\n    return render(request, \"admin/dashboard.html\", ctx)\n", "path": "pootle/apps/pootle_app/views/admin/dashboard.py"}]}