From b4f03b95531dce6772eac684ed29fb66693b9457 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 25 Dec 2017 15:10:34 +0100 Subject: [PATCH] Add cache_control decorator to all hosting views --- hosting/views.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 25d89b64..a6922a70 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -65,6 +65,7 @@ CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a \ minutes." +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class DashboardView(LoginRequiredMixin, View): template_name = "hosting/dashboard.html" login_url = reverse_lazy('hosting:login') @@ -186,6 +187,7 @@ class HostingPricingView(ProcessVMSelectionMixin, View): return render(request, self.template_name, context) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class IndexView(View): template_name = "hosting/index.html" @@ -210,6 +212,7 @@ class IndexView(View): return render(request, self.template_name, context) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class LoginView(LoginViewMixin): template_name = "hosting/login.html" form_class = HostingUserLoginForm @@ -310,6 +313,7 @@ class SignupValidatedView(SignupValidateView): return context +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class ResendActivationEmailView(ResendActivationLinkViewMixin): template_name = 'hosting/resend_activation_link.html' form_class = ResendActivationEmailForm @@ -318,6 +322,7 @@ class ResendActivationEmailView(ResendActivationLinkViewMixin): email_template_name = 'user_activation' +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class PasswordResetView(PasswordResetViewMixin): site = 'dcl' template_name = 'hosting/reset_password.html' @@ -326,6 +331,7 @@ class PasswordResetView(PasswordResetViewMixin): template_email_path = 'hosting/emails/' +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class PasswordResetConfirmView(PasswordResetConfirmViewMixin): template_name = 'hosting/confirm_reset_password.html' success_url = reverse_lazy('hosting:login') @@ -402,6 +408,7 @@ class MarkAsReadNotificationView(LoginRequiredMixin, UpdateView): return HttpResponseRedirect(reverse('hosting:notifications')) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class SSHKeyDeleteView(LoginRequiredMixin, DeleteView): login_url = reverse_lazy('hosting:login') success_url = reverse_lazy('hosting:ssh_keys') @@ -430,6 +437,7 @@ class SSHKeyDeleteView(LoginRequiredMixin, DeleteView): return super(SSHKeyDeleteView, self).delete(request, *args, **kwargs) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class SSHKeyListView(LoginRequiredMixin, ListView): template_name = "hosting/user_keys.html" login_url = reverse_lazy('hosting:login') @@ -450,6 +458,7 @@ class SSHKeyListView(LoginRequiredMixin, ListView): **response_kwargs) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class SSHKeyChoiceView(LoginRequiredMixin, View): template_name = "hosting/choice_ssh_keys.html" login_url = reverse_lazy('hosting:login') @@ -476,6 +485,7 @@ class SSHKeyChoiceView(LoginRequiredMixin, View): return redirect(reverse_lazy('hosting:ssh_keys'), foo='bar') +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class SSHKeyCreateView(LoginRequiredMixin, FormView): form_class = UserHostingKeyForm model = UserHostingKey @@ -538,6 +548,7 @@ class SSHKeyCreateView(LoginRequiredMixin, FormView): return self.form_invalid(form) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class SettingsView(LoginRequiredMixin, FormView): template_name = "hosting/settings.html" login_url = reverse_lazy('hosting:login') @@ -589,6 +600,7 @@ class SettingsView(LoginRequiredMixin, FormView): return self.form_invalid(form) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class PaymentVMView(LoginRequiredMixin, FormView): template_name = 'hosting/payment.html' login_url = reverse_lazy('hosting:login') @@ -667,8 +679,8 @@ class PaymentVMView(LoginRequiredMixin, FormView): return self.form_invalid(form) -class OrdersHostingDetailView(LoginRequiredMixin, - DetailView): +@cache_control(no_cache=True, must_revalidate=True, no_store=True) +class OrdersHostingDetailView(LoginRequiredMixin, DetailView): template_name = "hosting/order_detail.html" context_object_name = "order" login_url = reverse_lazy('hosting:login') @@ -881,6 +893,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, content_type="application/json") +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class OrdersHostingListView(LoginRequiredMixin, ListView): template_name = "hosting/orders.html" login_url = reverse_lazy('hosting:login') @@ -895,6 +908,7 @@ class OrdersHostingListView(LoginRequiredMixin, ListView): return super(OrdersHostingListView, self).get_queryset() +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class OrdersHostingDeleteView(LoginRequiredMixin, DeleteView): login_url = reverse_lazy('hosting:login') success_url = reverse_lazy('hosting:orders') @@ -939,6 +953,7 @@ class VirtualMachinesPlanListView(LoginRequiredMixin, ListView): return context +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class CreateVirtualMachinesView(LoginRequiredMixin, View): template_name = "hosting/create_virtual_machine.html" login_url = reverse_lazy('hosting:login') @@ -1011,6 +1026,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): return redirect(reverse('hosting:payment')) +@cache_control(no_cache=True, must_revalidate=True, no_store=True) class VirtualMachineView(LoginRequiredMixin, View): template_name = "hosting/virtual_machine_detail.html" login_url = reverse_lazy('hosting:login')