Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'as_of' for models #106

Merged
merged 6 commits into from
Aug 2, 2014
Merged

'as_of' for models #106

merged 6 commits into from
Aug 2, 2014

Conversation

macro1
Copy link
Collaborator

@macro1 macro1 commented Jul 20, 2014

Modifies 'as_of' on the historical manager to return an iterable when no instance is provided.

See discussion in #53

"""
as_of_list = list(
self.model.history.as_of(self.now - timedelta(days=1)))
self.assertEqual(as_of_list[0].changed_by, self.obj.changed_by)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these tests seem to check for only one instance. Should we test that multiple objects can be returned?

@treyhunner
Copy link
Member

I made some comments about more test ideas. This looks ready to merge to me. Feel free to merge now or add some more tests and then merge.

return history_obj.instance

def _as_of_set(self, date):
model = type(self.model().instance) # a bit of a hack to get the model
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@treyhunner, do you know of a better way of getting at the original model?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I do not.

macro1 added a commit that referenced this pull request Aug 2, 2014
Extend the 'as_of' method to work as a class method
@macro1 macro1 merged commit 7635120 into master Aug 2, 2014
@macro1 macro1 deleted the non-instance-as-of branch August 2, 2014 03:56
macro1 added a commit to macro1/django-simple-history that referenced this pull request Aug 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants