| 
									
										
										
										
											2018-04-12 08:56:24 +05:30
										 |  |  | from cms.extensions import PageExtension | 
					
						
							|  |  |  | from cms.extensions.extension_pool import extension_pool | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  | from cms.models.fields import PlaceholderField | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | from cms.models.pluginmodel import CMSPlugin | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  | from django import forms | 
					
						
							| 
									
										
										
										
											2018-06-27 09:06:28 +02:00
										 |  |  | from django.conf import settings | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  | from django.contrib.postgres.fields import ArrayField | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  | from django.contrib.sites.models import Site | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | from django.db import models | 
					
						
							|  |  |  | from django.utils.safestring import mark_safe | 
					
						
							| 
									
										
										
										
											2018-03-23 04:36:40 +05:30
										 |  |  | from djangocms_text_ckeditor.fields import HTMLField | 
					
						
							| 
									
										
										
										
											2018-04-12 08:56:24 +05:30
										 |  |  | from filer.fields.file import FilerFileField | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | from filer.fields.image import FilerImageField | 
					
						
							| 
									
										
										
										
											2018-03-27 19:19:26 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 03:57:01 +05:30
										 |  |  | from datacenterlight.models import VMPricing, VMTemplate | 
					
						
							| 
									
										
										
										
											2018-04-09 21:18:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-27 19:19:26 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | class CMSIntegration(models.Model): | 
					
						
							|  |  |  |     name = models.CharField( | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  |         max_length=100, default='default', | 
					
						
							| 
									
										
										
										
											2018-03-27 21:04:44 +05:30
										 |  |  |         help_text=( | 
					
						
							|  |  |  |             'A unique name for the Integration. This name will be used to ' | 
					
						
							|  |  |  |             'fetch the Integration into pages' | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2018-03-27 19:19:26 +05:30
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:58:08 +05:30
										 |  |  |     footer_placeholder = PlaceholderField( | 
					
						
							|  |  |  |         'datacenterlight_footer', related_name='dcl-footer-placeholder+' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     navbar_placeholder = PlaceholderField( | 
					
						
							|  |  |  |         'datacenterlight_navbar', related_name='dcl-navbar-placeholder+' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  |     calculator_placeholder = PlaceholderField( | 
					
						
							|  |  |  |         'datacenterlight_calculator', | 
					
						
							|  |  |  |         related_name='dcl-calculator-placeholder+' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  |     domain = models.ForeignKey(Site, null=True, blank=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class Meta: | 
					
						
							|  |  |  |         unique_together = ('name', 'domain') | 
					
						
							| 
									
										
										
										
											2018-03-27 19:19:26 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-27 21:04:44 +05:30
										 |  |  |     def __str__(self): | 
					
						
							|  |  |  |         return self.name | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 08:56:24 +05:30
										 |  |  | class CMSFaviconExtension(PageExtension): | 
					
						
							|  |  |  |     favicon = FilerFileField(related_name="cms_favicon_image") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extension_pool.register(CMSFaviconExtension) | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 08:56:24 +05:30
										 |  |  | # Models for CMS Plugins | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | class DCLSectionPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     heading = models.CharField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=100, | 
					
						
							|  |  |  |         help_text='An optional heading for the Section', | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     content = HTMLField() | 
					
						
							|  |  |  |     TEXT_DIRECTIONS = ( | 
					
						
							|  |  |  |         ('left', 'Left'), | 
					
						
							|  |  |  |         ('right', 'Right') | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     text_direction = models.CharField( | 
					
						
							|  |  |  |         choices=TEXT_DIRECTIONS, max_length=10, default=True, | 
					
						
							|  |  |  |         help_text='The alignment of text in the section' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |     html_id = models.SlugField( | 
					
						
							|  |  |  |         blank=True, null=True, | 
					
						
							|  |  |  |         help_text=( | 
					
						
							|  |  |  |             'An optional html id for the Section. Required to set as target ' | 
					
						
							|  |  |  |             'of a link on page' | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     plain_heading = models.BooleanField( | 
					
						
							|  |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to keep the heading style simpler.' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     center_on_mobile = models.BooleanField( | 
					
						
							|  |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to center align content on small screens.' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     background_gradient = models.BooleanField( | 
					
						
							|  |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to add a gradient background to the section.' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_extra_classes(self): | 
					
						
							|  |  |  |         extra_classes = self.text_direction | 
					
						
							|  |  |  |         if self.center_on_mobile: | 
					
						
							|  |  |  |             extra_classes += ' section-sm-center' | 
					
						
							|  |  |  |         if self.background_gradient: | 
					
						
							|  |  |  |             extra_classes += ' section-gradient' | 
					
						
							| 
									
										
										
										
											2018-03-05 18:41:13 +05:30
										 |  |  |         if self.plain_heading: | 
					
						
							|  |  |  |             extra_classes += ' split-section-plain' | 
					
						
							| 
									
										
										
										
											2018-03-02 02:05:42 +05:30
										 |  |  |         return extra_classes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __str__(self): | 
					
						
							|  |  |  |         return '#' + self.html_id if self.html_id else str(self.pk) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLBannerListPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     heading = models.CharField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=100, | 
					
						
							|  |  |  |         help_text='An optional heading for the Section', | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     html_id = models.SlugField( | 
					
						
							|  |  |  |         blank=True, null=True, | 
					
						
							|  |  |  |         help_text=( | 
					
						
							|  |  |  |             'An optional html id for the Section. Required to set as target ' | 
					
						
							|  |  |  |             'of a link on page' | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __str__(self): | 
					
						
							|  |  |  |         return '#' + self.html_id if self.html_id else str(self.pk) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLBannerItemPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     content = HTMLField() | 
					
						
							|  |  |  |     banner_text = HTMLField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=100, | 
					
						
							|  |  |  |         help_text='Optional text to be shown as banner in other half.', | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     banner_image = FilerImageField( | 
					
						
							|  |  |  |         on_delete=models.CASCADE, null=True, blank=True, | 
					
						
							|  |  |  |         help_text='Optional image to be used in the banner in other half.' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     TEXT_DIRECTIONS = ( | 
					
						
							|  |  |  |         ('left', 'Left'), | 
					
						
							|  |  |  |         ('right', 'Right') | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     text_direction = models.CharField( | 
					
						
							|  |  |  |         choices=TEXT_DIRECTIONS, max_length=10, default=True, | 
					
						
							|  |  |  |         help_text='The alignment of text in the section' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_extra_classes(self): | 
					
						
							|  |  |  |         extra_classes = '' | 
					
						
							|  |  |  |         if self.text_direction == 'left': | 
					
						
							|  |  |  |             extra_classes = 'flex-row-rev' | 
					
						
							|  |  |  |         return extra_classes | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLLinkPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     target = models.CharField( | 
					
						
							|  |  |  |         max_length=100, | 
					
						
							|  |  |  |         help_text='Url or #id to navigate to' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     text = models.CharField( | 
					
						
							|  |  |  |         max_length=50, | 
					
						
							|  |  |  |         help_text='Text for the menu item' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     title = models.CharField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=100, | 
					
						
							|  |  |  |         help_text=( | 
					
						
							|  |  |  |             'Optional title text, that will be shown when a user ' | 
					
						
							|  |  |  |             'hovers over the link' | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     separator = models.BooleanField( | 
					
						
							|  |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to include a separator after the previous link' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  | class DCLNavbarPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     logo_light = FilerImageField( | 
					
						
							|  |  |  |         on_delete=models.CASCADE, null=True, blank=True, | 
					
						
							| 
									
										
										
										
											2018-03-17 12:51:44 +05:30
										 |  |  |         help_text='Logo to be used on transparent navbar', | 
					
						
							|  |  |  |         related_name="dcl_navbar_logo_light", | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  |     ) | 
					
						
							|  |  |  |     logo_dark = FilerImageField( | 
					
						
							|  |  |  |         on_delete=models.CASCADE, null=True, blank=True, | 
					
						
							| 
									
										
										
										
											2018-03-17 12:51:44 +05:30
										 |  |  |         help_text='Logo to be used on white navbar', | 
					
						
							|  |  |  |         related_name="dcl_navbar_logo_dark", | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  |     ) | 
					
						
							|  |  |  |     logo_url = models.URLField(max_length=300, null=True, blank=True) | 
					
						
							| 
									
										
										
										
											2018-03-20 02:34:20 +05:30
										 |  |  |     language_dropdown = models.BooleanField( | 
					
						
							|  |  |  |         default=True, | 
					
						
							|  |  |  |         help_text='Select to include the language selection dropdown.' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-09-25 22:29:54 +02:00
										 |  |  |     show_login_option = models.BooleanField( | 
					
						
							|  |  |  |         default=True, | 
					
						
							|  |  |  |         help_text='Uncheck this if you do not want to show login/dashboard.' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |     def get_logo_dark(self): | 
					
						
							| 
									
										
										
										
											2018-03-16 23:42:40 +05:30
										 |  |  |         # used only if atleast one logo exists | 
					
						
							| 
									
										
										
										
											2018-03-17 13:11:42 +05:30
										 |  |  |         return self.logo_dark.url if self.logo_dark else self.logo_light.url | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |     def get_logo_light(self): | 
					
						
							| 
									
										
										
										
											2018-03-16 23:42:40 +05:30
										 |  |  |         # used only if atleast one logo exists | 
					
						
							|  |  |  |         return self.logo_light.url if self.logo_light else self.logo_dark.url | 
					
						
							| 
									
										
										
										
											2018-03-16 15:29:24 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  | class DCLNavbarDropdownPluginModel(CMSPlugin): | 
					
						
							| 
									
										
										
										
											2018-03-01 01:38:56 +05:30
										 |  |  |     target = models.CharField( | 
					
						
							| 
									
										
										
										
											2018-03-05 20:00:31 +05:30
										 |  |  |         max_length=100, null=True, blank=True, | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |         help_text='Optional Url or #id to navigate on click' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     text = models.CharField( | 
					
						
							|  |  |  |         max_length=50, | 
					
						
							|  |  |  |         help_text='Text for the dropdown toggle' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLContactPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     heading = models.CharField(max_length=100, default="Contact", blank=True) | 
					
						
							|  |  |  |     organization_name = models.CharField( | 
					
						
							| 
									
										
										
										
											2018-03-27 00:54:44 +05:30
										 |  |  |         max_length=100, default="ungleich glarus ag", blank=True | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |     ) | 
					
						
							|  |  |  |     email = models.EmailField(max_length=200, default="info@ungleich.ch") | 
					
						
							|  |  |  |     address = models.CharField( | 
					
						
							|  |  |  |         max_length=100, default="In der Au 7, Schwanden 8762", blank=True | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     country = models.CharField( | 
					
						
							|  |  |  |         max_length=100, default="Switzerland", blank=True | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     form_header = models.CharField( | 
					
						
							|  |  |  |         max_length=100, default="Send us a message.", blank=True | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLFooterPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     copyright_label = models.CharField( | 
					
						
							| 
									
										
										
										
											2018-03-27 00:54:44 +05:30
										 |  |  |         max_length=100, default='ungleich glarus ag', blank=True, | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |         help_text='Name of the company alongside the copyright year' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLSectionIconPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     fontawesome_icon_name = models.CharField( | 
					
						
							|  |  |  |         max_length=30, | 
					
						
							|  |  |  |         help_text=mark_safe( | 
					
						
							|  |  |  |             'Name of the fontawesome icon to use. ' | 
					
						
							| 
									
										
										
										
											2018-03-01 00:22:51 +05:30
										 |  |  |             '<a href="https://fontawesome.com/v4.7.0/icons/" target="_blank">' | 
					
						
							|  |  |  |             'Refer docs.</a>' | 
					
						
							| 
									
										
										
										
											2018-02-28 04:09:19 +05:30
										 |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLSectionImagePluginModel(CMSPlugin): | 
					
						
							|  |  |  |     image = FilerImageField( | 
					
						
							|  |  |  |         on_delete=models.CASCADE, | 
					
						
							|  |  |  |         help_text=( | 
					
						
							|  |  |  |             'Image file to be used in section. Add multiple plugins ' | 
					
						
							|  |  |  |             'to add more than one image' | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     caption = models.CharField( | 
					
						
							|  |  |  |         max_length=100, null=True, blank=True, | 
					
						
							|  |  |  |         help_text='Optional caption for the image.' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DCLSectionPromoPluginModel(CMSPlugin): | 
					
						
							|  |  |  |     background_image = FilerImageField( | 
					
						
							|  |  |  |         on_delete=models.CASCADE, null=True, blank=True, | 
					
						
							|  |  |  |         help_text=('Optional background image for the Promo Section'), | 
					
						
							|  |  |  |         related_name="dcl_section_promo_promo", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     heading = models.CharField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=100, | 
					
						
							|  |  |  |         help_text='An optional heading for the Promo Section', | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     subheading = models.CharField( | 
					
						
							|  |  |  |         blank=True, null=True, max_length=200, | 
					
						
							|  |  |  |         help_text='An optional subheading for the Promo Section', | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     content = HTMLField() | 
					
						
							|  |  |  |     html_id = models.SlugField( | 
					
						
							|  |  |  |         blank=True, null=True, | 
					
						
							|  |  |  |         help_text=( | 
					
						
							|  |  |  |             'An optional html id for the Section. Required to set as target ' | 
					
						
							|  |  |  |             'of a link on page' | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     plain_heading = models.BooleanField( | 
					
						
							|  |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to keep the heading style simpler.' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-03-23 00:50:01 +05:30
										 |  |  |     text_center = models.BooleanField( | 
					
						
							| 
									
										
										
										
											2018-03-22 00:52:06 +05:30
										 |  |  |         default=False, | 
					
						
							|  |  |  |         help_text='Select to center align content on small screens.' | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __str__(self): | 
					
						
							|  |  |  |         return '#' + self.html_id if self.html_id else str(self.pk) | 
					
						
							| 
									
										
										
										
											2018-03-23 00:50:01 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |     def get_extra_classes(self): | 
					
						
							|  |  |  |         extra_classes = '' | 
					
						
							|  |  |  |         if self.text_center: | 
					
						
							|  |  |  |             extra_classes += ' text-center' | 
					
						
							|  |  |  |         if self.plain_heading: | 
					
						
							|  |  |  |             extra_classes += ' promo-section-plain' | 
					
						
							|  |  |  |         if self.background_image: | 
					
						
							|  |  |  |             extra_classes += ' promo-with-bg' | 
					
						
							|  |  |  |         return extra_classes | 
					
						
							| 
									
										
										
										
											2018-04-09 21:18:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  | class MultipleChoiceArrayField(ArrayField): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     A field that allows us to store an array of choices. | 
					
						
							|  |  |  |     Uses Django's Postgres ArrayField | 
					
						
							|  |  |  |     and a MultipleChoiceField for its formfield. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2018-06-27 09:06:28 +02:00
										 |  |  |     VMTemplateChoices = [] | 
					
						
							|  |  |  |     if settings.OPENNEBULA_DOMAIN != 'test_domain': | 
					
						
							|  |  |  |         VMTemplateChoices = list( | 
					
						
							|  |  |  |             ( | 
					
						
							|  |  |  |                 str(obj.opennebula_vm_template_id), | 
					
						
							|  |  |  |                 (obj.name + ' - ' + VMTemplate.IPV6.title() | 
					
						
							|  |  |  |                     if obj.vm_type == VMTemplate.IPV6 else obj.name | 
					
						
							|  |  |  |                  ) | 
					
						
							| 
									
										
										
										
											2018-06-24 10:28:17 +02:00
										 |  |  |              ) | 
					
						
							| 
									
										
										
										
											2018-06-27 09:06:28 +02:00
										 |  |  |             for obj in VMTemplate.objects.all() | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def formfield(self, **kwargs): | 
					
						
							|  |  |  |         defaults = { | 
					
						
							|  |  |  |             'form_class': forms.MultipleChoiceField, | 
					
						
							| 
									
										
										
										
											2018-06-24 10:28:17 +02:00
										 |  |  |             'choices': self.VMTemplateChoices, | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         defaults.update(kwargs) | 
					
						
							|  |  |  |         # Skip our parent's formfield implementation completely as we don't | 
					
						
							|  |  |  |         # care for it. | 
					
						
							|  |  |  |         # pylint:disable=bad-super-call | 
					
						
							|  |  |  |         return super(ArrayField, self).formfield(**defaults) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-25 14:52:25 +05:30
										 |  |  | class DCLCalculatorPluginModel(CMSPlugin): | 
					
						
							| 
									
										
										
										
											2018-04-09 21:18:18 +02:00
										 |  |  |     pricing = models.ForeignKey( | 
					
						
							|  |  |  |         VMPricing, | 
					
						
							| 
									
										
										
										
											2018-04-15 23:18:22 +02:00
										 |  |  |         related_name="dcl_custom_pricing_vm_pricing", | 
					
						
							| 
									
										
										
										
											2018-04-09 21:18:18 +02:00
										 |  |  |         help_text='Choose a pricing that will be associated with this ' | 
					
						
							|  |  |  |                   'Calculator' | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-05-24 03:57:01 +05:30
										 |  |  |     vm_type = models.CharField( | 
					
						
							|  |  |  |         max_length=50, choices=VMTemplate.VM_TYPE_CHOICES, | 
					
						
							|  |  |  |         default=VMTemplate.PUBLIC | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-06-24 09:08:22 +02:00
										 |  |  |     vm_templates_to_show = MultipleChoiceArrayField( | 
					
						
							|  |  |  |         base_field=models.CharField( | 
					
						
							|  |  |  |             blank=True, | 
					
						
							|  |  |  |             max_length=256, | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         default=list, | 
					
						
							|  |  |  |         blank=True, | 
					
						
							|  |  |  |         help_text="Recommended: If you wish to show all templates of the " | 
					
						
							|  |  |  |                   "corresponding VM Type (public/ipv6only), please do not " | 
					
						
							|  |  |  |                   "select any of the items in the above field. " | 
					
						
							|  |  |  |                   "This will allow any new template(s) added " | 
					
						
							|  |  |  |                   "in the backend to be automatically listed in this " | 
					
						
							|  |  |  |                   "calculator instance." | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-09-27 22:33:24 +02:00
										 |  |  |     default_selected_template = models.CharField( | 
					
						
							| 
									
										
										
										
											2018-09-27 22:14:42 +02:00
										 |  |  |         default="Devuan Ascii", | 
					
						
							| 
									
										
										
										
											2018-09-27 22:09:11 +02:00
										 |  |  |         null=True, | 
					
						
							|  |  |  |         max_length=128, | 
					
						
							|  |  |  |         help_text="Write the name of the template that you need selected as" | 
					
						
							|  |  |  |                   " default when the calculator loads" | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2018-09-22 06:44:37 +02:00
										 |  |  |     enable_512mb_ram = models.BooleanField(default=False) |