Skip to content

Commit

Permalink
Return None instead of invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Oct 20, 2023
1 parent dd5cb0d commit a872c8b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions apps/export/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Meta:
status = graphene.Field(graphene.NonNull(ExportStatusEnum))
export_type = graphene.Field(graphene.NonNull(ExportExportTypeEnum))
file = graphene.Field(FileFieldType)
file_download_url = graphene.String()
file_download_url = graphene.String(required=False)
# Filter Data
filters = graphene.Field(LeadsFilterDataType)
filters_data = graphene.Field(LeadFilterDataType)
Expand All @@ -79,14 +79,15 @@ def resolve_filters_data(root, info):

@staticmethod
def resolve_file_download_url(root, info, **kwargs):
return info.context.request.build_absolute_uri(
URLCachedFileField.generate_url(
root.file.name,
parameters={
'ResponseContentDisposition': f'filename = "{root.title}.{root.format}"'
}
if root.file and root.file.name:
return info.context.request.build_absolute_uri(
URLCachedFileField.generate_url(
root.file.name,
parameters={
'ResponseContentDisposition': f'filename = "{root.title}.{root.format}"'
}
)
)
)


class UserGenericExportType(DjangoObjectType):
Expand All @@ -108,22 +109,23 @@ class Meta:
filters = GenericScalar(required=False)

file = graphene.Field(FileFieldType)
file_download_url = graphene.String()
file_download_url = graphene.String(required=False)

@staticmethod
def get_custom_queryset(queryset, info, **kwargs):
return get_generic_export_qs(info)

@staticmethod
def resolve_file_download_url(root, info, **kwargs):
return info.context.request.build_absolute_uri(
URLCachedFileField.generate_url(
root.file.name,
parameters={
'ResponseContentDisposition': f'filename = "{root.title}.{root.format}"'
}
if root.file and root.file.name:
return info.context.request.build_absolute_uri(
URLCachedFileField.generate_url(
root.file.name,
parameters={
'ResponseContentDisposition': f'filename = "{root.title}.{root.format}"'
}
)
)
)


class UserExportListType(CustomDjangoListObjectType):
Expand Down

0 comments on commit a872c8b

Please sign in to comment.