Commit graph

135 commits

Author SHA1 Message Date
Radosław Ganczarek
9e90dde2e8 Add SoftDeletableModel 2016-09-12 15:11:34 +02:00
Alexey Evseev
9ee6065f81 Support Django 1.10 deferred FileField with FieldTracker 2016-09-08 18:00:48 +03:00
Artis Avotins
d1337d5a7c Fixed a bug with Django >= 1.9 where values_list was called on
InheritanceQuerySet with `select_subclasses` applied as strings
raised AttributeError exception.

Adds a new test case `test_dj19_values_list_on_select_subclasses`
2016-05-25 18:58:03 +02:00
Mike Bryant
ff3f8e5546 Use all the fields to determine _id variants. Fixes #214
If a tracker is defined on an inherited model, where the parent has a ForeignKey,
the tracker will now correctly determine that the field_map takes `fk` -> `fk_id`
2016-03-31 15:45:19 +01:00
Karl WnW
ce8deed5ca Fix _clone signature for Django<1.9
InheritanceQuerySetMixin._clone signature conflicts with django
ValuesQuerySet._clone code which calls super like this:
"c = super(ValuesQuerySet, self)._clone(klass, **kwargs)"
2015-11-02 17:52:43 +01:00
jarekwg
81eba92e61 flakes 2015-10-29 09:37:21 +11:00
jarekwg
1d473ec6a9 Test InheritanceManager fail against a different model 2015-10-29 09:33:45 +11:00
jarekwg
201aa3bf30 Half-assed use of User model raises exceptions in 1.9b1 2015-10-29 08:12:02 +11:00
jarekwg
2824ec2e48 Remove PassThroughManager
As of Django 1.7, QuerySet.as_manager() achieves the same result.
2015-10-29 00:10:28 +11:00
bboogaard
041ef6b838 Keep track of deferred fields on model instance
Instead of on FieldInstanceTracker instance

Signed-off-by: bboogaard <b.boogaard@auto-interactive.nl>
2014-08-19 10:29:03 +02:00
Carl Meyer
a127e32217 Revert "Use a signal handler instead of patching save."
This reverts commit 3496fe4291.
2014-07-31 18:08:24 -06:00
Matthew Schinckel
3496fe4291 Use a signal handler instead of patching save.
References #83.

Instead of patching the save method of a tracked model class, we can use
a signal handler on post_save, which means we can still pickle our model
class.

Note we can't just listen for the signal from the class we have, but
instead listen for all post_save signals. This means we actually install
a new signal handler for each tracked model class, which fires on all
model save occurrences (and returns immediately if this handler doesn't care).

We probably could improve this to have a registry of tracked models, or
something, that allows us to just install one signal handler, and filter
according to membership.
2014-05-12 14:32:59 +09:30
Rodney Folz
f02b0912b2 Failing test for Django 1.7 makemigrations
======================================================================
ERROR: test_migrate (model_utils.tests.tests.MigrationsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/projects/django-model-utils/model_utils/tests/tests.py", line 42, in test_migrate
    call_command('migrate', fake=True)
  File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 167, in call_command
    return klass.execute(*args, **defaults)
  File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/base.py", line 337, in execute
    output = self.handle(*args, **options)
  File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 138, in handle
    ProjectState.from_apps(apps),
  File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 71, in from_apps
    model_state = ModelState.from_model(model)
  File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 136, in from_model
    e,
TypeError: Couldn't reconstruct field name_changed on tests.Monitored: MonitorField requires a "monitor" argument
2014-04-23 19:10:04 -07:00
Keryn Knight
8a1d0662f1 Provide dir() support for PassThroughManagers.
Reported in #55 by erikcw.
2014-04-15 08:48:01 +01:00
Matthew Schinckel
93500bb381 Ensure we call get_query_set on django 1.5-
Supersedes https://github.com/carljm/django-model-utils/pull/106

I can't actually see why this works, but it does: tests pass
after this that failed before.
2014-03-20 13:11:00 +10:30
Matthew Schinckel
a49936c267 Test case demonstrating relation failure.
https://github.com/carljm/django-model-utils/issues/120
2014-03-20 11:12:38 +10:30
Michael van Tellingen
6ffae1ad8f Add support for deferred fields in the FieldTracker 2014-03-01 13:34:17 +01:00
Michael van Tellingen
1bab9c492d Add failing test 2014-03-01 12:20:13 +01:00
funkybob
cb362f4a12 Shorten test docstring 2014-01-13 16:49:18 +11:00
Curtis Maloney
0e77c327f5 Update tests.py 2014-01-09 15:46:11 +11:00
Curtis
6f30e88ba5 Attempt to carry over extras(select) values from parent 2014-01-08 23:46:00 +11:00
Carl Meyer
8ea75e53f4 Check for StatusModel field name conflicts correctly. 2014-01-06 16:03:44 -07:00
Alejandro Varas
452ac5cd21 Added choices_name parameter to StatusField 2013-11-14 16:12:31 -03:00
Keryn Knight
dd469a0e8f Added test to explicitly demonstrate manually defined related_name
usage works in select_subclasses going forwards.

Also fixed fragility of 2 tests introduced in ae71f9080e
2013-10-26 16:34:21 +01:00
Keryn Knight
262455a60d Update model tests to include our new InheritanceManagerTestChild3
as part of the emulation of select_subclasses.

Test still fails because of #59.
2013-10-26 15:50:19 +01:00
Keryn Knight
ae71f9080e Tests for #59 - a manually specified OneToOne should behave
the same as an implicit one.
2013-10-26 15:44:01 +01:00
Keryn Knight
1de58474c0 Implemented #44 - passing Model classes to InheritanceManager's select_subclasses 2013-10-21 21:47:58 +01:00
Carl Meyer
3211c92a4d Merge branch 'master' into fix-choices-deepcopy
* master: (23 commits)
  only accepting iterables to the when field
  adding 'when' parameter to MonitorField
  Update AUTHORS and changelog.
  Add test to verify get_subclass() on QuerySet
  Refactor to make sure get_subclass() is on QuerySet
  Fixed indexing into Choices so its useful.
  Fix bug with child/grandchild select_subclasses in Django 1.6+; thanks Keryn Knight.
  fixed code block
  Bump version for dev.
  Bump version for 1.5.0 release.
  Add option-groups capability to Choices.
  Add Changelog note about Choices equality/addition.
  Added tests to improve coverage
  Alphabetised authors
  Removed redundant inequality method on Choices
  Moved documentation for Choices field to the right place
  Corrected typo
  Added self to Authors file
  Added equality methods to Choices objects, and overrode + for Choices for easy concatenation with other Choices and choice-like iterables. Also wrote tests for them, and extended the readme to reflect this
  Fix typo noted by @silonov
  ...

Conflicts:
	model_utils/choices.py
2013-10-11 13:23:56 -06:00
Filipe Ximenes
3d82ec89b4 only accepting iterables to the when field 2013-10-11 08:24:00 -03:00
Filipe Ximenes
e3450977bd adding 'when' parameter to MonitorField 2013-10-11 00:08:38 -03:00
Travis Swicegood
03c8a1929b Add test to verify get_subclass() on QuerySet 2013-10-08 10:38:52 -05:00
Carl Meyer
5a33ff760a Fixed indexing into Choices so its useful. 2013-09-24 15:13:27 -06:00
Carl Meyer
4b6a800050 Fix bug with child/grandchild select_subclasses in Django 1.6+; thanks Keryn Knight. 2013-09-20 10:04:10 -06:00
Carl Meyer
2e44f1c2c0 Add option-groups capability to Choices. 2013-08-29 22:00:53 -06:00
Tony Aldridge
b706aee4a9 Added tests to improve coverage 2013-08-25 08:29:10 +01:00
Tony Aldridge
3485df15f2 Merge remote-tracking branch 'upstream/master'
Conflicts:
	README.rst
2013-08-24 10:36:21 +01:00
Tony Aldridge
003ad70805 Added equality methods to Choices objects, and overrode + for Choices
for easy concatenation with other Choices and choice-like iterables.
Also wrote tests for them, and extended the readme to reflect this
2013-08-23 16:58:10 +01:00
Den Lesnov
18999c43dd Added deepcopy test 2013-08-21 17:15:19 +04:00
Trey Hunner
2679f6114b Merge branch 'silonov-json_fields_support'
Conflicts:
	CHANGES.rst
	model_utils/tests/tests.py
2013-08-17 01:40:09 -07:00
Trey Hunner
15910e04e7 Merge branch 'field-tracker-inheritance'
Conflicts:
	CHANGES.rst
2013-08-11 18:49:20 -07:00
silonov
f20e723952 Added more general mutable fields support instead of json-specific 2013-08-11 19:32:45 +04:00
silonov
630741b423 Added JSONEncoder().encode(...) check for json-like fields 2013-08-10 01:59:06 +04:00
Carl Meyer
9a3abce7f5 Update testing idioms. 2013-08-08 09:43:46 -06:00
Mikhail Silonov
8c6f343111 Added JSON Fields support 2013-08-08 18:02:12 +04:00
Mikhail Silonov
b9f954074c Fixed a bug causing KeyError when saving with the parameter update_fields in which there are untracked fields. 2013-08-08 13:22:25 +04:00
Keryn Knight
6f0cf2a96c first pass at tests for the __contains__ functionality
just implemented.
2013-08-02 12:24:44 +01:00
Trey Hunner
75646a1874 Improve FieldTracker tests for inherited models 2013-07-30 10:16:43 -07:00
Carl Meyer
9a5a2bcf88 Use proper unittest test-skipping. 2013-07-25 12:16:11 -05:00
Carl Meyer
bcc8ad3a64 Update tox.ini for Django 1.6 stable branch, South supporting Py3. 2013-07-25 11:58:46 -05:00
Eran Rundstein
5687d9836d create basic failing test case for inherited models and tracker 2013-06-06 13:24:43 +00:00