mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-23 15:00:23 +00:00
Merge branch 'master' into query-set-deprecated
* master: Update tox.ini. Update runtests.py for compatibility with Django 1.7. Check for StatusModel field name conflicts correctly.
This commit is contained in:
commit
32aa781dc2
5 changed files with 38 additions and 30 deletions
|
|
@ -4,6 +4,9 @@ CHANGES
|
|||
master (unreleased)
|
||||
-------------------
|
||||
|
||||
* Fixed bug with checking for field name conflicts for added query managers on
|
||||
`StatusModel`.
|
||||
|
||||
* Can pass `choices_name` to `StatusField` to use a different name for
|
||||
choices class attribute. ``STATUS`` is used by default.
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ def add_status_query_managers(sender, **kwargs):
|
|||
"""
|
||||
if not issubclass(sender, StatusModel):
|
||||
return
|
||||
for value, name in getattr(sender, 'STATUS', ()):
|
||||
for value, display in getattr(sender, 'STATUS', ()):
|
||||
try:
|
||||
sender._meta.get_field(name)
|
||||
sender._meta.get_field(value)
|
||||
raise ImproperlyConfigured("StatusModel: Model '%s' has a field "
|
||||
"named '%s' which conflicts with a "
|
||||
"status of the same name."
|
||||
% (sender.__name__, name))
|
||||
% (sender.__name__, value))
|
||||
except FieldDoesNotExist:
|
||||
pass
|
||||
sender.add_to_class(value, QueryManager(status=value))
|
||||
|
|
|
|||
|
|
@ -1132,8 +1132,8 @@ class StatusManagerAddedTests(TestCase):
|
|||
with self.assertRaises(ImproperlyConfigured):
|
||||
class ErrorModel(StatusModel):
|
||||
STATUS = (
|
||||
('active', 'active'),
|
||||
('deleted', 'deleted'),
|
||||
('active', 'Is Active'),
|
||||
('deleted', 'Is Deleted'),
|
||||
)
|
||||
active = models.BooleanField()
|
||||
|
||||
|
|
|
|||
35
runtests.py
35
runtests.py
|
|
@ -3,26 +3,31 @@
|
|||
import os, sys
|
||||
|
||||
from django.conf import settings
|
||||
import django
|
||||
|
||||
|
||||
if not settings.configured:
|
||||
settings_dict = dict(
|
||||
INSTALLED_APPS=(
|
||||
'django.contrib.contenttypes',
|
||||
'model_utils',
|
||||
'model_utils.tests',
|
||||
),
|
||||
DATABASES={
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3"
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
settings.configure(**settings_dict)
|
||||
DEFAULT_SETTINGS = dict(
|
||||
INSTALLED_APPS=(
|
||||
'django.contrib.contenttypes',
|
||||
'model_utils',
|
||||
'model_utils.tests',
|
||||
),
|
||||
DATABASES={
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3"
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def runtests(*test_args):
|
||||
if not settings.configured:
|
||||
settings.configure(**DEFAULT_SETTINGS)
|
||||
|
||||
# Compatibility with Django 1.7's stricter initialization
|
||||
if hasattr(django, 'setup'):
|
||||
django.setup()
|
||||
|
||||
if not test_args:
|
||||
test_args = ['tests']
|
||||
|
||||
|
|
|
|||
20
tox.ini
20
tox.ini
|
|
@ -14,14 +14,14 @@ commands = coverage run -a setup.py test
|
|||
[testenv:py26-1.4]
|
||||
basepython = python2.6
|
||||
deps =
|
||||
Django == 1.4.5
|
||||
Django == 1.4.10
|
||||
South == 0.7.6
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py26-1.5]
|
||||
basepython = python2.6
|
||||
deps =
|
||||
Django == 1.5.1
|
||||
Django == 1.5.5
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
|
|
@ -35,21 +35,21 @@ deps =
|
|||
[testenv:py27-1.4]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django == 1.4.5
|
||||
Django == 1.4.10
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py27-1.5]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django == 1.5.1
|
||||
Django == 1.5.5
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py27-1.6]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
https://github.com/django/django/tarball/stable/1.6.x
|
||||
Django == 1.6.1
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
|
|
@ -63,20 +63,20 @@ deps =
|
|||
[testenv:py27-1.5-nosouth]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django == 1.5.1
|
||||
Django == 1.5.5
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py32-1.5]
|
||||
basepython = python3.2
|
||||
deps =
|
||||
Django == 1.5.1
|
||||
Django == 1.5.5
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py32-1.6]
|
||||
basepython = python3.2
|
||||
deps =
|
||||
https://github.com/django/django/tarball/stable/1.6.x
|
||||
Django == 1.6.1
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
|
|
@ -90,14 +90,14 @@ deps =
|
|||
[testenv:py33-1.5]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
Django == 1.5.1
|
||||
Django == 1.5.5
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
[testenv:py33-1.6]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
https://github.com/django/django/tarball/stable/1.6.x
|
||||
Django == 1.6.1
|
||||
South == 0.8.1
|
||||
coverage == 3.6
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue