From 9cec272090ae47a0d4019ad211b4d215f2409dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Mon, 16 Jan 2017 23:14:50 +0100 Subject: [PATCH] talk: video field --- planning/utils.py | 10 ++++++++++ proposals/forms.py | 3 ++- proposals/migrations/0002_talk_video.py | 20 +++++++++++++++++++ proposals/models.py | 1 + .../templates/proposals/talk_detail.html | 4 ++++ proposals/templates/proposals/talk_list.html | 1 + proposals/views.py | 11 ++++++++++ 7 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 proposals/migrations/0002_talk_video.py diff --git a/planning/utils.py b/planning/utils.py index 4184d32..646d387 100644 --- a/planning/utils.py +++ b/planning/utils.py @@ -234,6 +234,16 @@ class Program: 'max': talk.attendees_limit, 'remain': talk.remaining_attendees or 0, } + if talk.materials: + links += mark_safe(""" + %(link)s""" % { + 'link': talk.materials.url, + }) + if talk.video: + links += mark_safe(""" + %(link)s""" % { + 'link': talk.video, + }) days_xml += """ %(start)s %(duration)s diff --git a/proposals/forms.py b/proposals/forms.py index 7403ddf..40db163 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -40,7 +40,7 @@ class TalkForm(forms.ModelForm): class Meta: model = Talk - fields = ['title', 'abstract', 'description', 'topics', 'track', 'notes', 'event', 'speakers', 'materials', 'duration', 'start_date', 'room', 'registration_required', 'attendees_limit'] + fields = ['title', 'abstract', 'description', 'topics', 'track', 'notes', 'event', 'speakers', 'materials', 'video', 'duration', 'start_date', 'room', 'registration_required', 'attendees_limit'] widgets = {'topics': forms.CheckboxSelectMultiple(), 'speakers': Select2TagWidget()} help_texts = { 'abstract': _('Should be less than 255 characters'), @@ -73,6 +73,7 @@ class TalkFilterForm(forms.Form): room = forms.NullBooleanField(help_text=_('Filter talks already / not yet affected to a room')) scheduled = forms.NullBooleanField(help_text=_('Filter talks already / not yet scheduled')) materials = forms.NullBooleanField(help_text=_('Filter talks with / without materials')) + video = forms.NullBooleanField(help_text=_('Filter talks with / without video')) def __init__(self, *args, **kwargs): site = kwargs.pop('site') diff --git a/proposals/migrations/0002_talk_video.py b/proposals/migrations/0002_talk_video.py new file mode 100644 index 0000000..5c085cb --- /dev/null +++ b/proposals/migrations/0002_talk_video.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-01-16 21:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('proposals', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='talk', + name='video', + field=models.URLField(blank=True, default='', max_length=1000, verbose_name='URL vidéo'), + ), + ] diff --git a/proposals/models.py b/proposals/models.py index c06a0b4..9ee3d53 100644 --- a/proposals/models.py +++ b/proposals/models.py @@ -170,6 +170,7 @@ class Talk(PonyConfModel): attendees_limit = models.PositiveIntegerField(default=0, verbose_name=_('Max. number of attendees')) materials = models.FileField(null=True, upload_to=talk_materials_destination, verbose_name=_('Materials'), help_text=_('You can use this field to share some materials related to your intervention.')) + video = models.URLField(max_length=1000, blank=True, default='', verbose_name='URL vidéo') class Meta: ordering = ('title',) diff --git a/proposals/templates/proposals/talk_detail.html b/proposals/templates/proposals/talk_detail.html index 62e23c1..e95e19d 100644 --- a/proposals/templates/proposals/talk_detail.html +++ b/proposals/templates/proposals/talk_detail.html @@ -60,6 +60,10 @@
{% trans "Materials" %}
{{ talk.materials_name }}
{% endif %} + {% if talk.video %} +
{% trans "Video" %}
+
{% trans "download" %}
+ {% endif %} diff --git a/proposals/templates/proposals/talk_list.html b/proposals/templates/proposals/talk_list.html index 1ca178b..4a12d8f 100644 --- a/proposals/templates/proposals/talk_list.html +++ b/proposals/templates/proposals/talk_list.html @@ -23,6 +23,7 @@ {% bootstrap_field filter_form.room layout="horizontal" %} {% bootstrap_field filter_form.scheduled layout="horizontal" %} {% bootstrap_field filter_form.materials layout="horizontal" %} + {% bootstrap_field filter_form.video layout="horizontal" %}
{% bootstrap_field filter_form.topic layout="horizontal" %} diff --git a/proposals/views.py b/proposals/views.py index 3ce0504..e6bcfea 100644 --- a/proposals/views.py +++ b/proposals/views.py @@ -98,16 +98,26 @@ def talk_list(request): q |= Q(track__slug__in=data['track']) talks = talks.filter(q) if data['vote'] != None: + show_filters = True if data['vote']: talks = talks.filter(vote__user=request.user) else: talks = talks.exclude(vote__user=request.user) if data['room'] != None: + show_filters = True talks = talks.filter(room__isnull=not data['room']) if data['scheduled'] != None: + show_filters = True talks = talks.filter(start_date__isnull=not data['scheduled']) if data['materials'] != None: + show_filters = True talks = talks.filter(materials__isnull=not data['materials']) + if data['video'] != None: + show_filters = True + if data['video']: + talks = talks.exclude(video__exact='') + else: + talks = talks.filter(video__exact='') # Action action_form = TalkActionForm(request.POST or None, talks=talks, site=get_current_site(request)) if not is_orga(request, request.user): @@ -205,6 +215,7 @@ def talk_edit(request, talk=None): talk.room.capacity) % {'room': talk.room.name, 'capacity': talk.room.capacity} else: form.fields.pop('materials') + form.fields.pop('video') form.fields['speakers'].initial = [request.user] if request.method == 'POST' and form.is_valid(): if hasattr(talk, 'id'):