diff --git a/AUTHORS b/AUTHORS index f4eeb7de7..b1c6e1f79 100644 --- a/AUTHORS +++ b/AUTHORS @@ -7,3 +7,4 @@ Authors of OpenSlides in chronological order of first contribution: Andy Kittner Moira BrĂ¼lisauer (French translation) Alexis Roussel (French translation) + Stefan Frauenknecht diff --git a/THANKS b/THANKS index 82e322535..f0ed4bea3 100644 --- a/THANKS +++ b/THANKS @@ -8,12 +8,16 @@ OpenSlides uses parts of the following projects: * jQuery + and some addons: cookie, form, once, templating * jQuery UI + custom ui components: core, widget, mouse, sortable, datepicker, slider + with css theme 'smoothness' + and some addons: slider access, timepicker * Twitter Bootstrap - + * ReportLab diff --git a/openslides/agenda/forms.py b/openslides/agenda/forms.py index 66a4ee7a7..098e949de 100644 --- a/openslides/agenda/forms.py +++ b/openslides/agenda/forms.py @@ -10,14 +10,14 @@ :license: GNU GPL, see LICENSE for more details. """ +import re + from django import forms from django.utils.translation import ugettext_lazy as _ - from mptt.forms import TreeNodeChoiceField from openslides.utils.forms import CssClassMixin - -from openslides.agenda.models import Item +from .models import Item class ItemForm(forms.ModelForm, CssClassMixin): @@ -27,6 +27,13 @@ class ItemForm(forms.ModelForm, CssClassMixin): parent = TreeNodeChoiceField( queryset=Item.objects.all(), label=_("Parent item"), required=False) + duration = forms.RegexField( + regex=re.compile('[0-99]:[0-5][0-9]'), + error_message=_("Invalid format. Hours from 0 to 99 and minutes from 00 to 59"), + max_length=5, + required=False, + label=_("Duration (hh:mm)")) + class Meta: model = Item exclude = ('closed', 'weight', 'related_sid') @@ -45,11 +52,15 @@ class ItemOrderForm(forms.Form, CssClassMixin): """ weight = forms.ChoiceField( choices=gen_weight_choices(), - widget=forms.Select(attrs={'class': 'menu-weight'}), - ) + widget=forms.Select(attrs={'class': 'menu-weight'})) self = forms.IntegerField( - widget=forms.HiddenInput(attrs={'class': 'menu-mlid'}), - ) + widget=forms.HiddenInput(attrs={'class': 'menu-mlid'})) parent = forms.IntegerField( - widget=forms.HiddenInput(attrs={'class': 'menu-plid'}), - ) + widget=forms.HiddenInput(attrs={'class': 'menu-plid'})) + + +class ConfigForm(CssClassMixin, forms.Form): + agenda_start_event_date_time = forms.CharField( + widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'), + required=False, + label=_("Begin of event")) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 0356607dd..a7c27c616 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -20,7 +20,7 @@ from openslides.config.models import config from openslides.projector.projector import SlideMixin from openslides.projector.api import ( register_slidemodel, get_slide_from_sid, register_slidefunc) -from openslides.agenda.slides import agenda_show +from .slides import agenda_show class Item(MPTTModel, SlideMixin): @@ -31,6 +31,13 @@ class Item(MPTTModel, SlideMixin): """ prefix = 'item' + AGENDA_ITEM = 1 + ORGANIZATIONAL_ITEM = 2 + + ITEM_TYPE = ( + (AGENDA_ITEM, _('Agenda item')), + (ORGANIZATIONAL_ITEM, _('Organizational item'))) + title = models.CharField(null=True, max_length=255, verbose_name=_("Title")) text = models.TextField(null=True, blank=True, verbose_name=_("Text")) comment = models.TextField(null=True, blank=True, verbose_name=_("Comment")) @@ -38,6 +45,8 @@ class Item(MPTTModel, SlideMixin): weight = models.IntegerField(default=0, verbose_name=_("Weight")) parent = TreeForeignKey('self', null=True, blank=True, related_name='children') + type = models.IntegerField(max_length=1, choices=ITEM_TYPE, default=AGENDA_ITEM, verbose_name=_("Type")) + duration = models.CharField(null=True, blank=True, max_length=5, verbose_name=_("Duration (hh:mm)")) related_sid = models.CharField(null=True, blank=True, max_length=63) def get_related_slide(self): @@ -170,6 +179,7 @@ class Item(MPTTModel, SlideMixin): permissions = ( ('can_see_agenda', ugettext_noop("Can see agenda")), ('can_manage_agenda', ugettext_noop("Can manage agenda")), + ('can_see_orga_items', ugettext_noop("Can see orga items and time scheduling of agenda")), ) class MPTTMeta: diff --git a/openslides/agenda/slides.py b/openslides/agenda/slides.py index c7e24aacd..51acb35c2 100644 --- a/openslides/agenda/slides.py +++ b/openslides/agenda/slides.py @@ -16,7 +16,7 @@ from django.utils.translation import ugettext as _ def agenda_show(): from openslides.agenda.models import Item data = {} - items = Item.objects.filter(parent=None) + items = Item.objects.filter(parent=None, type__exact=Item.AGENDA_ITEM) data['title'] = _("Agenda") data['items'] = items data['template'] = 'projector/AgendaSummary.html' diff --git a/openslides/agenda/static/javascript/jquery-ui-sliderAccess.js b/openslides/agenda/static/javascript/jquery-ui-sliderAccess.js new file mode 100644 index 000000000..a54cf4ab9 --- /dev/null +++ b/openslides/agenda/static/javascript/jquery-ui-sliderAccess.js @@ -0,0 +1,89 @@ +/* + * jQuery UI Slider Access + * By: Trent Richardson [http://trentrichardson.com] + * Version 0.3 + * Last Modified: 10/20/2012 + * + * Copyright 2011 Trent Richardson + * Dual licensed under the MIT and GPL licenses. + * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt + * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt + * + */ + (function($){ + + $.fn.extend({ + sliderAccess: function(options){ + options = options || {}; + options.touchonly = options.touchonly !== undefined? options.touchonly : true; // by default only show it if touch device + + if(options.touchonly === true && !("ontouchend" in document)) + return $(this); + + return $(this).each(function(i,obj){ + var $t = $(this), + o = $.extend({},{ + where: 'after', + step: $t.slider('option','step'), + upIcon: 'ui-icon-plus', + downIcon: 'ui-icon-minus', + text: false, + upText: '+', + downText: '-', + buttonset: true, + buttonsetTag: 'span', + isRTL: false + }, options), + $buttons = $('<'+ o.buttonsetTag +' class="ui-slider-access">'+ + ''+ + ''+ + ''); + + $buttons.children('button').each(function(j, jobj){ + var $jt = $(this); + $jt.button({ + text: o.text, + icons: { primary: $jt.data('icon') } + }) + .click(function(e){ + var step = $jt.data('step'), + curr = $t.slider('value'), + newval = curr += step*1, + minval = $t.slider('option','min'), + maxval = $t.slider('option','max'), + slidee = $t.slider("option", "slide") || function(){}, + stope = $t.slider("option", "stop") || function(){}; + + e.preventDefault(); + + if(newval < minval || newval > maxval) + return; + + $t.slider('value', newval); + + slidee.call($t, null, { value: newval }); + stope.call($t, null, { value: newval }); + }); + }); + + // before or after + $t[o.where]($buttons); + + if(o.buttonset){ + $buttons.removeClass('ui-corner-right').removeClass('ui-corner-left').buttonset(); + $buttons.eq(0).addClass('ui-corner-left'); + $buttons.eq(1).addClass('ui-corner-right'); + } + + // adjust the width so we don't break the original layout + var bOuterWidth = $buttons.css({ + marginLeft: ((o.where == 'after' && !o.isRTL) || (o.where == 'before' && o.isRTL)? 10:0), + marginRight: ((o.where == 'before' && !o.isRTL) || (o.where == 'after' && o.isRTL)? 10:0) + }).outerWidth(true) + 5; + var tOuterWidth = $t.outerWidth(true); + $t.css('display','inline-block').width(tOuterWidth-bOuterWidth); + }); + } + }); + +})(jQuery); \ No newline at end of file diff --git a/openslides/agenda/static/javascript/jquery-ui-timepicker-addon.js b/openslides/agenda/static/javascript/jquery-ui-timepicker-addon.js new file mode 100644 index 000000000..f9b5faa2d --- /dev/null +++ b/openslides/agenda/static/javascript/jquery-ui-timepicker-addon.js @@ -0,0 +1,1919 @@ +/* + * jQuery timepicker addon + * By: Trent Richardson [http://trentrichardson.com] + * Version 1.2 + * Last Modified: 02/02/2013 + * + * Copyright 2013 Trent Richardson + * You may use this project under MIT or GPL licenses. + * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt + * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt + */ + +/*jslint evil: true, white: false, undef: false, nomen: false */ + +(function($) { + + /* + * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" + */ + $.ui.timepicker = $.ui.timepicker || {}; + if ($.ui.timepicker.version) { + return; + } + + /* + * Extend jQueryUI, get it started with our version number + */ + $.extend($.ui, { + timepicker: { + version: "1.2" + } + }); + + /* + * Timepicker manager. + * Use the singleton instance of this class, $.timepicker, to interact with the time picker. + * Settings for (groups of) time pickers are maintained in an instance object, + * allowing multiple different settings on the same page. + */ + var Timepicker = function() { + this.regional = []; // Available regional settings, indexed by language code + this.regional[''] = { // Default regional settings + currentText: 'Now', + closeText: 'Done', + amNames: ['AM', 'A'], + pmNames: ['PM', 'P'], + timeFormat: 'HH:mm', + timeSuffix: '', + timeOnlyTitle: 'Choose Time', + timeText: 'Time', + hourText: 'Hour', + minuteText: 'Minute', + secondText: 'Second', + millisecText: 'Millisecond', + timezoneText: 'Time Zone', + isRTL: false + }; + this._defaults = { // Global defaults for all the datetime picker instances + showButtonPanel: true, + timeOnly: false, + showHour: true, + showMinute: true, + showSecond: false, + showMillisec: false, + showTimezone: false, + showTime: true, + stepHour: 1, + stepMinute: 1, + stepSecond: 1, + stepMillisec: 1, + hour: 0, + minute: 0, + second: 0, + millisec: 0, + timezone: null, + useLocalTimezone: false, + defaultTimezone: "+0000", + hourMin: 0, + minuteMin: 0, + secondMin: 0, + millisecMin: 0, + hourMax: 23, + minuteMax: 59, + secondMax: 59, + millisecMax: 999, + minDateTime: null, + maxDateTime: null, + onSelect: null, + hourGrid: 0, + minuteGrid: 0, + secondGrid: 0, + millisecGrid: 0, + alwaysSetTime: true, + separator: ' ', + altFieldTimeOnly: true, + altTimeFormat: null, + altSeparator: null, + altTimeSuffix: null, + pickerTimeFormat: null, + pickerTimeSuffix: null, + showTimepicker: true, + timezoneIso8601: false, + timezoneList: null, + addSliderAccess: false, + sliderAccessArgs: null, + controlType: 'slider', + defaultValue: null, + parse: 'strict' + }; + $.extend(this._defaults, this.regional['']); + }; + + $.extend(Timepicker.prototype, { + $input: null, + $altInput: null, + $timeObj: null, + inst: null, + hour_slider: null, + minute_slider: null, + second_slider: null, + millisec_slider: null, + timezone_select: null, + hour: 0, + minute: 0, + second: 0, + millisec: 0, + timezone: null, + defaultTimezone: "+0000", + hourMinOriginal: null, + minuteMinOriginal: null, + secondMinOriginal: null, + millisecMinOriginal: null, + hourMaxOriginal: null, + minuteMaxOriginal: null, + secondMaxOriginal: null, + millisecMaxOriginal: null, + ampm: '', + formattedDate: '', + formattedTime: '', + formattedDateTime: '', + timezoneList: null, + units: ['hour','minute','second','millisec'], + control: null, + + /* + * Override the default settings for all instances of the time picker. + * @param settings object - the new settings to use as defaults (anonymous object) + * @return the manager object + */ + setDefaults: function(settings) { + extendRemove(this._defaults, settings || {}); + return this; + }, + + /* + * Create a new Timepicker instance + */ + _newInst: function($input, o) { + var tp_inst = new Timepicker(), + inlineSettings = {}, + fns = {}, + overrides, i; + + for (var attrName in this._defaults) { + if(this._defaults.hasOwnProperty(attrName)){ + var attrValue = $input.attr('time:' + attrName); + if (attrValue) { + try { + inlineSettings[attrName] = eval(attrValue); + } catch (err) { + inlineSettings[attrName] = attrValue; + } + } + } + } + overrides = { + beforeShow: function (input, dp_inst) { + if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) { + return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst); + } + }, + onChangeMonthYear: function (year, month, dp_inst) { + // Update the time as well : this prevents the time from disappearing from the $input field. + tp_inst._updateDateTime(dp_inst); + if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { + tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); + } + }, + onClose: function (dateText, dp_inst) { + if (tp_inst.timeDefined === true && $input.val() !== '') { + tp_inst._updateDateTime(dp_inst); + } + if ($.isFunction(tp_inst._defaults.evnts.onClose)) { + tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst); + } + } + }; + for (i in overrides) { + if (overrides.hasOwnProperty(i)) { + fns[i] = o[i] || null; + } + } + tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, { + evnts:fns, + timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); + }); + tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { + return val.toUpperCase(); + }); + tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { + return val.toUpperCase(); + }); + + // controlType is string - key to our this._controls + if(typeof(tp_inst._defaults.controlType) === 'string'){ + if($.fn[tp_inst._defaults.controlType] === undefined){ + tp_inst._defaults.controlType = 'select'; + } + tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType]; + } + // controlType is an object and must implement create, options, value methods + else{ + tp_inst.control = tp_inst._defaults.controlType; + } + + if (tp_inst._defaults.timezoneList === null) { + var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000', + '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930', + '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400']; + + if (tp_inst._defaults.timezoneIso8601) { + timezoneList = $.map(timezoneList, function(val) { + return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3)); + }); + } + tp_inst._defaults.timezoneList = timezoneList; + } + + tp_inst.timezone = tp_inst._defaults.timezone; + tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin : + tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour; + tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin : + tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute; + tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin : + tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second; + tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin : + tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec; + tp_inst.ampm = ''; + tp_inst.$input = $input; + + if (o.altField) { + tp_inst.$altInput = $(o.altField).css({ + cursor: 'pointer' + }).focus(function() { + $input.trigger("focus"); + }); + } + + if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { + tp_inst._defaults.minDate = new Date(); + } + if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) { + tp_inst._defaults.maxDate = new Date(); + } + + // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. + if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) { + tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); + } + if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) { + tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime()); + } + if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) { + tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime()); + } + if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) { + tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime()); + } + tp_inst.$input.bind('focus', function() { + tp_inst._onFocus(); + }); + + return tp_inst; + }, + + /* + * add our sliders to the calendar + */ + _addTimePicker: function(dp_inst) { + var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); + + this.timeDefined = this._parseTime(currDT); + this._limitMinMaxDateTime(dp_inst, false); + this._injectTimePicker(); + }, + + /* + * parse the time string from input value or _setTime + */ + _parseTime: function(timeString, withDate) { + if (!this.inst) { + this.inst = $.datepicker._getInst(this.$input[0]); + } + + if (withDate || !this._defaults.timeOnly) { + var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); + try { + var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults); + if (!parseRes.timeObj) { + return false; + } + $.extend(this, parseRes.timeObj); + } catch (err) { + $.timepicker.log("Error parsing the date/time string: " + err + + "\ndate/time string = " + timeString + + "\ntimeFormat = " + this._defaults.timeFormat + + "\ndateFormat = " + dp_dateFormat); + return false; + } + return true; + } else { + var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults); + if (!timeObj) { + return false; + } + $.extend(this, timeObj); + return true; + } + }, + + /* + * generate and inject html for timepicker into ui datepicker + */ + _injectTimePicker: function() { + var $dp = this.inst.dpDiv, + o = this.inst.settings, + tp_inst = this, + litem = '', + uitem = '', + max = {}, + gridSize = {}, + size = null; + + // Prevent displaying twice + if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { + var noDisplay = ' style="display:none;"', + html = '
' + '
' + o.timeText + '
' + + '
'; + + // Create the markup + for(var i=0,l=this.units.length; i' + o[litem +'Text'] + '' + + '
'; + + if (o['show'+uitem] && o[litem+'Grid'] > 0) { + html += '
'; + + if(litem == 'hour'){ + for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) { + gridSize[litem]++; + var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o); + html += ''; + } + } + else{ + for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) { + gridSize[litem]++; + html += ''; + } + } + + html += '
' + tmph + '' + ((m < 10) ? '0' : '') + m + '
'; + } + html += '
'; + } + + // Timezone + html += '
' + o.timezoneText + '
'; + html += '
'; + + // Create the elements from string + html += '
'; + var $tp = $(html); + + // if we only want time picker... + if (o.timeOnly === true) { + $tp.prepend('
' + '
' + o.timeOnlyTitle + '
' + '
'); + $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); + } + + // add sliders, adjust grids, add events + for(var i=0,l=tp_inst.units.length; i 0) { + size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']); + $tp.find('.ui_tpicker_'+litem+' table').css({ + width: size + "%", + marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"), + marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0', + borderCollapse: 'collapse' + }).find("td").click(function(e){ + var $t = $(this), + h = $t.html(), + n = parseInt(h.replace(/[^0-9]/g),10), + ap = h.replace(/[^apm]/ig), + f = $t.data('for'); // loses scope, so we use data-for + + if(f == 'hour'){ + if(ap.indexOf('p') !== -1 && n < 12){ + n += 12; + } + else{ + if(ap.indexOf('a') !== -1 && n === 12){ + n = 0; + } + } + } + + tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n); + + tp_inst._onTimeChange(); + tp_inst._onSelectHandler(); + }) + .css({ + cursor: 'pointer', + width: (100 / gridSize[litem]) + '%', + textAlign: 'center', + overflow: 'hidden' + }); + } // end if grid > 0 + } // end for loop + + // Add timezone options + this.timezone_select = $tp.find('.ui_tpicker_timezone').append('').find("select"); + $.fn.append.apply(this.timezone_select, + $.map(o.timezoneList, function(val, idx) { + return $("