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

Task dto last updated attribute made timezone aware and add teams by … #6610

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 6 additions & 2 deletions backend/models/postgis/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)
from sqlalchemy.orm import relationship
from sqlalchemy.orm.exc import MultipleResultsFound
from datetime import timezone

from backend.db import Base, get_session
from backend.exceptions import NotFound
Expand Down Expand Up @@ -1357,7 +1358,6 @@ async def reset_lock(
comment=comment,
db=db,
)

# Update task lock history with duration
await TaskHistory.update_task_locked_with_duration(
task_id=task_id,
Expand Down Expand Up @@ -1737,7 +1737,11 @@ async def as_dto_with_instructions(

task_history.append(history)

last_updated = task_history[0].action_date if task_history else None
last_updated = (
task_history[0].action_date.replace(tzinfo=timezone.utc).isoformat()
if task_history
else None
)
task_dto = await Task.as_dto(task_id, project_id, db, last_updated)
per_task_instructions = await Task.get_per_task_instructions(
task_id, project_id, preferred_locale, db
Expand Down
3 changes: 2 additions & 1 deletion backend/models/postgis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class ST_Y(GenericFunction):

def timestamp():
"""Used in SQL Alchemy models to ensure we refresh timestamp when new models initialised"""
return datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
# return datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
return datetime.datetime.utcnow()


# Based on https://stackoverflow.com/a/51916936
Expand Down
3 changes: 2 additions & 1 deletion backend/services/team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,8 @@ async def is_user_team_manager(team_id: int, user_id: int, db: Database) -> bool

# Org admin manages teams attached to their org
user_managed_orgs = [
org.id for org in await OrganisationService.get_organisations(user_id, db)
org.organisation_id
for org in await OrganisationService.get_organisations(user_id, db)
]
if team.organisation_id in user_managed_orgs:
return True
Expand Down
Loading