Commit 0995134b authored by ras19's avatar ras19
Browse files

Implemented ability to see all users assigned to a task that appears on your...

Implemented ability to see all users assigned to a task that appears on your dashboard. Styled to look nice on the preview card [RS]
parent 782f0487
Pipeline #203783 passed with stage
in 1 minute and 20 seconds
......@@ -5,6 +5,7 @@ from backend.database_config.database import DB
from backend.models.task_model import AssignedTask
from backend.models.task_model import Task
from backend.models.project_model import Project
from backend.models.user_model import User
assigned_task = Blueprint('assigned_task', __name__)
......@@ -26,10 +27,20 @@ def get_tasks_for_user(username):
"project_id": task.project_id,
"project_name": Project.query.get(task.project_id).name,
"priority": task.priority,
"due_date": task.due_date} for task in (Task.query.get(x.task_id) for x in entries)]
"due_date": task.due_date,
"id": task.id} for task in (Task.query.get(x.task_id) for x in entries)]
return jsonify(task_list)
@assigned_task.route('/assigned_task/task/<task_id>', methods=['GET'])
def get_users_for_task(task_id):
entries = AssignedTask.query.filter_by(task_id=task_id)
users_list = [{"firstname": user.firstname,
"surname": user.surname,
"username": user.username} for user in (User.query.get(x.username) for x in entries)]
return jsonify(users_list)
@assigned_task.route('/assigned_task', methods=['POST'])
def assign_task_to_user():
username, task_id = (request.json['username'], request.json['task_id'])
......
......@@ -11,33 +11,6 @@ const Home = () => {
const { setToken, token } = useToken();
const { data: projects, errorRProjects, isPendingRProjects } = useFetch("/user_project/username/" + token);
// const project_tasks = [
// {
// "description": "This is example 1",
// "due_date": "17/06/2021",
// "priority": 1,
// "completed": "Completed",
// "project_id": 2,
// "id": 1
// },
// {
// "description": "This is example 2",
// "due_date": "18/06/2021",
// "priority": 1,
// "completed": "Available",
// "project_id": 3,
// "id": 2
// },
// {
// "description": "This is example 3",
// "due_date": "21/06/2021",
// "priority": 2,
// "completed": "Available",
// "project_id": 4,
// "id": 3
// }
// ]
const {data: project_tasks, errorProjectTasks, isPendingProjectTasks} = useFetch("/assigned_task/username/" + token)
return (
......
import { Link } from 'react-router-dom'
import useFetch from './useFetch';
const MyProjectTasks = ({ tasks, title }) => {
const FindingUsers = task_id => {
const { data: assignedUsers, error, isPending } = useFetch("/assigned_task/task/" + task_id);
return assignedUsers.map((user) => (
<div className="assigned-users-list">
<Link to={`/users/${user.username}`}>
<h5>{user.firstname} {user.surname}</h5>
</Link>
</div>
));
}
return (
<div>
<h2>{title}</h2>
......@@ -11,6 +23,8 @@ const MyProjectTasks = ({ tasks, title }) => {
<h2>{task.project_name}: {task.description}</h2>
<h3><strong>Priority level:</strong> {task.priority}</h3>
<h3><strong>To be done by:</strong> {task.due_date}</h3>
<h3>All volunteers assigned to this task: </h3>
{FindingUsers(task.id)}
<Link to={`/projects/${task.project_id}`}>
<h4>Click to see the project details</h4>
</Link>
......
......@@ -662,7 +662,29 @@ Note: Beware of modifying this element as it can break the animations - you shou
color: blue;
}
.task-preview h5 {
padding-left: 15px;
padding-bottom: 7px;
}
.task-preview h5:hover {
font-weight: bolder;
color: red;
}
.task-preview a {
text-decoration: none;
padding-top: 0px;
}
.assigned_user_list {
padding-left: 10px;
}
.assigned_user_list a {
text-decoration: none;
}
.assigned_user_list h4:hover {
color:red;
}
\ No newline at end of file
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