def get_author_details(): if request.method == 'GET': author_id = request.args.get('author_id') doc_num = request.args.get('doc_num') if author_id is None and doc_num is None: return render_template('data_visualize/select_author.html', title='Select an author', content=u'Select an author in the following list and the system will display the ' u'details of that author you selected', authors_list=data_warehouse.get_all_author_id_and_name() ) if request.method == 'POST': try: author_id = int(request.form['author_id']) doc_num = data_warehouse.get_num_of_doc_written_by_an_author(author_id) except ValueError: abort(403) try: author_id = int(author_id) doc_num = int(doc_num) except ValueError: abort(403) author_name = data_warehouse.get_author_name_by_id(author_id) return render_template('data_visualize/author_details.html', title=author_name, content=Markup(u'You are now looking at <strong>{}</strong>. There are <strong>{}</strong> ' u'of documents written by {} stored in our database.' .format(author_name, doc_num, author_name)), doc_list=data_warehouse.get_all_docs_by_author_id(author_id) )
def compare_authors(): if request.method == 'GET': abort(403) if request.method == 'POST': doc_id = request.form['doc_id'] # try: author_id, stat = comparision_top10.queryExp(int(doc_id)) print stat return render_template('data_visualize/show_stat.html', title='Result', content='', author=data_warehouse.get_author_name_by_id(author_id), stat=stat.iteritems() )