Skip to content

Commit

Permalink
feat: also allow .odt files not just word
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanH90 committed Aug 2, 2023
1 parent afe928d commit e00e49e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion document_merge_service/api/tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_convert(db, client, target_format, response_content_type):

def test_incorrect_file_type(db, client):
url = reverse("convert")
file_to_convert = django_file("odt-template.odt")
file_to_convert = django_file("invalid-template.xlsx")

data = {"file": file_to_convert.file, "target_format": "pdf"}
response = client.post(url, data=data, format="multipart")
Expand Down
10 changes: 5 additions & 5 deletions document_merge_service/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def post(self, request, **kwargs):

content_type, foo = mimetypes.guess_type(file.name)

if (
content_type
!= "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
):
if content_type not in [
"application/vnd.oasis.opendocument.text",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
]:
raise exceptions.ValidationError(
"Incorrect file format. Only docx files are supported for conversion."
"Incorrect file format. Only docx and odt files are supported for conversion."
)

response = FileConverter.convert(file.read(), target_format)
Expand Down

0 comments on commit e00e49e

Please sign in to comment.