Skip to content

Commit

Permalink
[Fixes🛠️] list all users route fixed - templates modified
Browse files Browse the repository at this point in the history
  • Loading branch information
[esekyi] committed Aug 27, 2024
1 parent 2d4e27c commit 5d59456
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 81 deletions.
21 changes: 11 additions & 10 deletions app/routes/user_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
# user routes blueprint
bp = Blueprint('user_routes', __name__)

@bp.route('/users', methods=['GET'])
@bp.route('/users', methods=['GET'], strict_slashes=False)
def list_users():
"""get all users in db"""
users = get_all_users()
user_list = []
for user in users:
return jsonify({
user_list.append({
"id": user.id,
"name": user.first_name + ' ' + user.last_name,
"email": user.email,
"password": user.password_hash
"email": user.email
})
return jsonify(user_list)


@bp.route('/user/<uuid:user_id>', methods=["GET"])
@bp.route('/user/<uuid:user_id>', methods=["GET"], strict_slashes=False)
@login_required
def get_user(user_id):
"""get a specific user by id"""
Expand All @@ -31,7 +32,7 @@ def get_user(user_id):
return jsonify({"username": user.username, "email": user.email})


@bp.route('/register', methods=['GET', 'POST'])
@bp.route('/register', methods=['GET', 'POST'], strict_slashes=False)
def register():
if request.method == 'POST':
data = request.form
Expand Down Expand Up @@ -59,10 +60,10 @@ def register():
flash('An error occured during registeration. Please try again', 'error')
return redirect(url_for('user_routes.register'))

return render_template('register.html')
return render_template('user_auth/register.html')


@bp.route('/user/<uuid:user_id>/edit', methods=["POST"])
@bp.route('/user/<uuid:user_id>/edit', methods=["POST"], strict_slashes=False)
@login_required
def edit_user(user_id):
"""Update user details by id"""
Expand Down Expand Up @@ -93,7 +94,7 @@ def edit_user(user_id):
return redirect(url_for('main.index'))


@bp.route('/user/<uuid:user_id>/delete', methods=['POST'])
@bp.route('/user/<uuid:user_id>/delete', methods=['POST'], strict_slashes=False)
@login_required
def delete_user_profile(user_id):

Expand All @@ -104,4 +105,4 @@ def delete_user_profile(user_id):
return redirect(url_for('main.index'))
else:
flash('You are not authorized to delete this profile.', 'danger')
return redirect(url_for('main.index'))
return redirect(url_for('main.index'))
12 changes: 0 additions & 12 deletions app/templates/index.html

This file was deleted.

22 changes: 0 additions & 22 deletions app/templates/login.html

This file was deleted.

37 changes: 0 additions & 37 deletions app/templates/register.html

This file was deleted.

0 comments on commit 5d59456

Please sign in to comment.