Skip to content

Commit

Permalink
webproject: Make *Extra views to render templates on post
Browse files Browse the repository at this point in the history
Astakos used to render the templates for both 'GET' and 'POST' methods.
The previous helper views that the newer Class-based ones replaced, did
support this. Extend the class-based helpers to render the template on a
'POST' request, as if it was a 'GET' one.
  • Loading branch information
philipgian committed Jan 18, 2017
1 parent bff52cb commit ffe8e90
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions snf-webproject/synnefo/webproject/views.py
Expand Up @@ -27,6 +27,9 @@ def get_context_data(self, **kwargs):
context.update(self.extra_context)
return context

def post(self, *args, **kwargs):
return self.get(*args, **kwargs)


class ListViewExtra(ListView):
""" ListView subclass that supports extra_context. """
Expand All @@ -37,6 +40,9 @@ def get_context_data(self, **kwargs):
context.update(self.extra_context)
return context

def post(self, *args, **kwargs):
return self.get(*args, **kwargs)


class DetailViewExtra(DetailView):
""" DetailView subclass that supports extra_context. """
Expand All @@ -46,3 +52,6 @@ def get_context_data(self, **kwargs):
context = super(DetailViewExtra, self).get_context_data(**kwargs)
context.update(self.extra_context)
return context

def post(self, *args, **kwargs):
return self.get(*args, **kwargs)

0 comments on commit ffe8e90

Please sign in to comment.