Add generic header plugin & model
This commit is contained in:
parent
3d28b17c71
commit
249769f732
2 changed files with 44 additions and 1 deletions
|
@ -13,6 +13,7 @@ from filer.fields.file import FilerFileField
|
||||||
from filer.fields.image import FilerImageField
|
from filer.fields.image import FilerImageField
|
||||||
|
|
||||||
from datacenterlight.models import VMPricing, VMTemplate
|
from datacenterlight.models import VMPricing, VMTemplate
|
||||||
|
from hosting.models import GenericProduct
|
||||||
|
|
||||||
|
|
||||||
class CMSIntegration(models.Model):
|
class CMSIntegration(models.Model):
|
||||||
|
@ -362,3 +363,22 @@ class DCLCalculatorPluginModel(CMSPlugin):
|
||||||
" default when the calculator loads"
|
" default when the calculator loads"
|
||||||
)
|
)
|
||||||
enable_512mb_ram = models.BooleanField(default=False)
|
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"
|
||||||
|
)
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from cms.plugin_base import CMSPluginBase
|
from cms.plugin_base import CMSPluginBase
|
||||||
from cms.plugin_pool import plugin_pool
|
from cms.plugin_pool import plugin_pool
|
||||||
|
|
||||||
|
@ -6,7 +8,8 @@ from .cms_models import (
|
||||||
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
|
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
|
||||||
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
|
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
|
||||||
DCLSectionPluginModel, DCLNavbarPluginModel,
|
DCLSectionPluginModel, DCLNavbarPluginModel,
|
||||||
DCLSectionPromoPluginModel, DCLCalculatorPluginModel
|
DCLSectionPromoPluginModel, DCLCalculatorPluginModel,
|
||||||
|
GenericProductHeaderPluginModel
|
||||||
)
|
)
|
||||||
from .models import VMTemplate
|
from .models import VMTemplate
|
||||||
from datacenterlight.utils import clear_all_session_vars
|
from datacenterlight.utils import clear_all_session_vars
|
||||||
|
@ -178,3 +181,23 @@ class DCLFooterPlugin(CMSPluginBase):
|
||||||
cache = False
|
cache = False
|
||||||
allow_children = True
|
allow_children = True
|
||||||
child_classes = ['DCLLinkPlugin']
|
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
|
Loading…
Add table
Reference in a new issue