Permalink
Browse files

Fixed #16905 -- Added extensible checks (nee validation) framework

This is the result of Christopher Medrela's 2013 Summer of Code project.

Thanks also to Preston Holmes, Tim Graham, Anssi Kääriäinen, Florian
Apolloner, and Alex Gaynor for review notes along the way.

Also: Fixes #8579, fixes #3055, fixes #19844.
  • Loading branch information...
1 parent 6e7bd0b commit d818e0c9b2b88276cc499974f9eee893170bf0a8 @freakboy3742 freakboy3742 committed Jan 20, 2014
Showing with 7,059 additions and 1,959 deletions.
  1. +11 −1 django/conf/__init__.py
  2. +10 −0 django/conf/global_settings.py
  3. +5 −1 django/contrib/admin/__init__.py
  4. +932 −0 django/contrib/admin/checks.py
  5. +52 −13 django/contrib/admin/options.py
  6. +1 −1 django/contrib/admin/sites.py
  7. +6 −0 django/contrib/auth/__init__.py
  8. +69 −0 django/contrib/auth/checks.py
  9. +1 −1 django/contrib/auth/management/commands/changepassword.py
  10. +70 −13 django/contrib/auth/tests/test_management.py
  11. +8 −0 django/contrib/contenttypes/__init__.py
  12. +18 −0 django/contrib/contenttypes/checks.py
  13. +165 −2 django/contrib/contenttypes/generic.py
  14. +1 −1 django/contrib/gis/management/commands/ogrinspect.py
  15. +50 −26 django/contrib/sites/managers.py
  16. +1 −1 django/contrib/staticfiles/management/commands/collectstatic.py
  17. +18 −0 django/core/checks/__init__.py
  18. +0 −39 django/core/checks/compatibility/base.py
  19. +94 −43 django/core/checks/compatibility/django_1_6_0.py
  20. +84 −0 django/core/checks/messages.py
  21. +49 −0 django/core/checks/model_checks.py
  22. +63 −0 django/core/checks/registry.py
  23. +109 −17 django/core/management/base.py
  24. +27 −9 django/core/management/commands/check.py
  25. +1 −1 django/core/management/commands/compilemessages.py
  26. +1 −1 django/core/management/commands/createcachetable.py
  27. +1 −1 django/core/management/commands/dbshell.py
  28. +1 −1 django/core/management/commands/diffsettings.py
  29. +1 −1 django/core/management/commands/inspectdb.py
  30. +1 −1 django/core/management/commands/makemessages.py
  31. +2 −2 django/core/management/commands/runserver.py
  32. +1 −1 django/core/management/commands/shell.py
  33. +1 −1 django/core/management/commands/test.py
  34. +1 −1 django/core/management/commands/testserver.py
  35. +10 −5 django/core/management/commands/validate.py
  36. +1 −1 django/core/management/templates.py
  37. +0 −411 django/core/management/validation.py
  38. +27 −1 django/db/backends/__init__.py
  39. +25 −8 django/db/backends/mysql/validation.py
  40. +303 −0 django/db/models/base.py
  41. +284 −14 django/db/models/fields/__init__.py
  42. +71 −3 django/db/models/fields/files.py
  43. +364 −3 django/db/models/fields/related.py
  44. +19 −0 django/db/models/manager.py
  45. +12 −7 django/db/models/options.py
  46. +12 −4 django/forms/models.py
  47. +2 −1 django/test/__init__.py
  48. +3 −3 django/test/testcases.py
  49. +20 −0 django/test/utils.py
  50. +3 −0 django/utils/termcolors.py
  51. +29 −3 docs/howto/custom-management-commands.txt
  52. +1 −0 docs/index.txt
  53. +10 −0 docs/internals/deprecation.txt
  54. +3 −3 docs/intro/tutorial01.txt
  55. +208 −0 docs/ref/checks.txt
  56. +31 −10 docs/ref/django-admin.txt
  57. +1 −0 docs/ref/index.txt
  58. +17 −0 docs/ref/settings.txt
  59. +41 −1 docs/releases/1.7.txt
  60. +2 −2 docs/topics/db/models.txt
  61. 0 tests/{invalid_models_tests/invalid_models → admin_checks}/__init__.py
  62. +57 −0 tests/admin_checks/models.py
  63. +436 −0 tests/admin_checks/tests.py
  64. 0 tests/{check → admin_scripts/app_raising_messages}/__init__.py
  65. +27 −0 tests/admin_scripts/app_raising_messages/models.py
  66. 0 tests/admin_scripts/app_raising_warning/__init__.py
  67. +16 −0 tests/admin_scripts/app_raising_warning/models.py
  68. +1 −1 tests/admin_scripts/management/commands/app_command.py
  69. +1 −1 tests/admin_scripts/management/commands/base_command.py
  70. +1 −1 tests/admin_scripts/management/commands/label_command.py
  71. +1 −1 tests/admin_scripts/management/commands/noargs_command.py
  72. +11 −0 tests/admin_scripts/management/commands/validation_command.py
  73. +144 −53 tests/admin_scripts/tests.py
  74. +2 −2 tests/admin_validation/tests.py
  75. +21 −10 tests/admin_views/tests.py
  76. +0 −128 tests/check/tests.py
  77. 0 tests/check_framework/__init__.py
  78. +8 −0 tests/{check → check_framework}/models.py
  79. +219 −0 tests/check_framework/tests.py
  80. +301 −2 tests/contenttypes_tests/tests.py
  81. +3 −0 tests/fixtures_model_package/tests.py
  82. +5 −4 tests/inline_formsets/tests.py
  83. +18 −0 tests/invalid_models_tests/base.py
  84. +0 −535 tests/invalid_models_tests/invalid_models/models.py
  85. +68 −0 tests/invalid_models_tests/test_backend_specific.py
  86. +334 −0 tests/invalid_models_tests/test_models.py
  87. +417 −0 tests/invalid_models_tests/test_ordinary_fields.py
  88. +1,037 −0 tests/invalid_models_tests/test_relative_fields.py
  89. +0 −46 tests/invalid_models_tests/tests.py
  90. +1 −1 tests/logging_tests/tests.py
  91. +5 −1 tests/migrate_signals/tests.py
  92. +16 −1 tests/migrations/test_commands.py
  93. +5 −0 tests/model_fields/tests.py
  94. +20 −16 tests/model_validation/tests.py
  95. +476 −474 tests/modeladmin/tests.py
  96. +4 −0 tests/proxy_model_inheritance/tests.py
  97. +0 −11 tests/sites_framework/models.py
  98. +45 −5 tests/sites_framework/tests.py
  99. +4 −1 tests/test_runner/tests.py
  100. +1 −1 tests/user_commands/management/commands/dance.py
  101. +0 −5 tests/validation/test_error_messages.py
@@ -99,7 +99,7 @@ def __init__(self, settings_module):
)
tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")
-
+ self._explicit_settings = set()
for setting in dir(mod):
if setting.isupper():
setting_value = getattr(mod, setting)
@@ -110,6 +110,7 @@ def __init__(self, settings_module):
"Please fix your settings." % setting)
setattr(self, setting, setting_value)
+ self._explicit_settings.add(setting)
if not self.SECRET_KEY:
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
@@ -126,6 +127,9 @@ def __init__(self, settings_module):
os.environ['TZ'] = self.TIME_ZONE
time.tzset()
+ def is_overridden(self, setting):
+ return setting in self._explicit_settings
+
class UserSettingsHolder(BaseSettings):
"""
@@ -159,4 +163,10 @@ def __delattr__(self, name):
def __dir__(self):
return list(self.__dict__) + dir(self.default_settings)
+ def is_overridden(self, setting):
+ if setting in self._deleted:
+ return False
+ else:
+ return self.default_settings.is_overridden(setting)
+
settings = LazySettings()
@@ -618,3 +618,13 @@
# Migration module overrides for apps, by app label.
MIGRATION_MODULES = {}
+
+#################
+# SYSTEM CHECKS #
+#################
+
+# List of all issues generated by system checks that should be silenced. Light
+# issues like warnings, infos or debugs will not generate a message. Silencing
+# serious issues like errors and criticals does not result in hiding the
+# message, but Django will not stop you from e.g. running server.
+SILENCED_SYSTEM_CHECKS = []
@@ -1,13 +1,15 @@
# ACTION_CHECKBOX_NAME is unused, but should stay since its import from here
# has been referenced in documentation.
+from django.contrib.admin.checks import check_admin_app
from django.contrib.admin.decorators import register
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
from django.contrib.admin.options import StackedInline, TabularInline
-from django.contrib.admin.sites import AdminSite, site
from django.contrib.admin.filters import (ListFilter, SimpleListFilter,
FieldListFilter, BooleanFieldListFilter, RelatedFieldListFilter,
ChoicesFieldListFilter, DateFieldListFilter, AllValuesFieldListFilter)
+from django.contrib.admin.sites import AdminSite, site
+from django.core import checks
from django.utils.module_loading import autodiscover_modules
__all__ = [
@@ -21,3 +23,5 @@
def autodiscover():
autodiscover_modules('admin', register_to=site)
+
+checks.register('admin')(check_admin_app)
Oops, something went wrong. Retry.

0 comments on commit d818e0c

Please sign in to comment.