diff --git a/src/djangoflash/models.py b/src/djangoflash/models.py index 448aab3..e2098b4 100644 --- a/src/djangoflash/models.py +++ b/src/djangoflash/models.py @@ -99,12 +99,6 @@ def __delitem__(self, key): if key in self._used: del self._used[key] - def __call__(self, **kwargs): - """Puts one or more values into this flash. - """ - for key, value in kwargs.items(): - self[key] = value - def __len__(self): """Returns the number of values inside this flash. """ @@ -178,9 +172,6 @@ def pop(self, key, default=None): def put(self, **kwargs): """Puts one or more values into this flash. - - .. deprecated :: 1.7.1 - :meth:`put` is deprecated in favor of ``flash(key=value)``. """ for key, value in kwargs.items(): self[key] = value @@ -205,15 +196,6 @@ def clear(self): self._session.clear() self._used.clear() - def put_immediate(self, key, value): - """Puts a value inside this flash and marks it as *used*. - - .. deprecated :: 1.7.1 - :meth:`put_immediate` is deprecated in favor of ``flash.now[key] = value``. - """ - self[key] = value - self._update_status(key) - def discard(self, *keys): """Marks the entire current flash or a single value as *used*, so when the next request hit the server, those values will be automatically @@ -296,7 +278,7 @@ def __setitem__(self, key, value): self.delegate[key] = value self.delegate.discard(key) - def __call__(self, **kwargs): + def put(self, **kwargs): """Puts one or more values into this flash. """ for key, value in kwargs.items(): diff --git a/src/djangoflash/tests/models.py b/src/djangoflash/tests/models.py index 119b1e3..a324e97 100644 --- a/src/djangoflash/tests/models.py +++ b/src/djangoflash/tests/models.py @@ -195,13 +195,6 @@ def test_put(self): self.assertEqual('Warning', self.flash['warn']) self.assertEqual('Error', self.flash['error']) - def test_new_put(self): - """FlashScope: Should put several keys into the flash scope at the same time (new way). - """ - self.flash(warn='Warning', error='Error') - self.assertEqual('Warning', self.flash['warn']) - self.assertEqual('Error', self.flash['error']) - def test_discard(self): """FlashScope: Should mark a value for removal. """ @@ -287,7 +280,7 @@ def test_now(self): def test_alternative_now(self): """FlashScope.now: Immediate values (flash.now) should be supported. """ - self.flash.now(error='Error') + self.flash.now.put(error='Error') self.assertEqual('Error', self.flash['error']) self.flash.update() self.assertFalse('error' in self.flash) diff --git a/src/djangoflash/tests/testproj/app/tests.py b/src/djangoflash/tests/testproj/app/tests.py index 2261d1c..93fb81d 100644 --- a/src/djangoflash/tests/testproj/app/tests.py +++ b/src/djangoflash/tests/testproj/app/tests.py @@ -36,6 +36,23 @@ def test_default_lifecycle(self): self.response = self.client.get(reverse(views.render_template)) self.assertFalse('message' in self._flash()) + def test_value_in_template(self): + """Integration: a value should be accessible by the templating system. + """ + def _assert_content(content, exists=True): + matcher = self.assertTrue if exists else self.assertFalse + matcher(self.response.content.find(content) > 0) + + self.response = self.client.get(reverse(views.set_flash_var)) + _assert_content('Flash context: Message', exists=True) + + self.response = self.client.get(reverse(views.render_template)) + _assert_content('Flash context: Message', exists=True) + + # Flash value will be removed when this request hits the app + self.response = self.client.get(reverse(views.render_template)) + _assert_content('Flash context: Message', exists=False) + def test_keep_lifecycle(self): """Integration: a value shouldn't be removed from the flash when it is kept. """ diff --git a/src/djangoflash/tests/testproj/templates/simple.html b/src/djangoflash/tests/testproj/templates/simple.html index a77dd71..469fe34 100644 --- a/src/djangoflash/tests/testproj/templates/simple.html +++ b/src/djangoflash/tests/testproj/templates/simple.html @@ -3,7 +3,7 @@ Simple template - + Flash context: {{ flash.message }}