Skip to content

Commit

Permalink
#322 Solves Error on Inline cookie cached, when a record is deleted a…
Browse files Browse the repository at this point in the history
…nd it's pk is on the edit cookie
  • Loading branch information
dpgaspar committed May 14, 2016
1 parent 2b37795 commit c304877
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions flask_appbuilder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,13 @@ def get_key(cls, k, default=None):
else:
return default

@classmethod
def del_key(cls, k):
"""Matching get method for ``set_key``
"""
k = cls.__name__ + '__' + k
session.pop(k)

def _get_list_widget(self, **args):
""" get joined base filter and current active filter for query """
widgets = super(CompactCRUDMixin, self)._get_list_widget(**args)
Expand Down Expand Up @@ -636,6 +643,7 @@ def add(self):
@has_access
def edit(self, pk):
widgets = self._edit(pk)
self.update_redirect()
if not widgets:
self.set_key('session_form_action', '')
self.set_key('session_form_widget', None)
Expand All @@ -647,6 +655,14 @@ def edit(self, pk):
self.set_key('session_form_edit_pk', pk)
return redirect(self.get_redirect())

@expose('/delete/<pk>')
@has_access
def delete(self, pk):
self._delete(pk)
edit_pk = self.get_key('session_form_edit_pk')
if pk == edit_pk:
self.del_key('session_form_edit_pk')
return redirect(self.get_redirect())

"""
This is for retro compatibility
Expand Down

0 comments on commit c304877

Please sign in to comment.