Skip to content

Commit

Permalink
fix: update task status when mapping starts (#1208)
Browse files Browse the repository at this point in the history
Co-authored-by: sujanadh <sujanadh07@gmail.com>
  • Loading branch information
Sujanadh and sujanadh authored Feb 14, 2024
1 parent af1b9ee commit 3632bd4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/backend/app/auth/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,12 @@ async def mapper(
"""A mapper for a specific project."""
# If project is public, skip permission check
if project.visibility == ProjectVisibility.PUBLIC:
return None

return user_data
db_user = await check_access(
user_data,
db,
project_id=project.id,
role=ProjectRole.VALIDATOR,
role=ProjectRole.MAPPER,
)

if db_user:
Expand Down
4 changes: 3 additions & 1 deletion src/backend/app/projects/project_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

"""Project dependencies for use in Depends."""

from typing import Optional

from fastapi import Depends
from fastapi.exceptions import HTTPException
from sqlalchemy.orm import Session
Expand All @@ -28,7 +30,7 @@


async def get_project_by_id(
db: Session = Depends(get_db), project_id: int = None
db: Session = Depends(get_db), project_id: Optional[int] = None
) -> DbProject:
"""Get a single project by id."""
if not project_id:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/tasks/tasks_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def update_task_status(
current_user: AuthUser = Depends(mapper),
):
"""Update the task status."""
user_id = get_uid(current_user)
user_id = await get_uid(current_user)
task = await tasks_crud.update_task_status(db, user_id, task_id, new_status)
updated_task = await tasks_crud.update_task_history(task, db)
if not task:
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/src/api/ProjectTaskStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import CoreModules from '@/shared/CoreModules';
import { CommonActions } from '@/store/slices/CommonSlice';
import { task_priority_str } from '@/types/enums';

const UpdateTaskStatus = (url, style, existingData, currentProjectId, feature, map, view, taskId, body) => {
const UpdateTaskStatus = (url, style, existingData, currentProjectId, feature, map, view, taskId, body, params) => {
return async (dispatch) => {
const index = existingData.findIndex((project) => project.id == currentProjectId);
const updateTask = async (url, existingData, body, feature) => {
const updateTask = async (url, existingData, body, feature, params) => {
try {
dispatch(CommonActions.SetLoading(true));

const response = await CoreModules.axios.post(url, body);
const response = await CoreModules.axios.post(url, body, { params });
const findIndexForUpdation = existingData[index].taskBoundries.findIndex((obj) => obj.id == response.data.id);

let project_tasks = [...existingData[index].taskBoundries];
Expand Down Expand Up @@ -52,7 +52,7 @@ const UpdateTaskStatus = (url, style, existingData, currentProjectId, feature, m
);
}
};
await updateTask(url, existingData, body, feature);
await updateTask(url, existingData, body, feature, params);
const centroid = await existingData[index].taskBoundries.filter((task) => {
return task.id == taskId;
})[0].outline_centroid.geometry.coordinates;
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/components/DialogTaskActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function Dialog({ taskId, feature, map, view }) {
view,
taskId,
body,
{ project_id: currentProjectId },
),
);
} else {
Expand Down

0 comments on commit 3632bd4

Please sign in to comment.