@@ -16,11 +16,11 @@ import os | |||
auth = Blueprint('auth', __name__) | |||
# routes for login page | |||
@auth.route('/login/') | |||
@auth.route('/login') | |||
def login(): | |||
return render_template('login.html') | |||
@auth.route('/login/', methods=['POST']) | |||
@auth.route('/login', methods=['POST']) | |||
def login_post(): | |||
email = request.form.get('email') | |||
password = request.form.get('password') | |||
@@ -40,11 +40,11 @@ def login_post(): | |||
return redirect(url_for('main.profile',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | |||
# routes for signup page | |||
@auth.route('/signup/') | |||
@auth.route('/signup') | |||
def signup(): | |||
return render_template('signup.html') | |||
@auth.route('/signup/', methods=['POST']) | |||
@auth.route('/signup', methods=['POST']) | |||
def signup_post(): | |||
email = request.form.get('email') | |||
name = request.form.get('name') | |||
@@ -66,7 +66,7 @@ def signup_post(): | |||
return redirect(url_for('auth.login',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | |||
# route for logout function | |||
@auth.route('/logout/') | |||
@auth.route('/logout') | |||
@login_required | |||
def logout(): | |||
logout_user() |
@@ -17,20 +17,20 @@ import os | |||
book = Blueprint('book', __name__) | |||
# route for displaying all books in database | |||
@book.route('/books/') | |||
@book.route('/books') | |||
def get_books(): | |||
books = Resource.query.filter_by(type='book') | |||
return render_template('resources.html', resources=books, type='book') | |||
# route for displaying a single book based on the ID in the database | |||
@book.route('/books/<int:book_id>/') | |||
@book.route('/books/<int:book_id>') | |||
def show_book(book_id): | |||
book = get_resource(book_id) | |||
links = get_linked_resources(book_id) | |||
return render_template('resource.html', resource=book, links=links) | |||
# route for editing a single book based on the ID in the database | |||
@book.route('/books/<int:book_id>/edit/', methods=('GET', 'POST')) | |||
@book.route('/books/<int:book_id>/edit', methods=('GET', 'POST')) | |||
@login_required | |||
def edit_book(book_id): | |||
book = get_resource(book_id) | |||
@@ -51,7 +51,7 @@ def edit_book(book_id): | |||
return render_template('edit.html', resource=book) | |||
# route for function to delete a single book from the edit page | |||
@book.route('/books/<int:book_id>/delete/', methods=('POST',)) | |||
@book.route('/books/<int:book_id>/delete', methods=('POST',)) | |||
@login_required | |||
def delete_book(book_id): | |||
delete_resource(book_id) |
@@ -18,7 +18,7 @@ import os | |||
create = Blueprint('create', __name__) | |||
# route for creating a new resource | |||
@create.route('/create/', methods=('GET', 'POST')) | |||
@create.route('/create', methods=('GET', 'POST')) | |||
@login_required | |||
def create_resource(): | |||
if request.method == 'POST': |
@@ -25,18 +25,18 @@ def index(): | |||
return render_template('index.html', text=text, tools=tools) | |||
# route for profile page | |||
@main.route('/profile/') | |||
@main.route('/profile') | |||
@login_required | |||
def profile(): | |||
return render_template('profile.html', name=current_user.name) | |||
# route for test page | |||
@main.route('/test/') | |||
@main.route('/test') | |||
def test(): | |||
return render_template('test.html') | |||
# route for about page | |||
@main.route('/about/') | |||
@main.route('/about') | |||
def about(): | |||
with open('content/about.md', 'r') as f: | |||
text = f.read() |
@@ -17,20 +17,20 @@ import os | |||
practice = Blueprint('practice', __name__) | |||
# route for displaying all practices in database | |||
@practice.route('/practices/') | |||
@practice.route('/practices') | |||
def get_practices(): | |||
practices = Resource.query.filter_by(type='practice') | |||
return render_template('resources.html', resources=practices, type='practice') | |||
# route for displaying a single practice based on the ID in the database | |||
@practice.route('/practices/<int:practice_id>/') | |||
@practice.route('/practices/<int:practice_id>') | |||
def show_practice(practice_id): | |||
practice = get_resource(practice_id) | |||
links = get_linked_resources(practice_id) | |||
return render_template('resource.html', resource=practice, links=links) | |||
# route for editing a single practice based on the ID in the database | |||
@practice.route('/practices/<int:practice_id>/edit/', methods=('GET', 'POST')) | |||
@practice.route('/practices/<int:practice_id>/edit', methods=('GET', 'POST')) | |||
@login_required | |||
def edit_practice(practice_id): | |||
practice = get_resource(practice_id) | |||
@@ -65,7 +65,7 @@ def edit_practice(practice_id): | |||
return render_template('edit.html', resource=practice, resource_dropdown=resource_dropdown, links=links) | |||
# route for function to delete a single practice from the edit page | |||
@practice.route('/practices/<int:practice_id>/delete/', methods=('POST',)) | |||
@practice.route('/practices/<int:practice_id>/delete', methods=('POST',)) | |||
@login_required | |||
def delete_practice(practice_id): | |||
delete_resource(practice_id) |
@@ -17,20 +17,20 @@ import os | |||
publisher = Blueprint('publisher', __name__) | |||
# route for displaying all publishers in database | |||
@publisher.route('/publishers/') | |||
@publisher.route('/publishers') | |||
def get_publishers(): | |||
publishers = Resource.query.filter_by(type='publisher') | |||
return render_template('resources.html', resources=publishers, type='publisher') | |||
# route for displaying a single publisher based on the ID in the database | |||
@publisher.route('/publishers/<int:publisher_id>/') | |||
@publisher.route('/publishers/<int:publisher_id>') | |||
def show_publisher(publisher_id): | |||
publisher = get_resource(publisher_id) | |||
links = get_linked_resources(publisher_id) | |||
return render_template('resource.html', resource=publisher, links=links) | |||
# route for editing a single publisher based on the ID in the database | |||
@publisher.route('/publishers/<int:publisher_id>/edit/', methods=('GET', 'POST')) | |||
@publisher.route('/publishers/<int:publisher_id>/edit', methods=('GET', 'POST')) | |||
@login_required | |||
def edit_publisher(publisher_id): | |||
publisher = get_resource(publisher_id) | |||
@@ -51,7 +51,7 @@ def edit_publisher(publisher_id): | |||
return render_template('edit.html', resource=publisher) | |||
# route for function to delete a single publisher from the edit page | |||
@publisher.route('/publishers/<int:publisher_id>/delete/', methods=('POST',)) | |||
@publisher.route('/publishers/<int:publisher_id>/delete', methods=('POST',)) | |||
@login_required | |||
def delete_publisher(publisher_id): | |||
delete_resource(publisher_id) |
@@ -17,20 +17,20 @@ import os | |||
tool = Blueprint('tool', __name__) | |||
# route for displaying all tools in database | |||
@tool.route('/tools/') | |||
@tool.route('/tools') | |||
def get_tools(): | |||
tools = Resource.query.filter_by(type='tool') | |||
return render_template('resources.html', resources=tools, type='tool') | |||
# route for displaying a single tool based on the ID in the database | |||
@tool.route('/tools/<int:tool_id>/') | |||
@tool.route('/tools/<int:tool_id>') | |||
def show_tool(tool_id): | |||
tool = get_resource(tool_id) | |||
links = get_linked_resources(tool_id) | |||
return render_template('resource.html', resource=tool, links=links) | |||
# route for editing a single tool based on the ID in the database | |||
@tool.route('/tools/<int:tool_id>/edit/', methods=('GET', 'POST')) | |||
@tool.route('/tools/<int:tool_id>/edit', methods=('GET', 'POST')) | |||
@login_required | |||
def edit_tool(tool_id): | |||
tool = get_resource(tool_id) | |||
@@ -81,7 +81,7 @@ def edit_tool(tool_id): | |||
return render_template('edit.html', resource=tool, resource_dropdown=resource_dropdown, links=links) | |||
# route for function to delete a single tool from the edit page | |||
@tool.route('/tools/<int:tool_id>/delete/', methods=('POST',)) | |||
@tool.route('/tools/<int:tool_id>/delete', methods=('POST',)) | |||
@login_required | |||
def delete_tool(tool_id): | |||
delete_resource(tool_id) |