diff --git a/openslides/agenda/migrations/0002_duration.py b/openslides/agenda/migrations/0002_duration.py
new file mode 100644
index 000000000..3c183544f
--- /dev/null
+++ b/openslides/agenda/migrations/0002_duration.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.1 on 2016-09-22 11:08
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+def convert_duration(apps, schema_editor):
+ Item = apps.get_model('agenda', 'item')
+ for item in Item.objects.all():
+ duration = item.duration
+
+ item.duration_tmp = None
+ if is_int(duration):
+ # assuming that these are minutes
+ item.duration_tmp = int(duration)
+ else:
+ split = duration.split(':')
+ # assuming format (h)h:(m)m
+ if len(split) == 2 and is_int(split[0]) and is_int(split[1]):
+ # duration = hours * 60 + minutes
+ item.duration_tmp = int(split[0]) * 60 + int(split[1])
+ item.save()
+
+
+def is_int(s):
+ try:
+ int(s)
+ return True
+ except ValueError:
+ return False
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('agenda', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='item',
+ name='duration_tmp',
+ field=models.IntegerField(blank=True, null=True),
+ ),
+ migrations.RunPython(convert_duration),
+ migrations.RemoveField(
+ model_name='item',
+ name='duration',
+ ),
+ migrations.RenameField(
+ model_name='item',
+ old_name='duration_tmp',
+ new_name='duration',
+ ),
+ ]
diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py
index 8e1564187..a97d9701a 100644
--- a/openslides/agenda/models.py
+++ b/openslides/agenda/models.py
@@ -220,7 +220,7 @@ class Item(RESTModelMixin, models.Model):
See Item.ITEM_TYPE for more information.
"""
- duration = models.CharField(null=True, blank=True, max_length=5)
+ duration = models.IntegerField(null=True, blank=True)
"""
The intended duration for the topic.
"""
diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js
index 31be6db39..5c9e06eb5 100644
--- a/openslides/agenda/static/js/agenda/site.js
+++ b/openslides/agenda/static/js/agenda/site.js
@@ -112,6 +112,31 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
});
$scope.alert = {};
+ $scope.sumDurations = function () {
+ var totalDuration = 0;
+ $scope.items.forEach(function (item) {
+ if (item.duration) {
+ totalDuration += item.duration;
+ }
+ });
+ return totalDuration;
+ };
+
+ $scope.calculateEndTime = function () {
+ var totalDuration = $scope.sumDurations();
+ var startTime = $scope.config('agenda_start_event_date_time');
+ // This date-time has a fixed structure: DD.MM.YYYY HH:MM
+ if (startTime) {
+ var timestamp = Date.parse(startTime) + totalDuration * 60 * 1000;
+ var endDate = new Date(timestamp);
+ var mm = ("0"+endDate.getMinutes()).slice(-2);
+ var dateStr = endDate.getHours() + ':' + mm;
+ return dateStr;
+ } else {
+ return '';
+ }
+ };
+
// pagination
$scope.currentPage = 1;
$scope.itemsPerPage = 100;
diff --git a/openslides/agenda/static/templates/agenda/item-list.html b/openslides/agenda/static/templates/agenda/item-list.html
index fb6a0469c..e29581c04 100644
--- a/openslides/agenda/static/templates/agenda/item-list.html
+++ b/openslides/agenda/static/templates/agenda/item-list.html
@@ -134,6 +134,12 @@