Exemplo n.º 1
0
 def save(self, *args, **kwargs):
     if not self.pk:
         words = self.name.split()
         filtered_words = [t for t in words if t.lower() not in STOP_WORDS]
         new_list = ' '.join(filtered_words)
         self.slug = version_slugify(new_list)[:50]
     super(Version, self).save(*args, **kwargs)
Exemplo n.º 2
0
 def save(self, *args, **kwargs):
     if not self.pk:
         words = self.name.split()
         filtered_words = [t for t in words if t.lower() not in STOP_WORDS]
         new_list = ' '.join(filtered_words)
         self.slug = version_slugify(new_list)[:50]
     self.padded_version = self.pad_name(self.name)
     super(Version, self).save(*args, **kwargs)
Exemplo n.º 3
0
    def forwards(self, orm):
        with transaction.atomic():
            # Adding field 'Version.slug'
            db.add_column(u'changes_version', 'slug',
                          self.gf('django.db.models.fields.SlugField')(blank=True, null=True, unique=False, max_length=50),
                          keep_default=False)

            # Adding field 'Entry.slug'
            db.add_column(u'changes_entry', 'slug',
                          self.gf('django.db.models.fields.SlugField')(
                              blank=True, null=True, unique=False, max_length=50),
                          keep_default=False)

            # Adding field 'Category.slug'
            db.add_column(u'changes_category', 'slug',
                          self.gf('django.db.models.fields.SlugField')(
                              blank=True, null=True, unique=False, max_length=50),
                          keep_default=False)

        with transaction.atomic():
            objects = orm['changes.Category'].objects.all()
            for obj in objects:
                obj.slug = slugify(obj.name)
                obj.save()

            objects = orm['changes.Version'].objects.all()
            for obj in objects:
                obj.slug = version_slugify(obj.name)
                obj.save()

            objects = orm['changes.Entry'].objects.all()
            for obj in objects:
                stop_words = (
                    'a', 'an', 'and', 'if', 'is', 'the', 'in', 'i', 'you', 'other',
                    'this', 'that'
                )
                words = obj.title.split()
                filtered_words = [t for t in words if t.lower() not in stop_words]
                new_list = ' '.join(filtered_words)
                obj.slug = slugify(new_list)[:49]
                obj.save()