Commit 1f06fa9e authored by ethan's avatar ethan
Browse files

Added a blueprint function to get all users assigned to a task [EW]

parent 07a8101b
Pipeline #204004 passed with stage
in 1 minute and 4 seconds
......@@ -4,6 +4,7 @@ from flask import Blueprint, request, jsonify
from backend.database_config.database import DB
from backend.models.task_model import AssignedTask
from backend.models.task_model import Task
from backend.models.user_model import User
import json
assigned_task = Blueprint('assigned_task', __name__)
......@@ -37,6 +38,14 @@ def get_pending_tasks_for_user(username):
return jsonify(task_list)
@assigned_task.route('/assigned_task/all_users/<task_id>', methods=['GET'])
def get_users_assigned_to_task(task_id):
entries = AssignedTask.query.filter_by(task_id=task_id)
usernames = [{"firstname": user.firstname,
"surname": user.surname}
for user in (User.query.get(username) for username in (x.username for x in entries))]
return jsonify(usernames)
@assigned_task.route('/assigned_task', methods=['POST'])
def assign_task_to_user():
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment