def single_author(authorID): author = Author.get_author(authorID) collections = Collection.get_collections_by_author(authorID) works = Work.get_works_by_author(authorID) for work in works: work['Content'] = re.sub(r'<([^<]+)>', '', work['Content']) work['Content'] = work['Content'].replace('%', '').replace('/', '') worksNum = Work.get_works_num(works) return render_template('single_author.html', author=author, collections=collections, works=works, worksNum=worksNum)
def edit_author(authorID): if request.method == 'GET': dynasties = Dynasty.get_dynasties() author = Author.get_author(authorID) return render_template('edit_author.html', dynasties=dynasties, author=author) elif request.method == 'POST': author = request.form['author'] quote = request.form['quote'] introduction = request.form['introduction'] birthYear = int(request.form['birthYear']) deathYear = int(request.form['deathYear']) dynastyID = int(request.form['dynastyID']) Author.edit_author(author, quote, introduction, birthYear, deathYear, dynastyID, authorID) return redirect(url_for('single_author', authorID=authorID))