Skip to content

Commit

Permalink
adapt success url for more instance specific
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkuty committed Jul 19, 2015
1 parent 20f1d3b commit 6f60424
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions horizon_contrib/forms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def get_success_url(self):
def form_valid(self, form):

handled = None
success_url = self.get_success_url()

if hasattr(form, 'save'):

try:
Expand All @@ -206,16 +208,17 @@ def form_valid(self, form):
try:
success_url = instance.get_absolute_url()
except Exception as e:
pass
try:
success_url = instance.page.get_absolute_url()
except:
pass

elif hasattr(form, 'handle'):

try:
handled = super(CreateView, self).form_valid(form)
except:
raise e
else:
success_url = self.get_success_url()

response = http.HttpResponseRedirect(success_url)
response['X-Horizon-Location'] = success_url
Expand Down

0 comments on commit 6f60424

Please sign in to comment.