Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #70 from postatum/101517326_simplify_logic
Browse files Browse the repository at this point in the history
Dont check needs_confirmation on delete_many
  • Loading branch information
jstoiko committed Sep 4, 2015
2 parents c768e27 + 60a2774 commit 38a462c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
8 changes: 0 additions & 8 deletions ramses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ def delete(self, **kwargs):

def delete_many(self, **kwargs):
objects = self.get_collection()

if self.needs_confirmation():
return objects

return self.Model._delete_many(objects, self.request)

def update_many(self, **kwargs):
Expand Down Expand Up @@ -314,10 +310,6 @@ def delete_many(self, **kwargs):
by ES in the 'index' method (so user deletes what he saw).
"""
db_objects = self.get_dbcollection_with_es(**kwargs)

if self.needs_confirmation():
return db_objects

return self.Model._delete_many(db_objects, self.request)

def update_many(self, **kwargs):
Expand Down
22 changes: 0 additions & 22 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,11 @@ def test_delete(self):
view.request)
assert resp is None

def test_delete_many_needs_confirm(self):
view = self._test_view()
view.Model = Mock()
view.get_collection = Mock()
view.needs_confirmation = Mock(return_value=True)
resp = view.delete_many(foo=1)
view.get_collection.assert_called_once_with()
assert resp == view.get_collection()

def test_delete_many(self):
view = self._test_view()
view.Model = Mock(__name__='Mock')
view.Model._delete_many.return_value = 123
view.get_collection = Mock()
view.needs_confirmation = Mock(return_value=False)
resp = view.delete_many(foo=1)
view.get_collection.assert_called_once_with()
view.Model._delete_many.assert_called_once_with(
Expand Down Expand Up @@ -440,19 +430,8 @@ def test_get_dbcollection_with_es(self):
view.Model.filter_objects.assert_called_once_with([1, 2])
assert result == view.Model.filter_objects()

def test_delete_many_need_confirmation(self):
view = self._test_view()
view.needs_confirmation = Mock(return_value=True)
view.Model = Mock()
view.get_dbcollection_with_es = Mock()
result = view.delete_many(foo=1)
view.get_dbcollection_with_es.assert_called_once_with(foo=1)
assert result == view.get_dbcollection_with_es()
assert not view.Model._delete_many.called

def test_delete_many(self):
view = self._test_view()
view.needs_confirmation = Mock(return_value=False)
view.Model = Mock(__name__='Foo')
view.Model._delete_many.return_value = 123
view.get_dbcollection_with_es = Mock()
Expand All @@ -464,7 +443,6 @@ def test_delete_many(self):

def test_update_many(self):
view = self._test_view()
view.needs_confirmation = Mock(return_value=False)
view.Model = Mock(__name__='Foo')
view.Model._update_many.return_value = 123
view.get_dbcollection_with_es = Mock()
Expand Down

0 comments on commit 38a462c

Please sign in to comment.