Skip to content

Commit

Permalink
Fix custom editor clears after project clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Aadesh-Baral committed Sep 1, 2022
1 parent a269311 commit c024a77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/models/postgis/custom_editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def as_dto(self) -> CustomEditorDTO:
dto.url = self.url

return dto

def clone_to_project(self, project_id: int):
new_editor = CustomEditor()
new_editor.project_id = project_id
new_editor.name = self.name
new_editor.description = self.description
new_editor.url = self.url
return new_editor
3 changes: 2 additions & 1 deletion backend/models/postgis/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ def clone(project_id: int, author_id: int):
for field in ["interests", "campaign"]:
value = getattr(orig, field)
setattr(new_proj, field, value)
new_proj.custom_editor = orig.custom_editor
if orig.custom_editor:
new_proj.custom_editor = orig.custom_editor.clone_to_project(new_proj.id)

return new_proj

Expand Down

0 comments on commit c024a77

Please sign in to comment.