Skip to content

Commit

Permalink
Merge pull request #592 from terceiro/talk-language
Browse files Browse the repository at this point in the history
talks: add language field to talks
  • Loading branch information
stefanor committed Jun 5, 2021
2 parents 0fa5b07 + 7fefdb8 commit edbd1a2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ Wafer's settings
There is a reasonable default form, but this can be changed to
customise the submission process.

``WAFER_TALK_LANGUAGUES``
A tuple of tuples, indicating the languages that users can select when
submitting talks. Each tuple has the language code as the first element,
and the language name as the second element. Example: ``(("en", "English"),
("pt", "Portuguese"))``. The first language listed will be considered the
default language, and will be selected by default on new submissions.

``WAFER_TALK_REVIEW_SCORES``
A tuple of 2 integers.
The range of values for talk reviews. Inclusive.
Expand Down
3 changes: 3 additions & 0 deletions wafer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@
# The form used for talk submission
WAFER_TALK_FORM = 'wafer.talks.forms.TalkForm'

# Languages the talks can be in
WAFER_TALK_LANGUAGES = ()

# Ask speakers for video release, and an email address of a reviewer
WAFER_VIDEO = True
WAFER_VIDEO_REVIEWER = True
Expand Down
8 changes: 4 additions & 4 deletions wafer/talks/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ def f(modeladmin, request, queryset):

class TalkAdmin(CompareVersionAdmin):
list_display = ('title', 'get_corresponding_author_name',
'get_corresponding_author_contact', 'talk_type',
'get_in_schedule', 'has_url', 'status',
'get_corresponding_author_contact', 'language',
'talk_type', 'get_in_schedule', 'has_url', 'status',
'review_count', 'review_score')
list_editable = ('status',)
list_filter = ('status', 'talk_type', 'track', ScheduleListFilter,
DateModifiedFilter, HasNotesFilter,)
list_filter = ('status', 'language', 'talk_type', 'track',
ScheduleListFilter, DateModifiedFilter, HasNotesFilter,)
search_fields = ('title',)
autocomplete_fields = ('authors', 'corresponding_author')
exclude = ('kv',)
Expand Down
7 changes: 6 additions & 1 deletion wafer/talks/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def __init__(self, *args, **kwargs):
if not self.user.has_perm('talks.edit_private_notes'):
self.fields.pop('private_notes')

if Talk.LANGUAGES:
self.fields['language'].required = True
else:
self.fields.pop('language')

if not Track.objects.exists():
self.fields.pop('track')

Expand Down Expand Up @@ -131,7 +136,7 @@ def clean_video_reviewer(self):

class Meta:
model = Talk
fields = ('title', 'talk_type', 'track', 'abstract', 'authors',
fields = ('title', 'language', 'talk_type', 'track', 'abstract', 'authors',
'video', 'video_reviewer', 'notes', 'private_notes')
widgets = {
'abstract': MarkItUpWidget(),
Expand Down
20 changes: 20 additions & 0 deletions wafer/talks/migrations/0022_talk_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.23 on 2021-06-03 15:32

from django.conf import settings
from django.db import migrations, models
import wafer.talks.models


class Migration(migrations.Migration):

dependencies = [
('talks', '0021_talk_type_show_speakers'),
]

operations = [
migrations.AddField(
model_name='talk',
name='language',
field=models.CharField(blank=True, max_length=5, null=True, verbose_name='language'),
),
]
11 changes: 11 additions & 0 deletions wafer/talks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ class Meta:
track = models.ForeignKey(
Track, verbose_name=_("track"), null=True, blank=True, on_delete=models.SET_NULL)

LANGUAGES = settings.WAFER_TALK_LANGUAGES
DEFAULT_LANGUAGE = LANGUAGES and LANGUAGES[0][0]
language = models.CharField(
verbose_name=_("language"),
max_length=5,
null=True,
blank=True,
choices=LANGUAGES,
default=DEFAULT_LANGUAGE,
)

title = models.CharField(_("title"), max_length=1024)

abstract = MarkupField(
Expand Down
8 changes: 8 additions & 0 deletions wafer/talks/templates/wafer.talks/talk.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ <h1>
{% endfor %}
{% endif %}

{% if object.language %}
<p>
{% blocktrans trimmed with language=object.get_language_display %}
Language:
{{ language }}
{% endblocktrans %}
</p>
{% endif %}
{% if object.track %}
<p>
{% blocktrans trimmed with track=object.track.name %}
Expand Down

0 comments on commit edbd1a2

Please sign in to comment.