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

Add condition in entry attachment for export #1521

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