forked from AFPy/PonyConf
track duration
This commit is contained in:
parent
b9f3fbfd7e
commit
026ee568e4
|
@ -30,7 +30,7 @@ class TalkForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = Talk
|
||||
fields = ['title', 'abstract', 'description', 'topics', 'track', 'notes', 'event', 'speakers']
|
||||
fields = ['title', 'abstract', 'description', 'topics', 'track', 'notes', 'event', 'duration', 'speakers']
|
||||
widgets = {'topics': forms.CheckboxSelectMultiple(), 'speakers': Select2TagWidget()}
|
||||
help_texts = {
|
||||
'abstract': _('Should be less than 255 characters'),
|
||||
|
|
25
proposals/migrations/0015_auto_20161005_1932.py
Normal file
25
proposals/migrations/0015_auto_20161005_1932.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10 on 2016-10-05 19:32
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('proposals', '0014_track_managers'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='duration',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='talk',
|
||||
name='duration',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
|
@ -49,6 +49,9 @@ class Track(PonyConfModel):
|
|||
class Meta:
|
||||
unique_together = ('site', 'name')
|
||||
|
||||
def estimated_duration(self):
|
||||
return sum([talk.estimated_duration() for talk in self.talk_set.all()])
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -81,6 +84,7 @@ class Event(models.Model):
|
|||
|
||||
site = models.ForeignKey(Site, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=64)
|
||||
duration = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('site', 'name')
|
||||
|
@ -108,6 +112,7 @@ class Talk(PonyConfModel):
|
|||
notes = models.TextField(blank=True, verbose_name=_('Notes'))
|
||||
event = models.ForeignKey(Event, verbose_name=_('Intervention kind'))
|
||||
accepted = models.NullBooleanField(default=None)
|
||||
duration = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
|
@ -115,6 +120,9 @@ class Talk(PonyConfModel):
|
|||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def estimated_duration(self):
|
||||
return self.duration or self.event.duration
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('show-talk', kwargs={'slug': self.slug})
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load bootstrap3 accounts_tags i18n %}
|
||||
{% load bootstrap3 accounts_tags proposals_tags i18n %}
|
||||
|
||||
{% block tracktab %} class="active"{% endblock %}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
|||
<a href="{{ track.get_absolute_url }}">{{ track.talk_set.count }} {% trans "talk" %}{{ track.talk_set.count|pluralize }}</a>
|
||||
|
|
||||
<a href="{% url 'edit-track' track.slug %}">{% bootstrap_icon "pencil" %}</a>
|
||||
|
|
||||
{{ track.estimated_duration|duration_format }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% cycle '' '<div class="clearfix visible-xs"></div>' %}
|
||||
|
|
|
@ -9,3 +9,10 @@ register = template.Library()
|
|||
@register.simple_tag
|
||||
def markdown(value):
|
||||
return markdown_to_html(value)
|
||||
|
||||
@register.filter('duration_format')
|
||||
def duration_format(value):
|
||||
value = int(value)
|
||||
hours = int(value/60)
|
||||
minutes = value%60
|
||||
return '%d h %02d' % (hours, minutes)
|
||||
|
|
|
@ -153,10 +153,12 @@ def talk_edit(request, talk=None):
|
|||
form.fields['topics'].disabled = True
|
||||
if not talk.is_editable_by(request.user):
|
||||
form.fields.pop('track')
|
||||
form.fields.pop('duration')
|
||||
else:
|
||||
form.fields['speakers'].initial = [request.user]
|
||||
if not is_orga(request, request.user):
|
||||
form.fields.pop('track')
|
||||
form.fields.pop('duration')
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
if hasattr(talk, 'id'):
|
||||
talk = form.save()
|
||||
|
|
Loading…
Reference in New Issue
Block a user