Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear priority areas, send message after validation, project com… #6636

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/models/dtos/message_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ListChatMessageDTO(BaseModel):

id: Optional[int] = Field(None, alias="id")
message: str = Field(required=True)
picture_url: str = Field(default=None, alias="pictureUrl")
picture_url: Optional[str] = Field(None, alias="pictureUrl")
timestamp: datetime
username: str

Expand Down
3 changes: 1 addition & 2 deletions backend/models/postgis/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,8 @@ async def update(self, project_dto: ProjectDTO, db: Database):
await ProjectInfo.update_from_dto(ProjectInfo(**project_info), dto, db)

# Always clear Priority Area prior to updating

await Project.clear_existing_priority_areas(db, self.id)
if project_dto.priority_areas:
await Project.clear_existing_priority_areas(db, self.id)
for priority_area in project_dto.priority_areas:
pa = await PriorityArea.from_dict(priority_area, db)
# Link project and priority area in the database
Expand Down
2 changes: 1 addition & 1 deletion backend/services/messaging/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def send_message_after_validation(
"""
project_name = await db.fetch_val(
project_name_query,
values={"project_id": project_id, "locale": project["default_locale"]},
values={"project_id": project_id, "locale": project.default_locale},
)
user = await UserService.get_user_by_id(mapped_by, db)
text_template = get_txt_template(
Expand Down
2 changes: 1 addition & 1 deletion backend/services/project_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def get_project_dto_for_mapper(
if project.status == ProjectStatus.DRAFT.value:
if not is_manager_permission:
is_allowed_user = False
raise HTTPException(status_code=400, detail="Unable to fetch project.")
raise ProjectServiceError("ProjectNotFetched- Unable to fetch project")

# Private Projects - allowed_users, admins, org admins &
# assigned teams (mappers, validators, project managers), authors permitted
Expand Down
11 changes: 10 additions & 1 deletion backend/services/team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,17 @@ async def send_message_to_all_team_members(
team_name: str,
message_dto: MessageDTO,
user_id: int,
db: Database,
db: Database = None,
):
if db is None:
print("inside....")
db = await acquire_connection()
print("Sending message to the team...")
print(db)
team_members = await TeamService._get_active_team_members(team_id, db)
user = await UserService.get_user_by_id(user_id, db)
print("Fetched User....")

sender = user.username
message_dto.message = (
"A message from {}, manager of {} team:<br/><br/>{}".format(
Expand All @@ -804,6 +811,8 @@ async def send_message_to_all_team_members(
)
messages = []
for team_member in team_members:
print("Looping teams.......")

if team_member.user_id != user_id:
message = Message.from_dto(team_member.user_id, message_dto)
message.message_type = MessageType.TEAM_BROADCAST.value
Expand Down
2 changes: 1 addition & 1 deletion backend/services/validator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def lock_tasks_for_validation(
"ProjectNotPublished- Validation not allowed because: Project not published"
)
elif error_reason == ValidatingNotAllowed.USER_ALREADY_HAS_TASK_LOCKED:
user_tasks = Task.get_locked_tasks_for_user(validation_dto.user_id)
user_tasks = Task.get_locked_tasks_for_user(validation_dto.user_id, db)
if set(user_tasks.locked_tasks) != set(validation_dto.task_ids):
raise ValidatorServiceError(
"UserAlreadyHasTaskLocked- User already has a task locked"
Expand Down
Loading