Esempio n. 1
0
 def get_or_create(self, **kwargs):
     "Gets or creates a selection. If the selection is created, a slug is given to it."
     new_slug = None
     if 'slug' in kwargs:
         new_slug = slugify(kwargs['slug'])
     kwargs = self._update_kwargs(kwargs)
     if new_slug:
         kwargs['defaults'] = kwargs.get('defaults') or {}
         kwargs['defaults']['internal_slug'] = new_slug
     instance, created = super(SelectionManager, self).get_or_create(**kwargs)
     if created:
         instance.assign_slug_by_id()
         instance.save()
     return instance, created
Esempio n. 2
0
 def get_or_create(self, **kwargs):
     "Gets or creates a selection. If the selection is created, a slug is given to it."
     new_slug = None
     if 'slug' in kwargs:
         new_slug = slugify(kwargs['slug'])
     kwargs = self._update_kwargs(kwargs)
     if new_slug:
         kwargs['defaults'] = kwargs.get('defaults') or {}
         kwargs['defaults']['internal_slug'] = new_slug
     instance, created = super(SelectionManager, self).get_or_create(**kwargs)
     if created:
         instance.assign_slug_by_id()
         instance.save()
     return instance, created
Esempio n. 3
0
 def create(self, **kwargs):
     if 'slug' in kwargs:
         kwargs['internal_slug'] = slugify(kwargs.pop('internal_slug'))
     kwargs = self._update_kwargs(kwargs)
     return super(SelectionManager, self).create(**kwargs)
Esempio n. 4
0
 def create(self, **kwargs):
     if 'slug' in kwargs:
         kwargs['internal_slug'] = slugify(kwargs.pop('internal_slug'))
     kwargs = self._update_kwargs(kwargs)
     return super(SelectionManager, self).create(**kwargs)
Esempio n. 5
0
 def slug(self, string):
     self.internal_slug = slugify(string)