def make_category(self, string, parent=None, order=1): """ Make and save a category object from a string """ cat = Category( name=string.strip(), slug=slugify(SLUG_TRANSLITERATOR(string.strip()))[:49], #parent=parent, order=order) cat._tree_manager.insert_node(cat, parent, 'last-child', True) cat.save() if parent: parent.rght = cat.rght + 1 parent.save() return cat
def make_category(self, string, parent=None, order=1): """ Make and save a category object from a string """ slug = slugify(SLUG_TRANSLITERATOR(string.strip()))[:49] if parent: parent_url = parent.url.rstrip("/") else: parent_url = "" cat = NavBarEntry(name=string.strip(), slug=slug, url="%s/%s/" % (parent_url, slug), order=order) cat._tree_manager.insert_node(cat, parent, 'last-child', True) cat.save() if parent: parent.rght = cat.rght + 1 parent.save() return cat
def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(SLUG_TRANSLITERATOR(self.name))[:50] super(CategoryTranslationBase, self).save(*args, **kwargs)