def to_dict(self): res = ModelMixin.to_dict(self) if self.deleted: from settings import gettext res["content"] = gettext("Comment Deleted") return res
def login(): if request.method == "POST" and "email" in request.form: email = request.form["email"].strip() password = request.form["password"].strip() remember = request.form.get("remember", "no") != "no" if login_user(email, password, remember): return redirect(request.args.get("next") or url_for("index")) flash(gettext("Please input valid email and password")) return render_template("login.html", admin_page=True)
def tags(tag_name): try: tag = apis.Tag.get_tag_by_name(unquote(tag_name)) if not tag: from ajax import MSG_NO_TAG raise Exception(gettext(MSG_NO_TAG, name=tag_name)) except: abort(404) pager = { "cur_page": 0, "per_page": 10, } tag.stats.increase("view_count") return render_template("tags.html", tag=tag, pager=pager)
def index(category_url=None): try: category_url = category_url and unquote(category_url) category = apis.Category.get_by_url(category_url) if not category: from ajax import MSG_NO_CATEGORY raise Exception(gettext(MSG_NO_CATEGORY, id=category_url)) pager = { "cur_page": 0, "per_page": category.posts_per_page, "group_by": "", "is_last_page": False, } except: abort(404) category.stats.increase("view_count") return render_template("index.html", category=category, pager = pager)
def index(category_url=None): try: category_url = category_url and unquote(category_url) category = apis.Category.get_by_url(category_url) if not category: from ajax import MSG_NO_CATEGORY raise Exception(gettext(MSG_NO_CATEGORY, id=category_url)) pager = { "cur_page": 0, "per_page": category.posts_per_page, "group_by": "", "is_last_page": False, } except: abort(404) category.stats.increase("view_count") return render_template("index.html", category=category, pager=pager)
def page_not_found(e): return render_template('error.html', error=gettext("Page not found")), 404