Skip to content

Commit

Permalink
Merge pull request #6659 from hotosm/fastapi-refactor
Browse files Browse the repository at this point in the history
fix: Tasks added to cloned projects
  • Loading branch information
prabinoid authored Dec 13, 2024
2 parents 71f3381 + 8abc0cd commit c34a95f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions backend/models/postgis/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,21 @@ async def save(self, db: Database):
Project.__table__.update().where(Project.id == self.id).values(**columns)
)

for task in self.tasks:
await db.execute(
Task.__table__.insert().values(
id=task.id,
project_id=self.id,
x=task.x,
y=task.y,
zoom=task.zoom,
is_square=task.is_square,
task_status=TaskStatus.READY.value,
extra_properties=task.extra_properties,
geometry=task.geometry,
)
)

@staticmethod
async def clone(project_id: int, author_id: int, db: Database):
"""Clone a project using encode databases and raw SQL."""
Expand Down Expand Up @@ -823,6 +838,7 @@ async def delete(self, db: Database):
# List of tables to delete from, in the order required to satisfy foreign key constraints
related_tables = [
"project_favorites",
"campaign_projects",
"project_custom_editors",
"project_interests",
"project_priority_areas",
Expand Down
2 changes: 1 addition & 1 deletion backend/services/project_admin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def create_draft_project(
draft_project.set_default_changeset_comment()
draft_project.set_country_info()
if draft_project_dto.cloneFromProjectId:
draft_project.save(db) # Update the clone
await draft_project.save(db) # Update the clone
return draft_project.id

else:
Expand Down

0 comments on commit c34a95f

Please sign in to comment.