class ModelTest(models.Model): bools = models.BooleanField() chars = models.CharField(max_length=20) dates = models.DateField() datetimes = models.DateTimeField() decimals = models.DecimalField() floats = models.FloatField() ints = models.IntegerField() nullbools = models.NullBooleanField() posints = models.PositiveIntegerField() possmalls = models.PositiveSmallIntegerField() slugs = models.SlugField() smallints = models.SmallIntegerField() texts = models.TextField() texts2 = models.TextField() times = models.TimeField() urls = models.URLField()
class GroupEntity(GWSModel): UWNETID_TYPE = "uwnetid" EPPN_TYPE = "eppn" GROUP_TYPE = "group" DNS_TYPE = "dns" SET_TYPE = "set" UWWI_TYPE = "uwwi" TYPE_CHOICES = ( (UWNETID_TYPE, "UWNetID"), (EPPN_TYPE, "ePPN"), (GROUP_TYPE, "Group ID"), (DNS_TYPE, "Hostname"), (SET_TYPE, "Set"), (UWWI_TYPE, "UWWI"), ) name = models.CharField(max_length=50) display_name = models.CharField(max_length=500, null=True) type = models.SlugField(max_length=8, choices=TYPE_CHOICES) def is_uwnetid(self): return self.type == self.UWNETID_TYPE def is_eppn(self): return self.type == self.EPPN_TYPE def is_group(self): return self.type == self.GROUP_TYPE def json_data(self, is_put_req=False): data = {"id": self.name, "type": self.type} if is_put_req is False: data["name"] = self.display_name return data def __eq__(self, other): return self.name == other.name and self.type == other.type def __init__(self, *args, **kwargs): super(GroupEntity, self).__init__(*args, **kwargs)
class GroupMember(GroupEntity): DIRECT_MTYPE = "direct" INDIRECT_MTYPE = "indirect" MTYPE_CHOICES = ( (DIRECT_MTYPE, DIRECT_MTYPE), (INDIRECT_MTYPE, INDIRECT_MTYPE), ) mtype = models.SlugField(max_length=10, choices=MTYPE_CHOICES, default=DIRECT_MTYPE) source = models.CharField(max_length=1000, null=True) def json_data(self, is_put_req=False): data = {"id": self.name, "type": self.type} if is_put_req is False: data["mtype"] = self.mtype data["source"] = self.source return data def __init__(self, *args, **kwargs): super(GroupMember, self).__init__(*args, **kwargs)
class SpotType(models.Model): """ The type of Spot. """ name = models.SlugField(max_length=50)