Skip to content

Commit

Permalink
Merge pull request #1265 from Signbank/feedback_translations
Browse files Browse the repository at this point in the history
Revision to Feedback for missing signs with translations
  • Loading branch information
susanodd committed Jun 17, 2024
2 parents fc7a37a + 5fe388a commit f93d865
Show file tree
Hide file tree
Showing 9 changed files with 906 additions and 691 deletions.
1,295 changes: 709 additions & 586 deletions conf/locale/nl/LC_MESSAGES/django.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion signbank/dictionary/templates/dictionary/gloss_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ <h2 id='modalTitleGloss'>{% trans "Add a sense" %}</h2>
<h2 id='modalDeleteNME'>{% trans "Delete NME Video" %}</h2>
</div>
<div class='modal-body'>
<p>{% trans "Are you sure you? This cannot be undone." %}</p>
<p>{% trans "Are you sure? This cannot be undone." %}</p>
</div>
<form class="formbutton" action='{% url "dictionary:update_gloss" gloss.id %}'
method='post'>
Expand Down
5 changes: 3 additions & 2 deletions signbank/feedback/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from signbank.feedback.models import *
from django.utils.translation import override, gettext_lazy as _
from django.contrib.admin import SimpleListFilter



class GeneralFeedbackAdmin(admin.ModelAdmin):
readonly_fields = ['user', 'date', 'comment', 'video']
list_display = ['user', 'date', 'comment']
Expand Down Expand Up @@ -61,7 +62,7 @@ class MissingSignFeedbackAdmin(admin.ModelAdmin):
list_filter = ['user']

def get_fields(self, request, obj=None):
fields = ['meaning', 'comments', 'video', 'status']
fields = ['meaning', 'comments', 'video', 'sentence', 'status']
return fields


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2024-06-14 11:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('feedback', '0013_remove_signfeedback_translation'),
]

operations = [
migrations.AddField(
model_name='missingsignfeedback',
name='sentence',
field=models.FileField(blank=True, upload_to='upload'),
),
migrations.AlterField(
model_name='missingsignfeedback',
name='video',
field=models.FileField(blank=True, upload_to='upload'),
),
]
92 changes: 78 additions & 14 deletions signbank/feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from signbank.settings.base import COMMENT_VIDEO_LOCATION, WRITABLE_FOLDER
import os
from signbank.video.fields import VideoUploadToFLVField
from django import forms

from django.utils.translation import gettext_lazy as _
from django.utils.encoding import escape_uri_path
Expand All @@ -14,16 +15,14 @@

import string


def t(message):
"""Replace $country and $language in message with dat from settings"""

tpl = string.Template(message)
return tpl.substitute(country=settings.COUNTRY_NAME, language=settings.LANGUAGE_NAME)



from django import forms

