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: Tasks added to cloned projects #6659

Merged
merged 1 commit into from
Dec 13, 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
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
Loading