Compare commits

...

4 commits

Author SHA1 Message Date
PCoder
5df23fb56a Fix button location and make things dynamic 2019-11-27 17:45:49 +05:30
PCoder
5fa0a645c1 Add template file 2019-11-27 12:55:39 +05:30
PCoder
2b8bf3f1f2 Add migration 2019-11-27 12:55:19 +05:30
PCoder
249769f732 Add generic header plugin & model 2019-11-27 12:54:58 +05:30
4 changed files with 117 additions and 1 deletions

View file

@ -13,6 +13,7 @@ from filer.fields.file import FilerFileField
from filer.fields.image import FilerImageField
from datacenterlight.models import VMPricing, VMTemplate
from hosting.models import GenericProduct
class CMSIntegration(models.Model):
@ -362,3 +363,22 @@ class DCLCalculatorPluginModel(CMSPlugin):
" default when the calculator loads"
)
enable_512mb_ram = models.BooleanField(default=False)
class GenericProductHeaderPluginModel(CMSPlugin):
generic_product = models.ForeignKey(
GenericProduct,
related_name="dcl_generic_product_header_plugin",
help_text='Choose or create a generic product that you want to link '
'with this header',
null=True,
blank=True
)
header_text = models.TextField(
help_text="Give a header text"
)
header_background_color = models.CharField(default="3c4e68", max_length=10)
buy_button_text = models.TextField(
default="Buy now",
help_text="Input the text to be shown on the buy button"
)

View file

@ -1,3 +1,5 @@
from django.core.urlresolvers import reverse
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
@ -6,7 +8,8 @@ from .cms_models import (
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
DCLSectionPluginModel, DCLNavbarPluginModel,
DCLSectionPromoPluginModel, DCLCalculatorPluginModel
DCLSectionPromoPluginModel, DCLCalculatorPluginModel,
GenericProductHeaderPluginModel
)
from .models import VMTemplate
from datacenterlight.utils import clear_all_session_vars
@ -178,3 +181,23 @@ class DCLFooterPlugin(CMSPluginBase):
cache = False
allow_children = True
child_classes = ['DCLLinkPlugin']
@plugin_pool.register_plugin
class GenericProductHeaderPlugin(CMSPluginBase):
module = "Datacenterlight"
name = "Generic Product Header Plugin"
model = GenericProductHeaderPluginModel
render_template = "datacenterlight/cms/generic_product_header.html"
cache = False
def render(self, context, instance, placeholder):
product_url = None
if instance.generic_product:
product_url = reverse(
'show_product',
kwargs={'product_slug': instance.generic_product.product_slug}
)
context["product_url"] = product_url
context["instance"] = instance
return context

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2019-11-27 07:18
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('hosting', '0058_genericproduct_product_subscription_interval'),
('cms', '0014_auto_20160404_1908'),
('datacenterlight', '0029_auto_20190420_1022'),
]
operations = [
migrations.CreateModel(
name='GenericProductHeaderPluginModel',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
('header_text', models.TextField(help_text='Give a header text')),
('header_background_color', models.CharField(default='3c4e68', max_length=10)),
('buy_button_text', models.TextField(default='Buy now', help_text='Input the text to be shown on the buy button')),
('generic_product', models.ForeignKey(blank=True, help_text='Choose or create a generic product that you want to link with this header', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dcl_generic_product_header_plugin', to='hosting.GenericProduct')),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
]

View file

@ -0,0 +1,41 @@
{% load cms_tags %}
<style>
.head-wrapper {
display: table;
width: 100%;
height: 85vh;
text-align: center;
background-color: #{{instance.header_background_color}};
}
.head-slide {
display: table-cell;
vertical-align: middle;
color: #fff;
font-size: 85px;
position: relative;
}
@media (min-width: 768px) {
.head-slide .btn-trans {
padding: 8px 15px;
min-width: 175px;
letter-spacing: 1px;
font-size: 0.25em;
}
}
.head-slide .btn-trans {
position: absolute;
bottom: 15%;
right: 5%;
font-size: 0.2em;
}
</style>
<div>
<div class="head-wrapper">
<div class="head-slide">
{{ instance.header_text }}
{% if product_url %}
<a class="btn btn-trans page-scroll url" href="{{product_url}}">{{instance.buy_button_text}}</a>
{% endif %}
</div>
</div>
</div>