def GET(self): i = web.input() topic_id = i.topic_id if i.get("json"): questions = model.get_questions_for_topic(topic_id) return json.dumps(questions) else: topic_name = model.get_topic(topic_id)["name"] return render.questions(topic_id, topic_name)
def questions(): is_json = request.args.get("json", False) if not is_admin(): return "login_fail" if is_json else redirect(url_for("admin")) topic_id = request.args["topic_id"] if is_json: return json.dumps(model.get_questions_for_topic(topic_id)) else: topic_name = model.get_topic(topic_id)["name"] return render_template("questions.html", topic_id=topic_id, topic_name=topic_name)
def questions(): is_json = request.args.get('json', False) if not is_admin(): return 'login_fail' if is_json else redirect(url_for('admin')) topic_id = request.args['topic_id'] if is_json: return json.dumps(model.get_questions_for_topic(topic_id)) else: topic_name = model.get_topic(topic_id)['name'] return render_template('questions.html', topic_id=topic_id, topic_name=topic_name)