def linked_taglist(self): """ Returns the tags in the original order and format, with link to tag page """ return [(tag, url_for('frontend.tag', slug=slugify(tag))) for tag in self.taglist]
def linked_taglist(self): """ Returns the tags in the original order and format, with link to tag page """ return [(tag, url_for('frontend.tag', slug=slugify(tag))) for tag in self.taglist]
def create_or_login(response): openid = response.identity_url user, authenticated = \ User.query.authenticate_openid(response.email, openid) next_url = session.pop('next', None) if user is None: session['openid'] = openid username = response.fullname or response.nickname if username: username = slugify(username.replace("-", "_")) return redirect( url_for("openid.signup", next=next_url, name=username, email=response.email)) if authenticated: session.permanent = True identity_changed.send(current_app._get_current_object(), identity=Identity(user.id)) flash(_("Welcome back, %%s") % user.username, "success") if next_url is None: next_url = url_for('user.posts', username=user.username) return redirect(next_url) # user already exists, so login and attach openid session['openid'] = openid flash( _("You already have an account with us. " "Please login with your email address so your " "OpenID can be attached to your user account"), "success") return redirect(url_for('account.login', login=response.email))
def create_or_login(response): openid = response.identity_url user, authenticated = \ User.query.authenticate_openid(response.email, openid) next_url = session.pop('next', None) if user is None: session['openid'] = openid username = response.fullname or response.nickname if username: username = slugify(username.replace("-", "_")) return redirect(url_for("openid.signup", next=next_url, name=username, email=response.email)) if authenticated: session.permanent = True identity_changed.send(current_app._get_current_object(), identity=Identity(user.id)) flash(_("Welcome back, %%s") % user.username, "success") if next_url is None: next_url = url_for('user.posts', username=user.username) return redirect(next_url) # user already exists, so login and attach openid session['openid'] = openid flash(_("You already have an account with us. " "Please login with your email address so your " "OpenID can be attached to your user account"), "success") return redirect(url_for('account.login', login=response.email))
def _set_tags(self, tags): self._tags = tags if self.id: # ensure existing tag references are removed d = db.delete(post_tags, post_tags.c.post_id == self.id) db.engine.execute(d) for tag in set(self.taglist): slug = slugify(tag) tag_obj = Tag.query.filter(Tag.slug == slug).first() if tag_obj is None: tag_obj = Tag(name=tag, slug=slug) db.session.add(tag_obj) if self not in tag_obj.posts: tag_obj.posts.append(self)
def _set_tags(self, tags): self._tags = tags if self.id: # ensure existing tag references are removed d = db.delete(post_tags, post_tags.c.post_id == self.id) db.engine.execute(d) for tag in set(self.taglist): slug = slugify(tag) tag_obj = Tag.query.filter(Tag.slug == slug).first() if tag_obj is None: tag_obj = Tag(name=tag, slug=slug) db.session.add(tag_obj) if self not in tag_obj.posts: tag_obj.posts.append(self)
def test_slugify(self): assert slugify("hello, this is a test") == "hello-this-is-a-test"
def _set_name(self, name): self._name = name.lower().strip() self.slug = slugify(name)
def slug(self): return slugify(self.title or '')[:80]
def _set_name(self, name): self._name = name.lower().strip() self.slug = slugify(name)
def slug(self): return slugify(self.title or '')[:80]
def test_slugify(self): assert slugify("hello, this is a test") == "hello-this-is-a-test"