Commit b81a17ee authored by ras19's avatar ras19
Browse files

Added function in project_to_user blueprint to retrieve users assigned to a...

Added function in project_to_user blueprint to retrieve users assigned to a project in a particular json form [RS]
parent da46e054
Pipeline #203242 passed with stage
in 6 minutes and 37 seconds
......@@ -3,6 +3,7 @@ from flask import Blueprint, request, jsonify
from backend.database_config.database import DB
from backend.models.user_model import User_project
from backend.models.project_model import Project
from backend.models.user_model import User
user_project = Blueprint('user_project', __name__)
......@@ -24,6 +25,14 @@ def get_users_for_project(project_id):
"id" : x.id} for x in entries]
return jsonify(assignments_list)
@user_project.route('/user_project/project_task/<project_id>', methods=['GET'])
def get_users_for_project_for_tasks(project_id):
entries = User_project.query.filter_by(project_id=project_id)
assigned_users = [{"value" : query.username,
"label" : query.firstname + " " + query.surname}
for query in (User.query.get(x.username) for x in entries)]
return jsonify(assigned_users)
@user_project.route('/user_project/username/<username>', methods=['GET'])
def get_projects_for_user(username):
entries = User_project.query.filter_by(username=username)
......
......@@ -14,19 +14,7 @@ const AddProjectTask = () => {
const [assignedUsers, setAssignedUsers] = useState([]);
const { data: project, error, isPending } = useFetch("/projects/" + id)
const participants = [
{
"value": "john34",
"label": "John Smith"
},
{
"value": "rs0408",
"label": "JRahil Shah"
},{
"value": "ew1234",
"label": "Ethan Weitzman"
}
]
const { data: participants, errorParticipants, isPendingParticipants } = useFetch("/user_project/project_task/" + id)
const history = useHistory();
......
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