From 164396a97800695be4579897768cb8fd066540f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Wed, 27 Sep 2017 21:53:35 +0200 Subject: [PATCH] fix talks materials and video --- cfp/forms.py | 6 +++--- cfp/models.py | 12 ++++-------- cfp/templates/cfp/staff/talk_details.html | 4 ++-- cfp/templates/cfp/staff/talk_form.html | 2 +- cfp/templates/cfp/staff/talk_list.html | 2 ++ cfp/templatetags/cfp_tags.py | 3 ++- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cfp/forms.py b/cfp/forms.py index 666a290..0ea6d62 100644 --- a/cfp/forms.py +++ b/cfp/forms.py @@ -28,7 +28,6 @@ class TalkForm(forms.ModelForm): def __init__(self, *args, **kwargs): categories = kwargs.pop('categories') super().__init__(*args, **kwargs) - self.fields['materials'].required = False if categories.exists(): self.fields['category'].queryset = categories else: @@ -36,7 +35,7 @@ class TalkForm(forms.ModelForm): class Meta: model = Talk - fields = ('category', 'title', 'description','notes') + fields = ('category', 'title', 'description', 'notes') class TalkStaffForm(forms.ModelForm): @@ -46,11 +45,12 @@ class TalkStaffForm(forms.ModelForm): self.fields['category'].queryset = TalkCategory.objects.filter(site=conference.site) self.fields['track'].queryset = Track.objects.filter(site=conference.site) self.fields['room'].queryset = Room.objects.filter(site=conference.site) + self.fields['materials'].required = False if self.instance and self.instance.category and self.instance.category.duration: self.fields['duration'].help_text = _('Default duration: %(duration)d min') % {'duration': self.instance.duration} class Meta(TalkForm.Meta): - fields = ('category', 'track', 'title', 'description', 'notes', 'start_date', 'duration', 'room',) + fields = ('category', 'track', 'title', 'description', 'notes', 'start_date', 'duration', 'room', 'materials', 'video',) labels = { 'category': _('Category'), 'title': _('Title'), diff --git a/cfp/models.py b/cfp/models.py index 1077e00..3861f28 100644 --- a/cfp/models.py +++ b/cfp/models.py @@ -14,7 +14,7 @@ from colorful.fields import RGBColorField import uuid from datetime import timedelta -from os.path import join +from os.path import join, basename from ponyconf.utils import PonyConfModel from mailing.models import MessageThread @@ -241,10 +241,6 @@ class TalkCategory(models.Model): # type of talk (conf 30min, 1h, stand, …) # return self.get_name() -#def talk_materials_destination(talk, filename): -# return join(talk.site.name, talk.slug, filename) - - class TalkManager(models.Manager): def get_queryset(self): qs = super().get_queryset() @@ -325,9 +321,9 @@ class Talk(PonyConfModel): else: return None - #@property - #def materials_name(self): - # return basename(self.materials.name) + @property + def materials_name(self): + return basename(self.materials.name) class Meta: ordering = ('category__id', 'title',) diff --git a/cfp/templates/cfp/staff/talk_details.html b/cfp/templates/cfp/staff/talk_details.html index 5d9c21d..3e8f386 100644 --- a/cfp/templates/cfp/staff/talk_details.html +++ b/cfp/templates/cfp/staff/talk_details.html @@ -44,7 +44,8 @@ {% if talk.registration_required %}
{% trans "Registrations" %}
{% if talk.attendees_limit %}{{ talk.attendees.count }} / {{ talk.attendees_limit }}{% else %}{% trans "required but unlimited" %}{% endif %}
- {% endif %} + {% endif % + {% endcomment %} {% if talk.materials %}
{% trans "Materials" %}
{{ talk.materials_name }}
@@ -53,7 +54,6 @@
{% trans "Video" %}
{% trans "download" %}
{% endif %} - {% endcomment %} diff --git a/cfp/templates/cfp/staff/talk_form.html b/cfp/templates/cfp/staff/talk_form.html index 6123e62..74f02da 100644 --- a/cfp/templates/cfp/staff/talk_form.html +++ b/cfp/templates/cfp/staff/talk_form.html @@ -8,6 +8,6 @@

{% trans "Edit a talk" %}

{% url 'talk-details' talk.token as cancel_url %} -{% include '_form.html' %} +{% include '_form.html' with multipart=True %} {% endblock %} diff --git a/cfp/templates/cfp/staff/talk_list.html b/cfp/templates/cfp/staff/talk_list.html index a861c2a..12eca28 100644 --- a/cfp/templates/cfp/staff/talk_list.html +++ b/cfp/templates/cfp/staff/talk_list.html @@ -19,6 +19,8 @@ {% bootstrap_field filter_form.vote layout="horizontal" %} {% bootstrap_field filter_form.scheduled layout="horizontal" %} {% bootstrap_field filter_form.room layout="horizontal" %} + {% bootstrap_field filter_form.materials layout="horizontal" %} + {% bootstrap_field filter_form.video layout="horizontal" %}
{% bootstrap_field filter_form.track layout="horizontal" %} diff --git a/cfp/templatetags/cfp_tags.py b/cfp/templatetags/cfp_tags.py index 297676d..11ae8a6 100644 --- a/cfp/templatetags/cfp_tags.py +++ b/cfp/templatetags/cfp_tags.py @@ -10,7 +10,8 @@ register = template.Library() def staff(request): return is_staff(request, request.user) -@register.filter('duration_format') + +@register.filter(name='duration_format') def duration_format(value): value = int(value) hours = int(value/60)