Add generic header plugin & model
This commit is contained in:
parent
3d28b17c71
commit
249769f732
2 changed files with 44 additions and 1 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue