Scott Baker | 37b4790 | 2014-09-02 14:37:41 -0700 | [diff] [blame] | 1 | import os |
| 2 | import socket |
| 3 | from django.db import models |
Scott Baker | 7a61dc4 | 2014-09-02 17:08:20 -0700 | [diff] [blame^] | 4 | from core.models import PlCoreBase, Deployment |
Scott Baker | 37b4790 | 2014-09-02 14:37:41 -0700 | [diff] [blame] | 5 | from django.contrib.contenttypes.models import ContentType |
| 6 | from django.contrib.contenttypes import generic |
| 7 | |
| 8 | class Flavor(PlCoreBase): |
| 9 | name = models.CharField(max_length=32, help_text="name of this flavor, as displayed to users") |
| 10 | description = models.CharField(max_length=1024, blank=True, null=True) |
| 11 | flavor = models.CharField(max_length=32, help_text="flavor string used to configure deployments") |
| 12 | deployments = models.ManyToManyField(Deployment, blank=True, related_name="flavors") |
| 13 | order = models.IntegerField(default=0, help_text="used to order flavors when displayed in a list") |
| 14 | default = models.BooleanField(default=False, help_text="make this a default flavor to use when creating new instances") |
| 15 | |
| 16 | class Meta: |
| 17 | app_label = "core" |
| 18 | ordering = ('order', 'name') |
| 19 | |
| 20 | def __unicode__(self): return u'%s' % (self.name) |
| 21 | |
| 22 | @staticmethod |
| 23 | def select_by_user(user): |
| 24 | return Flavor.objects.all() |
| 25 | |
| 26 | """ FlavorParameterType and FlavorParameter are below for completeness sake, |
| 27 | waiting for the day we might want to add parameters to flavors. |
| 28 | |
| 29 | class FlavorParameterType(PlCoreBase): |
| 30 | name = models.SlugField(help_text="The name of this parameter", max_length=128) |
| 31 | description = models.CharField(max_length=1024) |
| 32 | |
| 33 | def __unicode__(self): return u'%s' % (self.name) |
| 34 | |
| 35 | class FlavorParameter(PlCoreBase): |
| 36 | parameter = models.ForeignKey(FlavorParameterType, related_name="parameters", help_text="The type of the parameter") |
| 37 | value = models.CharField(help_text="The value of this parameter", max_length=1024) |
| 38 | |
| 39 | flavor = models.ForeignKey(Flavor) |
| 40 | |
| 41 | def __unicode__(self): |
| 42 | return self.parameter.name |
| 43 | |
| 44 | """ |
| 45 | |