def admin_articles_mod(req, id): check_login(req) match_right(req, module_rights) article = Article(id) if not article.get(req): raise SERVER_RETURN(state.HTTP_NOT_FOUND) if (not do_check_right(req, right_editor) and article.author_id != req.login.id): raise SERVER_RETURN(state.HTTP_FORBIDDEN) Codebook = build_class('tags') pager = Pager(order='value', limit=-1) tags = Codebook.list(req, Codebook, pager) if req.method == 'POST': article.bind(req.form) error = article.mod(req) if error != article: return generate_page(req, "admin/articles_mod.html", article=article, error=error) if not article.get(req): raise SERVER_RETURN(state.HTTP_NOT_FOUND) return generate_page(req, "admin/articles_mod.html", article=article, token=create_token(req), tags=tags)
def admin_articles_add(req): check_login(req) match_right(req, module_rights) article = Article() if req.method == 'POST': article.bind(req.form, req.login.id) error = article.add(req) if error: return generate_page(req, "admin/articles_mod.html", article=article, error=error) redirect(req, '/admin/articles/%d' % article.id) # end article.state = 2 if do_check_right(req, right_editor) else 1 return generate_page(req, "admin/articles_mod.html", article=article)