def save(self, *args, **kwargs): """ Saves the Attribute and auto-generates a slug field if one wasn't provided. """ if not self.slug: self.slug = EavSlugField.create_slug_from_name(self.name) self.full_clean() super(Attribute, self).save(*args, **kwargs)
def derive_datatype(self): """ We map our field_type to the appropriate data_type here. """ # set our slug based on our command and keyword self.slug = "%s_%s" % (self.xform.get_primary_keyword(), EavSlugField.create_slug_from_name(self.command)) typedef = self.lookup_type(self.field_type) if not typedef: raise ValidationError("Field '%s' has an unknown data type: %s" % (self.command, self.datatype)) self.datatype = typedef['db_type']
def derive_datatype(self): """ We map our field_type to the appropriate data_type here. """ # set our slug based on our command and keyword self.slug = "%s_%s" % (self.xform.get_primary_keyword(), EavSlugField.create_slug_from_name(self.command)) typedef = self.lookup_type(self.field_type) if not typedef: raise ValidationError("Field '%s' has an unknown data type: %s" % (self.command, self.datatype)) self.datatype = typedef['db_type']
def save(self, *args, **kwargs): ''' Saves the Attribute and auto-generates a slug field if one wasn't provided. If parent provided is not already a ContentType, calculate this. Yes, this means you can't add Attributes for the ContentType model. ''' if not getattr(self, 'slug', None): self.slug = EavSlugField.create_slug_from_name(self.name) if not getattr(self, 'site', None): self.site = Site.objects.get_current() self.full_clean() super(Attribute, self).save(*args, **kwargs)
def derive_datatype(self): """ We map our field_type to the appropriate data_type here. """ # set our slug based on our command and keyword self.slug = "%s_%s" % (self.xform.keyword, EavSlugField.create_slug_from_name(self.command)) for (field_type, name, datatype, func, xforms_type) in XFormField.TYPE_CHOICES: if field_type == self.field_type: self.datatype = datatype break if not self.datatype: raise ValidationError("Field '%s' has an unknown data type: %s" % (self.command, self.datatype))