Skip to content

Commit

Permalink
Merge pull request #1264 from Signbank/ann_sent_improv_1234
Browse files Browse the repository at this point in the history
Fix for other temporary file types #1234
  • Loading branch information
susanodd authored Jun 13, 2024
2 parents 40ef5a0 + 22e5170 commit 710d471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions signbank/dictionary/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3972,10 +3972,14 @@ def add_video(self, user, videofile, eaffile, corpus):
"""Add a video to the annotated sentence"""
from signbank.video.models import AnnotatedVideo

if (isinstance(videofile, File) or videofile.content_type == 'django.core.files.uploadedfile.InMemoryUploadedFile')\
and eaffile.content_type == 'application/octet-stream':
if ((isinstance(videofile, File) or videofile.content_type == 'django.core.files.uploadedfile.InMemoryUploadedFile' \
or videofile.content_type == 'django.core.files.uploadedfile.TemporaryUploadedFile')\
and (eaffile.content_type == 'application/octet-stream' or eaffile.content_type == 'django.core.files.uploadedfile.TemporaryUploadedFile'\
or eaffile.content_type == 'django.core.files.uploadedfile.InMemoryUploadedFile')):
annotatedVideo = AnnotatedVideo.objects.create(annotatedsentence=self, videofile=videofile, eaffile=eaffile)

else:
return None

annotatedVideo.corpus = corpus
annotatedVideo.save()

Expand Down
9 changes: 7 additions & 2 deletions signbank/video/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.template import Context, RequestContext
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import HttpResponse
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
Expand Down Expand Up @@ -65,9 +66,13 @@ def addvideo(request):
annotatedSentence.add_contexts(json.loads(contexts))

corpus = form.cleaned_data['corpus_name']
annotatedSentence.add_video(request.user, vfile, eaf_file, corpus)
annotatedVideo = annotatedSentence.add_video(request.user, vfile, eaf_file, corpus)

annotatedSentence.save()
if annotatedVideo == None:
messages.add_message(request, messages.ERROR, _('Annotated sentence upload went wrong. Please try again.'))
annotatedSentence.delete()
else:
annotatedSentence.save()

return redirect(redirect_url)

Expand Down

0 comments on commit 710d471

Please sign in to comment.