def set_auto_slug(self): full_slug = gen_slug(self.name) if not full_slug: # if slug generation failed we select the highest category # id as base for slug generation. tag = Tag.query.autoflush(False).order_by(Tag.id.desc()).first() full_slug = unicode(tag and tag.id or u'1') if full_slug != self.slug: while Tag.query.autoflush(False) \ .filter_by(slug=full_slug).limit(1).count(): full_slug = increment_string(full_slug) self.slug = full_slug
def set_auto_slug(self): """Generate a slug for this category.""" full_slug = gen_slug(self.name) if not full_slug: # if slug generation failed we select the highest category # id as base for slug generation. category = Category.query.autoflush(False) \ .order_by(Category.id.desc()).first() full_slug = unicode(category and category.id or u'1') if full_slug != self.slug: while Category.query.autoflush(False) \ .filter_by(slug=full_slug).limit(1).count(): full_slug = increment_string(full_slug) self.slug = full_slug
def set_auto_slug(self): """Generate a slug for this post.""" #cfg = get_application().cfg slug = gen_slug(self.title) if not slug: slug = to_blog_timezone(self.pub_date).strftime('%H%M') full_slug = gen_timestamped_slug(slug, self.content_type, self.pub_date) if full_slug != self.slug: while Post.query.autoflush(False).filter_by(slug=full_slug) \ .limit(1).count(): full_slug = increment_string(full_slug) self.slug = full_slug