STATUS_CHOICES = (('unread', 'unread'),
('read', 'read'),
('deleted', 'deleted'),
Expand All @@ -44,18 +43,20 @@ class Meta:
def has_video(self):
"""Return the video object for this Feedback or None if no video available"""
if self.video:
filepath = os.path.join(settings.COMMENT_VIDEO_LOCATION, os.sep, self.video.path)
filepath = os.path.join(settings.COMMENT_VIDEO_LOCATION, self.video.name)
else:
filepath = ''
if filepath and os.path.exists(filepath.encode('utf-8')):
return self.video
else:
return ''


class GeneralFeedbackForm(forms.Form):
"""Form for general feedback"""

comment = forms.CharField(widget=forms.Textarea(attrs={'rows':6, 'cols':80}), required=True)
comment = forms.CharField(widget=forms.Textarea(attrs={'rows': 4, 'cols': 80}),
required=True)
video = forms.FileField(required=False, widget=forms.FileInput(attrs={'size':'60'}))


Expand Down Expand Up @@ -96,48 +97,76 @@ def __str__(self):
class Meta:
ordering = ['-date']


class SignFeedbackForm(forms.Form):
"""Form for input of sign feedback"""

comment = forms.CharField(label="Comment or new keywords", required=True, widget=forms.Textarea(attrs={'rows':6, 'cols':80}))
comment = forms.CharField(label="Comment or new keywords", required=True,
widget=forms.Textarea(attrs={'rows': 4, 'cols': 80}))

def __init__(self, *args, **kwargs):
super(SignFeedbackForm, self).__init__(*args, **kwargs)


class MorphemeFeedbackForm(forms.Form):
"""Form for input of sign feedback"""

comment = forms.CharField(label="Comment or new keywords", required=True, widget=forms.Textarea(attrs={'rows':6, 'cols':80}))
comment = forms.CharField(label=_("Comment or new keywords"), required=True,
widget=forms.Textarea(attrs={'rows': 4, 'cols': 80}))

def __init__(self, *args, **kwargs):
super(MorphemeFeedbackForm, self).__init__(*args, **kwargs)


class MissingSignFeedbackForm(forms.Form):

meaning = forms.CharField(label='Sign Meaning', widget=forms.Textarea(attrs={'rows':6, 'cols':80}))
video = forms.FileField(required=False, widget=forms.FileInput(attrs={'size':'60'}))
comments = forms.CharField(label='Further Details', widget=forms.Textarea(attrs={'rows':6, 'cols':80}), required=True)
meaning = forms.CharField(label=_('Sign Meaning'), widget=forms.Textarea(attrs={'rows': 4, 'cols': 80}),
required=True)
video = forms.FileField(label=_('Video of the Sign'), required=True,
widget=forms.FileInput(attrs={'size': '60', 'accept': 'video/*'}))
comments = forms.CharField(label=_('Other Remarks'), widget=forms.Textarea(attrs={'rows': 4, 'cols': 80}),
required=False)
sentence = forms.FileField(label=_('Example Sentence'), required=False,
widget=forms.FileInput(attrs={'size': '60', 'accept': 'video/*'}))

def __init__(self, *args, **kwargs):
sign_languages = kwargs.pop('sign_languages')

super(MissingSignFeedbackForm, self).__init__(*args, **kwargs)

self.fields['signlanguage'] = forms.ModelChoiceField(label=_("Sign Language"),
self.fields['signlanguage'] = forms.ModelChoiceField(label=_("Sign Language"), required=True,
queryset=SignLanguage.objects.filter(id__in=sign_languages),
widget=forms.Select(attrs={'class': 'form-control'}))
self.fields['signlanguage'].initial = sign_languages[0]


def get_video_file_path(instance, filename, signlanguage, comment_type):
(base, ext) = os.path.splitext(filename)

filename = comment_type + '_' + signlanguage + '_' + str(instance.id) + ext

signlanguage_directory = os.path.join(settings.WRITABLE_FOLDER, settings.COMMENT_VIDEO_LOCATION, signlanguage)
path = os.path.join(settings.COMMENT_VIDEO_LOCATION, signlanguage, filename)

if not os.path.isdir(signlanguage_directory):
os.mkdir(signlanguage_directory)

if hasattr(settings, 'ESCAPE_UPLOADED_VIDEO_FILE_PATH') and settings.ESCAPE_UPLOADED_VIDEO_FILE_PATH:
from django.utils.encoding import escape_uri_path
path = escape_uri_path(path)
return path


class MissingSignFeedback(models.Model):
user = models.ForeignKey(authmodels.User, on_delete=models.CASCADE)
date = models.DateTimeField(auto_now_add=True)
signlanguage = models.ForeignKey(SignLanguage, verbose_name=_("Sign Language"),
help_text=_("Sign Language of the missing sign"), null=True, on_delete=models.CASCADE)
help_text=_("Sign Language of the missing sign"), null=True,
on_delete=models.CASCADE)
meaning = models.TextField()
comments = models.TextField(blank=True)
video = models.FileField(upload_to=settings.COMMENT_VIDEO_LOCATION, blank=True)
video = models.FileField(upload_to=settings.VIDEO_UPLOAD_LOCATION, blank=True)
sentence = models.FileField(upload_to=settings.VIDEO_UPLOAD_LOCATION, blank=True)

status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='unread')

Expand All @@ -147,10 +176,45 @@ class Meta:
def has_video(self):
"""Return the video object for this Feedback or None if no video available"""
if self.video:
filepath = os.path.join(settings.COMMENT_VIDEO_LOCATION, os.sep, self.video.path)
filepath = os.path.join(settings.WRITABLE_FOLDER, self.video.name)
else:
filepath = ''
if filepath and os.path.exists(filepath.encode('utf-8')):
return self.video
else:
return ''

def has_sentence_video(self):
"""Return the sentence object for this Feedback or None if no sentence available"""
if self.sentence:
filepath = os.path.join(settings.WRITABLE_FOLDER, self.sentence.name)
else:
filepath = ''
if filepath and os.path.exists(filepath.encode('utf-8')):
return self.sentence
else:
return ''

def save_video(self, *args, **kwargs):
if not self.video:
return
filename = self.video.name
signlanguage = self.signlanguage.name
newloc = get_video_file_path(self, filename, signlanguage, 'missing_sign')
newpath = os.path.join(settings.WRITABLE_FOLDER, newloc)
oldpath = os.path.join(settings.WRITABLE_FOLDER, self.video.name)
os.rename(oldpath, newpath)
self.video.name = newloc
self.save()

def save_sentence_video(self, *args, **kwargs):
if not self.sentence:
return
filename = self.sentence.name
signlanguage = self.signlanguage.name
newloc = get_video_file_path(self, filename, signlanguage, 'meaning_missing_sign')
newpath = os.path.join(settings.WRITABLE_FOLDER, newloc)
oldpath = os.path.join(settings.WRITABLE_FOLDER, self.sentence.name)
os.rename(oldpath, newpath)
self.sentence.name = newloc
self.save()
70 changes: 23 additions & 47 deletions signbank/feedback/templates/feedback/missingsign.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
$("#signdescriptioninput").toggle();
return false;
});
$("#videoupload").hide();

$("#togglesignlanguagebutton").click(function() {
$("#signlanguage").toggle();
return false;
});
$("#signlanguage").hide();

});
</script>
Expand All @@ -34,40 +32,33 @@
{% block content %}
<div class="col-md-5 col-md-offset-1">

<h2>{% trans "Missing Sign Feedback" %}</h2>
<h3>{% trans "Missing Sign Feedback" %}</h3>

{% if posted %}
<div id="feedbackmessage">
<p class='alert alert-info'>
<h4 class='alert alert-info'>
{% trans "Thank you for your feedback." %}
</p>
</h4>
</div>
{% else %}
<p>{% trans "Please submit a video comment showing the sign you think is missing." %}</p>
<p>{% trans "Please produce the sign in isolation and then in an example sentence." %}</p>
<p>{% blocktrans trimmed %}
Please also type in the English translation equivalent below as well as
your contact information (name and email address) so we can contact you for a follow up if need be.
{% endblocktrans %}</p>
<p>{% trans "Thank you for taking the time to contact us and help SignBank grow." %}</p>
<h4>{% trans "What sign do you think is missing?" %}</h4>

<form method="post" enctype="multipart/form-data" name="missingsign">
{% csrf_token %}
<p>{% blocktrans trimmed %}
You may either upload a video that shows the missing sign or
fill in details below. In either case, you should
enter a meaning and any comments you might have in the text
boxes at the bottom of the form.
{% endblocktrans %}</p>

<button class='btn btn-default' id="togglesignlanguagebutton">{% trans "Sign Language" %}</button>
<button class='btn btn-default' id="togglevideobutton">{% trans "Video Comment" %}</button>

<fieldset id="videoupload">
<legend>{% trans "Sign" %}</legend>
<div id="{{form.video.name}}div">
{% bootstrap_label form.video.label %}
{% if form.video.errors %}{{form.video.errors}}{% endif %}
{% bootstrap_field form.video show_label=False %}
</div>
</fieldset>

<fieldset id="signlanguage">
<legend>{% trans "Sign Language" %}</legend>
<div id="{{form.signlanguage.name}}div">
<p>{% trans "What is the sign language of the missing sign?" %}</p>
<p>{% trans "From which sign language is this sign?" %}</p>
{% if form.signlanguage.errors %}{{form.signlanguage.errors}}{% endif %}
{% bootstrap_field form.signlanguage show_label=False %}

Expand All @@ -84,39 +75,24 @@ <h2>{% trans "Missing Sign Feedback" %}</h2>
</fieldset>


<fieldset id="videoupload">
<legend>{% trans "Video Upload" %}</legend>
<div id="{{form.video.name}}div">
{% bootstrap_label form.video.label %}
<p>{% trans "Upload a video of the sign." %}</p>
{% if form.video.errors %}{{form.video.errors}}{% endif %}
{% bootstrap_field form.video show_label=False %}

<p>{% blocktrans trimmed %}
NOTE: Video files can be quite large, and may take a long time to send.
Please be patient when submitting this feedback.
{% endblocktrans %}</p>
</div>
</fieldset>


<fieldset id="meaninginput">
<legend>{% trans "Details" %}</legend>
<div id="{{form.meaning.name}}div">
<p>{% blocktrans trimmed %}
Please explain the meaning of the new or missing sign, or enter individual
English words that have the same meaning as this sign (i.e. keywords).
{% endblocktrans %}</p>
<p>{% trans "What does this sign mean?" %}
{% trans "Please provide an explanation, translation and/or example sentence" %}
</p>
{% if form.meaning.errors %}{{form.meaning.errors}}{% endif %}
{% bootstrap_field form.meaning show_label=False %}
</div>

<div id="{{form.sentence.name}}div">
{% bootstrap_label form.sentence.label %}
{% if form.video.errors %}{{form.sentence.errors}}{% endif %}
{% bootstrap_field form.sentence show_label=False %}
</div>

<div id="{{form.comments.name}}div">
<p>{% blocktrans trimmed %}
Are there any other comments you would like to give about this sign? For example,
do you think there are other or extra keyword/s that belong with this sign?
If so, please include your comments below.
{% endblocktrans %}</p>
<p>{% trans "Other remarks / information about the sign" %}</p>
{% if form.comments.errors %}{{form.comments.errors}}{% endif %}
{% bootstrap_field form.comments show_label=False %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ <h4 class="panel-title">
</h4>
</div>
<div id="missingcollapse{{fb.id}}" class="panel-collapse collapse col-md-4">

<br>
{% if fb.has_video %}
<label>{% trans 'Video of the Sign' %}</label>
<div class="videocontainer">
<video id='msfb{{fb.id}}' class='video-js vjs-default-skin'
poster='{{posterurl}}' controls preload='false' data-setup='{"example_option":true}'>
Expand All @@ -93,7 +94,18 @@ <h4 class="panel-title">
<p><a href='{{ MEDIA_URL }}{{ fb.video }}'>{% trans "Download Video" %}</a></p>
</div>
{% endif %}


{% if fb.has_sentence_video %}
<label>{% trans 'Example Sentence' %}</label>
<div class="videocontainer">
<video id='mssfb{{fb.id}}' class='video-js vjs-default-skin'
poster='{{posterurl}}' controls preload='false' data-setup='{"example_option":true}'>
<source src='{{protected_media_url}}{{ fb.sentence }}' type='video/mp4' codecs='avc1.42E01E, mp4a.40.2'>
</video>
<p><a href='{{ MEDIA_URL }}{{ fb.sentence }}'>{% trans "Download Video" %}</a></p>
</div>
{% endif %}

<dl class='dl-horizontal'>
<dt>{% trans "Sign Language" %}</dt>
{% if fb.signlanguage %}
Expand Down
Loading

0 comments on commit f93d865

Please sign in to comment.