def save(self, *args, **kwargs):
     if self.order is None:
         self.order = self.form.fields.count()
     if not self.slug:
         slug = slugify(self).replace('-', '_')
         self.slug = unique_slug(self.form.fields, "slug", slug)
     super(Field, self).save(*args, **kwargs)
Example #2
0
 def save(self, *args, **kwargs):
     if self.order is None:
         self.order = self.form.fields.count()
     if not self.slug:
         slug = slugify(self).replace('-', '_')
         self.slug = unique_slug(self.form.fields, "slug", slug)
     super(Field, self).save(*args, **kwargs)
Example #3
0
def callback_field(sender, instance, *args, **kwargs):
    if not instance.slug or len(instance.slug) == len(instance.label):
        slug = slugify(get_translation(instance.label))
        instance.slug = unique_slug(instance.__class__.objects, "slug", slug)
    if not instance.order:
        max_order = max(instance.form.fields.aggregate(Max('order')).values() +
                        instance.form.labels.aggregate(Max('order')).values())
        instance.order = max_order or 0 + 1
Example #4
0
 def save(self, *args, **kwargs):
     """
     Create a unique slug from title - append an index and increment if it
     already exists.
     """
     if not self.slug:
         slug = slugify(self)
         self.slug = unique_slug(self.__class__.objects, "slug", slug)
     super(AbstractForm, self).save(*args, **kwargs)
 def save(self, *args, **kwargs):
     """
     Create a unique slug from title - append an index and increment if it
     already exists.
     """
     if not self.slug:
         slug = slugify(self)
         self.slug = unique_slug(self.__class__.objects, "slug", slug)
     super(AbstractForm, self).save(*args, **kwargs)
Example #6
0
 def save(self, *args, **kwargs):
     if not self.slug:
         slug = slugify(self).replace('-', '_')
         self.slug = unique_slug(self.form.fields, "slug", slug)
     return super(AbstractField, self).save(*args, **kwargs)
Example #7
0
 def save(self, *args, **kwargs):
     if not self.slug:
         slug = slugify(self).replace('-', '_')
         self.slug = unique_slug(self.form.fields, "slug", slug)
     return super(AbstractField, self).save(*args, **kwargs)
Example #8
0
def callback_form(sender, instance, *args, **kwargs):
    if not instance.slug or len(instance.slug) == len(instance.title):
        slug = slugify(get_translation(instance.title))
        instance.slug = unique_slug(instance.__class__.objects, "slug", slug)