From ffe4eb41239a019b9a90d9f3eecce9a66baffa2e Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 10:25:21 +0200 Subject: [PATCH 01/11] Use REDIRECT_TO_CMS and MULTISITE_CMS_FALLBACK to construct /hosting footer urls --- .../templates/datacenterlight/includes/_footer.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/includes/_footer.html b/datacenterlight/templates/datacenterlight/includes/_footer.html index 7d27eaef..4be5b928 100644 --- a/datacenterlight/templates/datacenterlight/includes/_footer.html +++ b/datacenterlight/templates/datacenterlight/includes/_footer.html @@ -4,15 +4,15 @@
From 399c91d636dbe775ccdc00614a74484c6d7dd91c Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 12:51:40 +0200 Subject: [PATCH 02/11] Add HostingContextMixin that sets the REDIRECT_TO_CMS and MULTISITE_CMS_FALLBACK urls --- hosting/mixins.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hosting/mixins.py b/hosting/mixins.py index 666cbcbe..7ef05581 100644 --- a/hosting/mixins.py +++ b/hosting/mixins.py @@ -1,4 +1,7 @@ +from cms.models.pagemodel import Page from django.shortcuts import redirect +from django.conf import settings +from django.contrib.sites.models import Site from django.core.urlresolvers import reverse from opennebula_api.serializers import VirtualMachineTemplateSerializer @@ -24,3 +27,17 @@ class ProcessVMSelectionMixin(object): request.session['next'] = reverse('hosting:payment') return redirect(reverse('hosting:login')) return redirect(reverse('hosting:payment')) + + +class HostingContextMixin(object): + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['REDIRECT_TO_CMS'] = (Page + .objects + .filter(site_id=Site + .objects + .get_current() + .id) + .count()) + context['MULTISITE_CMS_FALLBACK'] = settings.MULTISITE_CMS_FALLBACK + return context From f911d6b4035e068701d4563025811ee5cb68eb64 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 12:53:53 +0200 Subject: [PATCH 03/11] Add HostingContextMixin to various hosting views --- hosting/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 8e7380fb..7c11e1f6 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -54,7 +54,7 @@ from .forms import ( HostingUserSignupForm, HostingUserLoginForm, UserHostingKeyForm, generate_ssh_key_name ) -from .mixins import ProcessVMSelectionMixin +from .mixins import ProcessVMSelectionMixin, HostingContextMixin from .models import ( HostingOrder, HostingBill, HostingPlan, UserHostingKey, VMDetail ) @@ -213,13 +213,13 @@ class IndexView(View): return render(request, self.template_name, context) -class LoginView(LoginViewMixin): +class LoginView(HostingContextMixin, LoginViewMixin): template_name = "hosting/login.html" form_class = HostingUserLoginForm success_url = reverse_lazy('hosting:dashboard') -class SignupView(CreateView): +class SignupView(HostingContextMixin, CreateView): template_name = 'hosting/signup.html' form_class = HostingUserSignupForm model = CustomUser @@ -248,7 +248,7 @@ class SignupView(CreateView): return super(SignupView, self).get(request, *args, **kwargs) -class SignupValidateView(TemplateView): +class SignupValidateView(HostingContextMixin, TemplateView): template_name = "hosting/signup_validate.html" def get_context_data(self, **kwargs): @@ -272,7 +272,7 @@ class SignupValidateView(TemplateView): return context -class SignupValidatedView(SignupValidateView): +class SignupValidatedView(HostingContextMixin, SignupValidateView): template_name = "hosting/signup_validate.html" def get_context_data(self, **kwargs): @@ -325,7 +325,8 @@ class SignupValidatedView(SignupValidateView): return super(SignupValidatedView, self).get(request, *args, **kwargs) -class ResendActivationEmailView(ResendActivationLinkViewMixin): +class ResendActivationEmailView(HostingContextMixin, + ResendActivationLinkViewMixin): template_name = 'hosting/resend_activation_link.html' form_class = ResendActivationEmailForm success_url = reverse_lazy('hosting:login') @@ -333,7 +334,7 @@ class ResendActivationEmailView(ResendActivationLinkViewMixin): email_template_name = 'user_activation' -class PasswordResetView(PasswordResetViewMixin): +class PasswordResetView(HostingContextMixin, PasswordResetViewMixin): site = 'dcl' template_name = 'hosting/reset_password.html' form_class = PasswordResetRequestForm @@ -341,7 +342,8 @@ class PasswordResetView(PasswordResetViewMixin): template_email_path = 'hosting/emails/' -class PasswordResetConfirmView(PasswordResetConfirmViewMixin): +class PasswordResetConfirmView(HostingContextMixin, + PasswordResetConfirmViewMixin): template_name = 'hosting/confirm_reset_password.html' success_url = reverse_lazy('hosting:login') From c6e3963303728b98ac2b4dcf1fd30ca7d7c164d4 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 12:55:32 +0200 Subject: [PATCH 04/11] Update footer links in dcl _footer.html --- .../templates/datacenterlight/includes/_footer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/includes/_footer.html b/datacenterlight/templates/datacenterlight/includes/_footer.html index 4be5b928..1fb1b963 100644 --- a/datacenterlight/templates/datacenterlight/includes/_footer.html +++ b/datacenterlight/templates/datacenterlight/includes/_footer.html @@ -4,11 +4,11 @@
  • - {% trans "Home" %} + {% trans "Home" %}
  • - {% trans "Contact" %} + {% trans "Contact" %}
  • From 178ff8da382b687046a3581f83e381442c1be7ea Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 13:13:53 +0200 Subject: [PATCH 05/11] CMS home page can now be accessed at /cms/ for all sites --- datacenterlight/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/urls.py b/datacenterlight/urls.py index af8e76f2..006e7fc3 100644 --- a/datacenterlight/urls.py +++ b/datacenterlight/urls.py @@ -13,7 +13,7 @@ urlpatterns = [ url(r'^g/$', IndexView.as_view(), name='index_g'), url(r'^f/$', IndexView.as_view(), name='index_f'), url(r'^l/$', IndexView.as_view(), name='index_l'), - url(r'^new/$', RedirectView.as_view(url='/cms/datacenterlight/'), + url(r'^new/$', RedirectView.as_view(url='/cms/'), name='cms_index'), url(r'^whydatacenterlight/?$', WhyDataCenterLightView.as_view(), name='whydatacenterlight'), From 7b1cb975df344c8739b3c86ccf3c0621cee09847 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 13:15:44 +0200 Subject: [PATCH 06/11] Fix Method Resolution Order --- hosting/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 7c11e1f6..59239b96 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -272,7 +272,7 @@ class SignupValidateView(HostingContextMixin, TemplateView): return context -class SignupValidatedView(HostingContextMixin, SignupValidateView): +class SignupValidatedView(SignupValidateView, HostingContextMixin): template_name = "hosting/signup_validate.html" def get_context_data(self, **kwargs): From 698cf7f1ee3190ca7213607add6b4f58ff77ba67 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 7 Apr 2018 13:16:36 +0200 Subject: [PATCH 07/11] Fix link in signup message --- hosting/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 59239b96..6e143760 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -307,7 +307,7 @@ class SignupValidatedView(SignupValidateView, HostingContextMixin): email.send() else: home_url = 'Data Center Light' message = '{sorry_message}
    {go_back_to} {hurl}'.format( sorry_message=_("Sorry. Your request is invalid."), From c3dff3155e13b9cbc4df5318069dcd5a67171af3 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 8 Apr 2018 00:29:39 +0200 Subject: [PATCH 08/11] Redirect the contact link to dcl always --- datacenterlight/templates/datacenterlight/includes/_footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/templates/datacenterlight/includes/_footer.html b/datacenterlight/templates/datacenterlight/includes/_footer.html index 1fb1b963..9583271e 100644 --- a/datacenterlight/templates/datacenterlight/includes/_footer.html +++ b/datacenterlight/templates/datacenterlight/includes/_footer.html @@ -8,7 +8,7 @@
  • - {% trans "Contact" %} + {% trans "Contact" %}
  • From 30d7785700c597507327e5914f5fa8230325b101 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 8 Apr 2018 08:36:00 +0200 Subject: [PATCH 09/11] Redirect to DCL home on hosting footer for all domains --- datacenterlight/templates/datacenterlight/includes/_footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/templates/datacenterlight/includes/_footer.html b/datacenterlight/templates/datacenterlight/includes/_footer.html index 9583271e..c4950807 100644 --- a/datacenterlight/templates/datacenterlight/includes/_footer.html +++ b/datacenterlight/templates/datacenterlight/includes/_footer.html @@ -4,7 +4,7 @@
    • - {% trans "Home" %} + {% trans "Home" %}
    • From 5dd29bb09ec6156fc574f641ff2b0e4e664f8084 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 9 Apr 2018 03:02:50 +0530 Subject: [PATCH 10/11] Update mixins.py --- hosting/mixins.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hosting/mixins.py b/hosting/mixins.py index 7ef05581..bd80fc32 100644 --- a/hosting/mixins.py +++ b/hosting/mixins.py @@ -32,12 +32,5 @@ class ProcessVMSelectionMixin(object): class HostingContextMixin(object): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['REDIRECT_TO_CMS'] = (Page - .objects - .filter(site_id=Site - .objects - .get_current() - .id) - .count()) context['MULTISITE_CMS_FALLBACK'] = settings.MULTISITE_CMS_FALLBACK return context From a306f59327c6831b0017470d9de54f42a78fd262 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 9 Apr 2018 03:12:41 +0530 Subject: [PATCH 11/11] Update mixins.py --- hosting/mixins.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/hosting/mixins.py b/hosting/mixins.py index bd80fc32..5fb83383 100644 --- a/hosting/mixins.py +++ b/hosting/mixins.py @@ -1,7 +1,5 @@ -from cms.models.pagemodel import Page from django.shortcuts import redirect from django.conf import settings -from django.contrib.sites.models import Site from django.core.urlresolvers import reverse from opennebula_api.serializers import VirtualMachineTemplateSerializer