diff --git a/signbank/dictionary/models.py b/signbank/dictionary/models.py index a874bbcc3..677f3a9a7 100755 --- a/signbank/dictionary/models.py +++ b/signbank/dictionary/models.py @@ -2442,15 +2442,14 @@ def get_nme_videos(self): nmevideos = GlossVideoNME.objects.filter(gloss=self) return nmevideos - def add_nme_video(self, user, videofile, new_offset, recorded): + def add_nme_video(self, user, videofile, new_offset, recorded, perspective='center'): # Preventing circular import from signbank.video.models import GlossVideoNME, GlossVideoHistory, get_video_file_path - # Create a new GlossVideo object - existing_nmevideos = GlossVideoNME.objects.filter(gloss=self) - existing_offsets = [nmev.offset for nmev in existing_nmevideos] - if new_offset in existing_offsets: + + existing_offsets_for_this_perspective = [nmev.offset for nmev in GlossVideoNME.objects.filter(gloss=self,perspective=perspective)] + if new_offset in existing_offsets_for_this_perspective: # override given offset to avoid duplicate usage - offset = max(existing_offsets)+1 + offset = max(existing_offsets_for_this_perspective)+1 else: offset = new_offset diff --git a/signbank/dictionary/templates/dictionary/gloss_detail.html b/signbank/dictionary/templates/dictionary/gloss_detail.html index bf0a32e69..e0a5747f4 100755 --- a/signbank/dictionary/templates/dictionary/gloss_detail.html +++ b/signbank/dictionary/templates/dictionary/gloss_detail.html @@ -1888,11 +1888,7 @@

{% trans "Upload New NME Video" %}

{% trans "Perspective" %} - + {{nmevideoform.nme_perspective}} diff --git a/signbank/settings/server_specific/global_sb_new_aj.py b/signbank/settings/server_specific/global_sb_new_aj.py index ef54e4cae..98c6dc44a 100644 --- a/signbank/settings/server_specific/global_sb_new_aj.py +++ b/signbank/settings/server_specific/global_sb_new_aj.py @@ -5,7 +5,7 @@ COUNTRY_NAME = 'Netherlands' SIGNBANK_VERSION_CODE = 'global' URL = 'https://signbank.cls.ru.nl/' -ALLOWED_HOSTS = ['signbank.science.ru.nl','signbank.cls.ru.nl','new.signbank.science.ru.nl'] +ALLOWED_HOSTS=["*"] EAF_FILES_LOCATION = 'corpus-ngt/eaf/' METADATA_LOCATION = 'CNGT_MetadataEnglish_OtherResearchers.csv' @@ -81,3 +81,5 @@ 'OPTIONS': 'mysql.conf', 'TEST': {'NAME':'sigbank_test'} }} +SECRET_KEY="vu43ra23e3w4" +CSRF_TRUSTED_ORIGINS = ["https://signbank.cls.ru.nl","https://signbank-dev.cls.ru.nl"] diff --git a/signbank/video/forms.py b/signbank/video/forms.py index 0b37268e7..4d7add1e7 100755 --- a/signbank/video/forms.py +++ b/signbank/video/forms.py @@ -19,6 +19,7 @@ class Meta: ('right', 'Right') ) +NME_PERSPECTIVE_CHOICES = (('left','Left'),('right','Right'),('center', 'Center')) class VideoUploadForObjectForm(forms.Form): """Form for video upload for all video types""" @@ -32,6 +33,10 @@ class VideoUploadForObjectForm(forms.Form): perspective = forms.ChoiceField(label=_('Video Perspective'), choices=PERSPECTIVE_CHOICES, required=False, widget=forms.Select(attrs=ATTRS_FOR_FORMS)) + nme_perspective = forms.ChoiceField(label=_('NME video perspective'), + choices=NME_PERSPECTIVE_CHOICES, required=False, + widget=forms.Select(attrs=ATTRS_FOR_FORMS)) + eaffile = forms.FileField(label="Upload EAF", widget=forms.FileInput(attrs={'accept':'text/xml'}), required=False) feedbackdata = forms.CharField(widget=forms.HiddenInput, required=False) translations = forms.CharField(widget=forms.HiddenInput, required=False) diff --git a/signbank/video/migrations/0014_glossvideonme_perspective.py b/signbank/video/migrations/0014_glossvideonme_perspective.py index 4b891f398..5f71bce8f 100644 --- a/signbank/video/migrations/0014_glossvideonme_perspective.py +++ b/signbank/video/migrations/0014_glossvideonme_perspective.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.17 on 2024-12-13 14:34 +# Generated by Django 4.2.17 on 2024-12-20 15:00 from django.db import migrations, models @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='glossvideonme', name='perspective', - field=models.CharField(choices=[('left', 'Left'), ('right', 'Right')], default='center', max_length=20), + field=models.CharField(choices=[('left', 'Left'), ('right', 'Right'), ('center', 'Center')], default='center', max_length=20), ), ] diff --git a/signbank/video/models.py b/signbank/video/models.py index e3e1be9c9..62bee6614 100755 --- a/signbank/video/models.py +++ b/signbank/video/models.py @@ -40,6 +40,8 @@ def get_two_letter_dir(idgloss): ('right', 'Right') ) +NME_PERSPECTIVE_CHOICES = (('left','Left'),('right','Right'),('center', 'Center')) + class GlossVideoStorage(FileSystemStorage): """Implement our shadowing video storage system""" @@ -887,10 +889,9 @@ class GlossVideoDescription(models.Model): def __str__(self): return self.text - class GlossVideoNME(GlossVideo): offset = models.IntegerField(default=1) - perspective = models.CharField(max_length=20, choices=PERSPECTIVE_CHOICES, default='center') + perspective = models.CharField(max_length=20, choices=NME_PERSPECTIVE_CHOICES, default='center') class Meta: verbose_name = gettext("NME Gloss Video") diff --git a/signbank/video/views.py b/signbank/video/views.py index dc436be28..e82ee1e66 100755 --- a/signbank/video/views.py +++ b/signbank/video/views.py @@ -61,7 +61,8 @@ def addvideo(request): if not gloss: redirect(redirect_url) offset = form.cleaned_data['offset'] - nmevideo = gloss.add_nme_video(request.user, vfile, offset, recorded) + perspective = form.cleaned_data['nme_perspective'] + nmevideo = gloss.add_nme_video(request.user, vfile, offset, recorded, perspective) translation_languages = gloss.lemma.dataset.translation_languages.all() descriptions = dict() for language in translation_languages: @@ -69,7 +70,8 @@ def addvideo(request): form_value = form.cleaned_data[form_field] descriptions[language.language_code_2char] = form_value.strip() nmevideo.add_descriptions(descriptions) - nmevideo.perspective = form.cleaned_data['perspective'] #This is incorrect + nmevideo.perspective = perspective + nmevideo.save() elif object_type == 'morpheme_video': morpheme = Morpheme.objects.filter(id=object_id).first() if not morpheme: