Skip to content

Commit

Permalink
Merge pull request #1521 from the-deep/fix/entry-export
Browse files Browse the repository at this point in the history
Add condition in entry attachment for export
  • Loading branch information
subinasr authored Jul 31, 2024
2 parents 3c455be + 9447e2f commit 5f1d955
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 7 additions & 5 deletions apps/export/entries/excel_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ def add_entries_from_excel_data_for_static_column(
return [entry_excerpt, entry.dropped_excerpt]
return entry_excerpt
elif exportable == Export.StaticColumn.LEAD_ENTRY_ENTRY_ATTACHMENT_FILE_PREVIEW:
return get_private_file_url(
PrivateFileModuleType.ENTRY_ATTACHMENT,
entry.id,
entry.entry_attachment.file.name
)
if entry.entry_attachment:
return get_private_file_url(
PrivateFileModuleType.ENTRY_ATTACHMENT,
entry.id,
entry.entry_attachment.file.name
)
return None

def add_entries_from_excel_data(self, rows, data, export_data):
export_type = data.get('type')
Expand Down
2 changes: 1 addition & 1 deletion apps/export/tests/snapshots/snap_test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

snapshots['TestGenericExportMutationSchema::test_project_stats generic-export-csv'] = '''ID,Title,Created Date,Owners,Start Date,End Date,Last Entry (Date),Organisation (Project owner),Project Stakeholders,Geo Areas,Analysis Framework,Description,Status,Test project (Y/N),Members Count,Sources Count,Entries Count,# of Exports\r
2,Project-1,2021-01-01 00:00:00.123456+00:00,,,,,,,,AF-0,,inactive,N,0,0,0,0\r
1,Project-0,2021-01-01 00:00:00.123456+00:00,,,,2021-01-01 00:00:00.123456+00:00,,,,AF-0,,inactive,N,0,1,10,0\r
1,Project-0,2021-01-01 00:00:00.123456+00:00,,,,2021-01-01 00:00:00.123456+00:00,,,,AF-0,,inactive,N,0,1,20,0\r
'''
9 changes: 9 additions & 0 deletions apps/export/tests/test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from export.tasks import get_export_filename
from export.serializers import UserExportCreateGqlSerializer

from entry.models import Entry


class TestExportMutationSchema(GraphQLTestCase):
CREATE_EXPORT_QUERY = '''
Expand Down Expand Up @@ -798,6 +800,13 @@ def setUp(self):
self.project, *_ = ProjectFactory.create_batch(2, analysis_framework=self.af)
self.lead = LeadFactory.create(project=self.project)
EntryFactory.create_batch(10, lead=self.lead, project=self.project, analysis_framework=self.af)
EntryFactory.create_batch(
10,
lead=self.lead,
project=self.project,
analysis_framework=self.af,
entry_type=Entry.TagType.ATTACHMENT
)
# User with role
self.user = UserFactory.create()
# -- Some other data which shouldn't be visible in exports
Expand Down

0 comments on commit 5f1d955

Please sign in to comment.