| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | from cms.plugin_base import CMSPluginBase | 
					
						
							|  |  |  | from cms.plugin_pool import plugin_pool | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .cms_models import ( | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel, | 
					
						
							|  |  |  |     DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel, | 
					
						
							|  |  |  |     DCLSectionIconPluginModel, DCLSectionImagePluginModel, | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |     DCLSectionPluginModel, DCLNavbarPluginModel, | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |     DCLSectionPromoPluginModel, DCLCalculatorPluginModel | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2018-04-25 17:26:31 +05:30
										 |  |  | from .models import VMTemplate | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | class DCLSectionPlugin(CMSPluginBase): | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Section Plugin" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     model = DCLSectionPluginModel | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     render_template = "datacenterlight/cms/section.html" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     cache = False | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     allow_children = True | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |     child_classes = [ | 
					
						
							|  |  |  |         'DCLSectionIconPlugin', 'DCLSectionImagePlugin', | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |         'DCLSectionPromoPlugin', 'UngleichHTMLPlugin', 'DCLCalculatorPlugin' | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |     ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def render(self, context, instance, placeholder): | 
					
						
							|  |  |  |         context = super(DCLSectionPlugin, self).render( | 
					
						
							|  |  |  |             context, instance, placeholder | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2018-03-23 03:22:29 +05:30
										 |  |  |         context['children_to_side'] = [] | 
					
						
							|  |  |  |         context['children_to_content'] = [] | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |         context['children_calculator'] = [] | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |         if instance.child_plugin_instances is not None: | 
					
						
							| 
									
										
										
										
											2018-03-23 01:27:51 +05:30
										 |  |  |             right_children = [ | 
					
						
							|  |  |  |                 'DCLSectionImagePluginModel', | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |                 'DCLSectionIconPluginModel', | 
					
						
							| 
									
										
										
										
											2018-03-23 01:27:51 +05:30
										 |  |  |             ] | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |             for child in instance.child_plugin_instances: | 
					
						
							| 
									
										
										
										
											2018-03-23 01:27:51 +05:30
										 |  |  |                 if child.__class__.__name__ in right_children: | 
					
						
							| 
									
										
										
										
											2018-03-23 03:22:29 +05:30
										 |  |  |                     context['children_to_side'].append(child) | 
					
						
							| 
									
										
										
										
											2018-04-25 15:08:28 +05:30
										 |  |  |                 elif child.plugin_type == 'DCLCalculatorPlugin': | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |                     context['children_calculator'].append(child) | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |                 else: | 
					
						
							| 
									
										
										
										
											2018-03-23 03:22:29 +05:30
										 |  |  |                     context['children_to_content'].append(child) | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |         return context | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | class DCLSectionIconPlugin(CMSPluginBase): | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Section Icon Plugin" | 
					
						
							|  |  |  |     model = DCLSectionIconPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/section_icon.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     require_parent = True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLSectionImagePlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							|  |  |  |     name = "DCL Section Image Plugin" | 
					
						
							|  |  |  |     model = DCLSectionImagePluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/section_image.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     require_parent = True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLSectionPromoPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							|  |  |  |     name = "DCL Section Promo Plugin" | 
					
						
							|  |  |  |     model = DCLSectionPromoPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/section_promo.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLCalculatorPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |     name = "DCL Calculator Plugin" | 
					
						
							|  |  |  |     model = DCLCalculatorPluginModel | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     render_template = "datacenterlight/cms/calculator.html" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     cache = False | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |     require_parent = True | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-05 18:41:13 +05:30
										 |  |  |     def render(self, context, instance, placeholder): | 
					
						
							|  |  |  |         context = super(DCLCalculatorPlugin, self).render( | 
					
						
							|  |  |  |             context, instance, placeholder | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  |         ids = instance.vm_templates_to_show | 
					
						
							| 
									
										
										
										
											2018-06-13 11:53:43 +02:00
										 |  |  |         if ids: | 
					
						
							|  |  |  |             context['templates'] = VMTemplate.objects.filter( | 
					
						
							|  |  |  |                 vm_type=instance.vm_type | 
					
						
							|  |  |  |             ).filter(opennebula_vm_template_id__in=ids) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             context['templates'] = VMTemplate.objects.filter( | 
					
						
							|  |  |  |                 vm_type=instance.vm_type | 
					
						
							|  |  |  |             ) | 
					
						
							| 
									
										
										
										
											2018-03-05 18:41:13 +05:30
										 |  |  |         return context | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | class DCLBannerListPlugin(CMSPluginBase): | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Banner List Plugin" | 
					
						
							|  |  |  |     model = DCLBannerListPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/banner_list.html" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     cache = False | 
					
						
							|  |  |  |     allow_children = True | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     child_classes = ['DCLBannerItemPlugin'] | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | class DCLBannerItemPlugin(CMSPluginBase): | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Banner Item Plugin" | 
					
						
							|  |  |  |     model = DCLBannerItemPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/banner_item.html" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     cache = False | 
					
						
							|  |  |  |     require_parent = True | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     parent_classes = ['DCLBannerListPlugin'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLNavbarPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							|  |  |  |     name = "DCL Navbar Plugin" | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  |     model = DCLNavbarPluginModel | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     render_template = "datacenterlight/cms/navbar.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     allow_children = True | 
					
						
							|  |  |  |     child_classes = ['DCLLinkPlugin', 'DCLNavbarDropdownPlugin'] | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLNavbarDropdownPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Navbar Dropdown Plugin" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     model = DCLNavbarDropdownPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/navbar_dropdown.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     allow_children = True | 
					
						
							|  |  |  |     child_classes = ['DCLLinkPlugin'] | 
					
						
							|  |  |  |     require_parent = True | 
					
						
							|  |  |  |     parent_classes = ['DCLNavbarPlugin'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLLinkPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							|  |  |  |     name = "DCL Link Plugin" | 
					
						
							|  |  |  |     model = DCLLinkPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/link.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     require_parent = True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLContactPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Contact Plugin" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     model = DCLContactPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/contact.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @plugin_pool.register_plugin | 
					
						
							|  |  |  | class DCLFooterPlugin(CMSPluginBase): | 
					
						
							|  |  |  |     module = "Datacenterlight" | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     name = "DCL Footer Plugin" | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     model = DCLFooterPluginModel | 
					
						
							|  |  |  |     render_template = "datacenterlight/cms/footer.html" | 
					
						
							|  |  |  |     cache = False | 
					
						
							|  |  |  |     allow_children = True | 
					
						
							|  |  |  |     child_classes = ['DCLLinkPlugin'] |