From d796272c1053f644758bab7eb3a6b0f48bb90734 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 25 Dec 2017 15:54:23 +0100 Subject: [PATCH] Add cache_control headers to get and post methods --- hosting/views.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 3a596394..879fc3e7 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -73,6 +73,7 @@ class DashboardView(LoginRequiredMixin, View): context = {} return context + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): context = self.get_context_data() return render(request, self.template_name, context) @@ -204,9 +205,9 @@ class IndexView(View): } return context + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): context = self.get_context_data() - return render(request, self.template_name, context) @@ -443,6 +444,7 @@ class SSHKeyListView(LoginRequiredMixin, ListView): self.queryset = UserHostingKey.objects.filter(user=user) return super(SSHKeyListView, self).get_queryset() + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def render_to_response(self, context, **response_kwargs): if not self.queryset: return HttpResponseRedirect(reverse('hosting:choice_ssh_keys')) @@ -454,10 +456,12 @@ class SSHKeyChoiceView(LoginRequiredMixin, View): template_name = "hosting/choice_ssh_keys.html" login_url = reverse_lazy('hosting:login') + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): context = {} return render(request, self.template_name, context) + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def post(self, request, *args, **kwargs): name = generate_ssh_key_name() private_key, public_key = UserHostingKey.generate_keys() @@ -527,6 +531,10 @@ class SSHKeyCreateView(LoginRequiredMixin, FormView): manager.manage_public_key([{'value': public_key, 'state': True}]) return HttpResponseRedirect(self.success_url) + @cache_control(no_cache=True, must_revalidate=True, no_store=True) + def get(self, request, *args, **kwargs): + return render(request, self.template_name) + def post(self, request, *args, **kwargs): form = self.get_form() required = 'add_ssh' in self.request.POST @@ -572,6 +580,10 @@ class SettingsView(LoginRequiredMixin, FormView): return context + @cache_control(no_cache=True, must_revalidate=True, no_store=True) + def get(self, request, *args, **kwargs): + return render(request, self.template_name) + def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): @@ -1045,6 +1057,7 @@ class VirtualMachineView(LoginRequiredMixin, View): final_url = reverse('hosting:virtual_machines') return final_url + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): vm = self.get_object() if vm is None: