示例#1
0
def get_dynasty_by_json():
	check_admin()

	dynasty_id = int(request.form['dynasty_id'])
	dynasty = Dynasty.get_dynasty(dynasty_id)
	authors = Author.get_authors_by_dynasty(dynasty_id)
	return render_template('single_dynasty.widget', dynasty=dynasty, authors=authors)
示例#2
0
def add_quote(author_id):
	check_admin()

	quote = request.form['quote']
	work_id = int(request.form['work-id'])
	work_title = Work.get_work(work_id)['Title'] 
	Quote.add(author_id, quote, work_id, work_title)
	return redirect(url_for('admin_quotes', author_id=author_id))
示例#3
0
def admin_widgets(target_type, target_id):
    check_admin()

    widgets = Widget.get_widgets(target_type, target_id)
    return render_template('admin_widgets.html',
                           target_type=target_type,
                           target_id=target_id,
                           widgets=widgets)
示例#4
0
def get_authors_by_name():
	check_admin()

	name = request.form['author']
	authors = Author.get_authors_by_name(name)
	for author in authors:
		author['Collections'] = Collection.get_collections_by_author(author['AuthorID'])
	return json.dumps(authors)
示例#5
0
def add_quote(author_id):
    check_admin()

    quote = request.form['quote']
    work_id = int(request.form['work-id'])
    work_title = Work.get_work(work_id)['Title']
    Quote.add(author_id, quote, work_id, work_title)
    return redirect(url_for('admin_quotes', author_id=author_id))
示例#6
0
def get_authors_by_name():
    check_admin()

    name = request.form['author']
    authors = Author.get_authors_by_name(name)
    for author in authors:
        author['Collections'] = Collection.get_collections_by_author(
            author['AuthorID'])
    return json.dumps(authors)
示例#7
0
def add_collection():
	check_admin()

	if request.method == 'GET':
		return render_template('add_collection.html')
	elif request.method == 'POST':
		collection = request.form['collection']
		authorID = int(request.form['authorID'])
		introduction = request.form['introduction']
		newCollectionID = Collection.add_collection(collection, authorID, introduction)
		return redirect(url_for('single_collection', collectionID = newCollectionID))
示例#8
0
def edit_quote(quote_id):
	check_admin()
	
	if request.method == 'GET':
		quote = Quote.get_quote_by_id(quote_id)
		return render_template('edit_quote.html', quote=quote)
	elif request.method == 'POST':
		quote = request.form['quote']
		work_id = int(request.form['work-id'])
		work = Work.get_work(work_id)
		Quote.edit(quote_id, work['AuthorID'], quote, work['WorkID'], work['Title'])
		return redirect(url_for('admin_quotes', author_id=work['AuthorID']))
示例#9
0
def add_widget():
    check_admin()

    target_type = request.form['target_type']
    target_id = int(request.form['target_id'])
    title = request.form['title']
    content = request.form['content']
    index = int(request.form['index'])

    Widget.add_widget(target_type, target_id, title, content, index)
    return redirect(
        url_for('admin_widgets', target_type=target_type, target_id=target_id))
示例#10
0
def edit_collection(collectionID):
	check_admin()

	if request.method == 'GET':
		collection = Collection.get_collection(collectionID)
		return render_template('edit_collection.html', collection=collection)
	elif request.method == 'POST':
		collection = request.form['collection']
		authorID = int(request.form['authorID'])
		introduction = request.form['introduction']
		Collection.edit_collection(collection, authorID, introduction, collectionID)
		return redirect(url_for('single_collection', collectionID=collectionID))
示例#11
0
def add_collection():
    check_admin()

    if request.method == 'GET':
        return render_template('add_collection.html')
    elif request.method == 'POST':
        collection = request.form['collection']
        authorID = int(request.form['authorID'])
        introduction = request.form['introduction']
        newCollectionID = Collection.add_collection(collection, authorID,
                                                    introduction)
        return redirect(
            url_for('single_collection', collectionID=newCollectionID))
示例#12
0
def add_dynasty():
	check_admin()

	if request.method == 'GET':
		return render_template('add_dynasty.html')
	elif request.method == 'POST':
		dynasty = request.form['dynasty']
		abbr = request.form['abbr']
		introduction = request.form['introduction']
		startYear = int(request.form['startYear'])
		endYear = int(request.form['endYear'])
		Dynasty.add_dynasty(dynasty, abbr, introduction, startYear, endYear)
		return redirect(url_for('single_dynasty', dynasty_abbr=abbr))
示例#13
0
def add_product():
	check_admin()

	if request.method == 'GET':
		return render_template('add_product.html')
	elif request.method == 'POST':
		product = request.form['product']
		url = request.form['url']
		image_url = request.form['image-url']
		introduction = request.form['introduction']
		
		new_product_id = Product.add_product(product, url, image_url, introduction)
		return redirect(url_for('single_product', product_id=new_product_id))
示例#14
0
def edit_quote(quote_id):
    check_admin()

    if request.method == 'GET':
        quote = Quote.get_quote_by_id(quote_id)
        return render_template('edit_quote.html', quote=quote)
    elif request.method == 'POST':
        quote = request.form['quote']
        work_id = int(request.form['work-id'])
        work = Work.get_work(work_id)
        Quote.edit(quote_id, work['AuthorID'], quote, work['WorkID'],
                   work['Title'])
        return redirect(url_for('admin_quotes', author_id=work['AuthorID']))
示例#15
0
def add_product():
    check_admin()

    if request.method == 'GET':
        return render_template('add_product.html')
    elif request.method == 'POST':
        product = request.form['product']
        url = request.form['url']
        image_url = request.form['image-url']
        introduction = request.form['introduction']

        new_product_id = Product.add_product(product, url, image_url,
                                             introduction)
        return redirect(url_for('single_product', product_id=new_product_id))
示例#16
0
def edit_product(product_id):
	check_admin()
	
	if request.method == 'GET':
		product = Product.get_product(product_id)
		return render_template('edit_product.html', product=product)
	elif request.method == 'POST':
		product = request.form['product']
		url = request.form['url']
		image_url = request.form['image-url']
		introduction = request.form['introduction']

		Product.edit_product(product_id, product, url, image_url, introduction)
		return redirect(url_for('single_product', product_id=product_id))
示例#17
0
def edit_collection(collectionID):
    check_admin()

    if request.method == 'GET':
        collection = Collection.get_collection(collectionID)
        return render_template('edit_collection.html', collection=collection)
    elif request.method == 'POST':
        collection = request.form['collection']
        authorID = int(request.form['authorID'])
        introduction = request.form['introduction']
        Collection.edit_collection(collection, authorID, introduction,
                                   collectionID)
        return redirect(url_for('single_collection',
                                collectionID=collectionID))
示例#18
0
def edit_product(product_id):
    check_admin()

    if request.method == 'GET':
        product = Product.get_product(product_id)
        return render_template('edit_product.html', product=product)
    elif request.method == 'POST':
        product = request.form['product']
        url = request.form['url']
        image_url = request.form['image-url']
        introduction = request.form['introduction']

        Product.edit_product(product_id, product, url, image_url, introduction)
        return redirect(url_for('single_product', product_id=product_id))
示例#19
0
def add_author():
	check_admin()

	if request.method == 'GET':
		dynasties = Dynasty.get_dynasties()
		return render_template('add_author.html', dynasties=dynasties)
	elif request.method == 'POST':
		author = request.form['author']
		abbr = request.form['abbr']
		introduction = request.form['introduction']
		birthYear = request.form['birthYear']
		deathYear = request.form['deathYear']
		dynastyID = int(request.form['dynastyID'])
		Author.add_author(author, abbr, introduction, birthYear, deathYear, dynastyID)
		return redirect(url_for('single_author', author_abbr=abbr))
示例#20
0
def edit_dynasty(dynasty_id):
	check_admin()

	if request.method == 'GET':
		dynasty = Dynasty.get_dynasty(dynasty_id)
		return render_template('edit_dynasty.html', dynasty=dynasty)
	elif request.method == 'POST':
		dynasty = request.form['dynasty']
		abbr = request.form['abbr']
		introduction = request.form['introduction']
		history = request.form['history']
		startYear = int(request.form['startYear'])
		endYear = int(request.form['endYear'])
		Dynasty.edit_dynasty(dynasty, abbr, introduction, history, startYear, endYear, dynasty_id)
		return redirect(url_for('single_dynasty', dynasty_abbr=abbr))
示例#21
0
def add_author():
    check_admin()

    if request.method == 'GET':
        dynasties = Dynasty.get_dynasties()
        return render_template('add_author.html', dynasties=dynasties)
    elif request.method == 'POST':
        author = request.form['author']
        abbr = request.form['abbr']
        introduction = request.form['introduction']
        birthYear = request.form['birthYear']
        deathYear = request.form['deathYear']
        dynastyID = int(request.form['dynastyID'])
        Author.add_author(author, abbr, introduction, birthYear, deathYear,
                          dynastyID)
        return redirect(url_for('single_author', author_abbr=abbr))
示例#22
0
def edit_widget(widget_id):
    check_admin()

    if request.method == 'GET':
        widget = Widget.get_widget(widget_id)
        return render_template('edit_widget.html', widget=widget)
    elif request.method == 'POST':
        target_type = request.form['target_type']
        target_id = int(request.form['target_id'])
        title = request.form['title']
        content = request.form['content']
        index = int(request.form['index'])

        Widget.edit_widget(widget_id, title, content, index)
        return redirect(
            url_for('admin_widgets',
                    target_type=target_type,
                    target_id=target_id))
示例#23
0
def add_work():
	check_admin()

	if request.method == 'GET':
		work_types = Work.get_types()
		return render_template('add_work.html', work_types=work_types)
	elif request.method == 'POST':
		title = request.form['title']
		content = request.form['content']
		foreword = request.form['foreword']
		intro = request.form['introduction']
		authorID = int(request.form['authorID'])
		dynastyID = int(Dynasty.get_dynastyID_by_author(authorID))
		collectionID = int(request.form['collectionID'])
		work_type = request.form['type']
		type_name = Work.get_type_name(work_type)
		
		new_work_id = Work.add_work(title, content, foreword, intro, authorID, dynastyID, collectionID, work_type, type_name)
		return redirect(url_for('single_work', work_id=new_work_id))
示例#24
0
def add_work():
    check_admin()

    if request.method == 'GET':
        work_types = Work.get_types()
        return render_template('add_work.html', work_types=work_types)
    elif request.method == 'POST':
        title = request.form['title']
        content = request.form['content']
        foreword = request.form['foreword']
        intro = request.form['introduction']
        authorID = int(request.form['authorID'])
        dynastyID = int(Dynasty.get_dynastyID_by_author(authorID))
        collectionID = int(request.form['collectionID'])
        work_type = request.form['type']
        type_name = Work.get_type_name(work_type)

        new_work_id = Work.add_work(title, content, foreword, intro, authorID,
                                    dynastyID, collectionID, work_type,
                                    type_name)
        return redirect(url_for('single_work', work_id=new_work_id))
示例#25
0
def search_author_in_collection():
	check_admin()
	
	name = request.form['author']
	authors = Author.get_authors_by_name(name)
	return json.dumps(authors)
示例#26
0
def get_collections_by_author():
    check_admin()

    authorID = int(request.form['authorID'])
    collections = Collection.get_collections_by_author(authorID)
    return json.dumps(collections)
示例#27
0
def admin_quotes(author_id):
    check_admin()

    author = Author.get_author_by_id(author_id)
    quotes = Quote.get_quotes_by_author(author_id)
    return render_template('admin_quotes.html', quotes=quotes, author=author)
示例#28
0
def admin_quotes(author_id):
	check_admin()

	author = Author.get_author_by_id(author_id)
	quotes = Quote.get_quotes_by_author(author_id)
	return render_template('admin_quotes.html', quotes=quotes, author=author)
示例#29
0
def delete_quote(quote_id):
	check_admin()

	author_id = int(request.args['author_id'])
	Quote.delete(quote_id)
	return redirect(url_for('admin_quotes', author_id=author_id))
示例#30
0
def search_author_in_collection():
    check_admin()

    name = request.form['author']
    authors = Author.get_authors_by_name(name)
    return json.dumps(authors)
示例#31
0
def get_collections_by_author():
	check_admin()
	
	authorID = int(request.form['authorID'])
	collections = Collection.get_collections_by_author(authorID)
	return json.dumps(collections)
示例#32
0
def delete_quote(quote_id):
    check_admin()

    author_id = int(request.args['author_id'])
    Quote.delete(quote_id)
    return redirect(url_for('admin_quotes', author_id=author_id))