From 883118e0503c630483265f2b4e40fed1123994bd Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 5 Mar 2018 18:41:13 +0530 Subject: [PATCH] whydcl section style fix, footer style fix --- datacenterlight/cms_models.py | 2 + datacenterlight/cms_plugins.py | 8 ++++ .../static/datacenterlight/css/cms.css | 5 ++- .../datacenterlight/css/landing-page.css | 28 +++++++++--- .../datacenterlight/cms/section.html | 30 ++++++------- .../includes/_calculator_form.html | 2 +- datacenterlight/views.py | 44 +++++++++++-------- 7 files changed, 76 insertions(+), 43 deletions(-) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 8438e515..a4406c04 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -47,6 +47,8 @@ class DCLSectionPluginModel(CMSPlugin): extra_classes += ' section-sm-center' if self.background_gradient: extra_classes += ' section-gradient' + if self.plain_heading: + extra_classes += ' split-section-plain' return extra_classes def __str__(self): diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index c3f2fb10..70ecfaa2 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -8,6 +8,7 @@ from .cms_models import ( DCLSectionIconPluginModel, DCLSectionImagePluginModel, DCLSectionPluginModel, ) +from .models import VMTemplate @plugin_pool.register_plugin @@ -49,6 +50,13 @@ class DCLCalculatorPlugin(CMSPluginBase): render_template = "datacenterlight/cms/calculator.html" cache = False + def render(self, context, instance, placeholder): + context = super(DCLCalculatorPlugin, self).render( + context, instance, placeholder + ) + context['templates'] = VMTemplate.objects.all() + return context + @plugin_pool.register_plugin class DCLBannerListPlugin(CMSPluginBase): diff --git a/datacenterlight/static/datacenterlight/css/cms.css b/datacenterlight/static/datacenterlight/css/cms.css index 87479a1e..d36a7876 100644 --- a/datacenterlight/static/datacenterlight/css/cms.css +++ b/datacenterlight/static/datacenterlight/css/cms.css @@ -52,7 +52,10 @@ /* only for editing mode */ .section-figure .cms-plugin { - padding: 10px; flex-basis: 50%; flex-grow: 1; +} + +.split-section-plain .section-figure .cms-plugin { + flex-grow: 0; } \ No newline at end of file diff --git a/datacenterlight/static/datacenterlight/css/landing-page.css b/datacenterlight/static/datacenterlight/css/landing-page.css index 66ca4806..90d959a3 100755 --- a/datacenterlight/static/datacenterlight/css/landing-page.css +++ b/datacenterlight/static/datacenterlight/css/landing-page.css @@ -436,11 +436,29 @@ textarea { } .section-figure .section-image { - padding: 10px; + padding: 25px 15px; flex-basis: 50%; flex-grow: 1; } +.split-section-plain .section-figure .section-image { + flex-grow: 0; +} + +.split-section-plain .section-figure { + justify-content: flex-start; +} + +@media (min-width: 768px) { + .split-section-plain .split-figure { + width: 41.66666667%; + } + + .split-section-plain .split-text { + width: 58.33333333%; + } +} + .section-image img { margin: auto; } @@ -1236,12 +1254,12 @@ footer .dcl-link-separator::before { content: ""; position: absolute; display: inline-block; - top: 8px; + top: 9px; bottom: 0; - left: -3px; + left: -2px; right: 0; - width: 4px; - height: 4px; + width: 2px; + height: 2px; border-radius: 100%; background: #777; } diff --git a/datacenterlight/templates/datacenterlight/cms/section.html b/datacenterlight/templates/datacenterlight/cms/section.html index 7743b5b9..ed399ebc 100644 --- a/datacenterlight/templates/datacenterlight/cms/section.html +++ b/datacenterlight/templates/datacenterlight/cms/section.html @@ -3,24 +3,20 @@
-
- {% block section-feature %} -
- {% for plugin in instance.child_plugin_instances %} - {% render_plugin plugin %} - {% endfor %} -
- {% endblock section-feature %} +
+
+ {% for plugin in instance.child_plugin_instances %} + {% render_plugin plugin %} + {% endfor %} +
-
-
-
-

{{ instance.heading }}

-
-
-
- {{ instance.content }} -
+
+
+

{{ instance.heading }}

+
+
+
+ {{ instance.content }}
diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index 1892c638..f38150bb 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -1,5 +1,5 @@ {% load staticfiles i18n%} -
+ {% csrf_token %}

{% trans "VM hosting" %}

diff --git a/datacenterlight/views.py b/datacenterlight/views.py index c67b436a..faa1d59c 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -112,37 +112,41 @@ class IndexView(CreateView): storage_field = forms.IntegerField(validators=[self.validate_storage]) template_id = int(request.POST.get('config')) template = VMTemplate.objects.filter( - opennebula_vm_template_id=template_id).first() + opennebula_vm_template_id=template_id + ).first() template_data = VMTemplateSerializer(template).data + referer_url = request.META['HTTP_REFERER'] try: cores = cores_field.clean(cores) except ValidationError as err: msg = '{} : {}.'.format(cores, str(err)) - messages.add_message(self.request, messages.ERROR, msg, - extra_tags='cores') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + messages.add_message( + self.request, messages.ERROR, msg, extra_tags='cores' + ) + return HttpResponseRedirect(referer_url + "#order_form") try: memory = memory_field.clean(memory) except ValidationError as err: msg = '{} : {}.'.format(memory, str(err)) - messages.add_message(self.request, messages.ERROR, msg, - extra_tags='memory') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + messages.add_message( + self.request, messages.ERROR, msg, extra_tags='memory' + ) + return HttpResponseRedirect(referer_url + "#order_form") try: storage = storage_field.clean(storage) except ValidationError as err: msg = '{} : {}.'.format(storage, str(err)) - messages.add_message(self.request, messages.ERROR, msg, - extra_tags='storage') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") - amount_to_be_charged = get_vm_price(cpu=cores, memory=memory, - disk_size=storage) + messages.add_message( + self.request, messages.ERROR, msg, extra_tags='storage' + ) + return HttpResponseRedirect(referer_url + "#order_form") + + amount_to_be_charged = get_vm_price( + cpu=cores, memory=memory, disk_size=storage + ) specs = { 'cpu': cores, 'memory': memory, @@ -161,8 +165,9 @@ class IndexView(CreateView): def get_context_data(self, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) context.update({ - 'base_url': "{0}://{1}".format(self.request.scheme, - self.request.get_host()), + 'base_url': "{0}://{1}".format( + self.request.scheme, self.request.get_host() + ), 'contact_form': ContactForm }) return context @@ -231,8 +236,9 @@ class PaymentOrderView(FormView): def post(self, request, *args, **kwargs): if 'login_form' in request.POST: - login_form = HostingUserLoginForm(data=request.POST, - prefix='login_form') + login_form = HostingUserLoginForm( + data=request.POST, prefix='login_form' + ) if login_form.is_valid(): email = login_form.cleaned_data.get('email') password = login_form.cleaned_data.get('password')