Skip to content

Commit

Permalink
fix: copy files in copy_hearing function
Browse files Browse the repository at this point in the history
  • Loading branch information
danipran committed May 7, 2024
1 parent c5c4d99 commit 7949619
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions democracy/models/utils.py
Expand Up @@ -60,6 +60,12 @@ def copy_hearing(old_hearing, **kwargs):
image.section = section
image.save()
_copy_translations(image, old_image)
for old_file in old_section.files.all():
file = deepcopy(old_file)
file.pk = None
file.section = section
file.save()
_copy_translations(file, old_file)
for old_poll in old_polls:
old_options = old_poll.options.all()
poll = deepcopy(old_poll)
Expand Down
3 changes: 2 additions & 1 deletion democracy/tests/integrationtest/test_hearing.py
Expand Up @@ -899,8 +899,9 @@ def test_hearing_copy(default_hearing, random_label):

assert new_hearing.sections.count() == 3
for i, new_section in enumerate(new_hearing.sections.all().order_by("translations__abstract"), 1):
# each section should have 3 images, the correct abstract and no comments
# each section should have 3 images, 1 file, the correct abstract and no comments
assert new_section.images.count() == 3
assert new_section.files.count() == 1
assert new_section.abstract == "Section %d abstract" % i
assert new_section.comments.count() == 0
assert new_section.n_comments == 0
Expand Down

0 comments on commit 7949619

Please sign in to comment.