Commit 905d7119229fc5cfb9159f794503f4aae9363fb8

Authored by Luan
1 parent f40f5197

Adding bootstrap datepicker to project and filtering by date

src/search/forms.py
... ... @@ -37,6 +37,8 @@ class ColabSearchForm(SearchForm):
37 37 name = forms.CharField(required=False, label=_(u'Name'))
38 38 institution = forms.CharField(required=False, label=_(u'Institution'))
39 39 role = forms.CharField(required=False, label=_(u'Role'))
  40 + since = forms.DateField(required=False, label=_(u'Since'))
  41 + until = forms.DateField(required=False, label=_(u'Until'))
40 42  
41 43 def search(self):
42 44 if not self.is_valid():
... ... @@ -96,6 +98,16 @@ class ColabSearchForm(SearchForm):
96 98 if self.cleaned_data['list']:
97 99 sqs = sqs.filter(tag__in=self.cleaned_data['list'])
98 100  
  101 + since = self.cleaned_data['since']
  102 + until = self.cleaned_data['until']
  103 +
  104 + if since and until:
  105 + sqs = sqs.filter(modified__gte=since, modified__lte=until)
  106 + elif since and not until:
  107 + sqs = sqs.filter(modified__gte=since)
  108 + elif until and not since:
  109 + sqs = sqs.filter(modified__lte=until)
  110 +
99 111 if self.load_all:
100 112 sqs = sqs.load_all()
101 113  
... ...
src/static/third-party/bootstrap-datetimepicker/README 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +This bootstrap extension was copied from
  2 +
  3 +https://github.com/Eonasdan/bootstrap-datetimepicker
  4 +ed42869337753e50adeb4a0e2476bfffc8edf2a9
  5 +
  6 +Distributed under Apache License Version 2.0:
  7 +https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/LICENSE
... ...
src/static/third-party/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +/*!
  2 + * Datepicker for Bootstrap v3
  3 + *
  4 + * Copyright 2012 Stefan Petre
  5 + * Licensed under the Apache License v2.0
  6 + * http://www.apache.org/licenses/LICENSE-2.0
  7 + *
  8 + */
  9 + .bootstrap-datetimepicker-widget{top:0;left:0;z-index:3000;width:250px;padding:4px;margin-top:1px;border-radius:4px}.bootstrap-datetimepicker-widget .btn{padding:6px}.bootstrap-datetimepicker-widget:before{position:absolute;top:-7px;left:6px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.bootstrap-datetimepicker-widget:after{position:absolute;top:-6px;left:7px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid white;border-left:6px solid transparent;content:''}.bootstrap-datetimepicker-widget.pull-right:before{right:6px;left:auto}.bootstrap-datetimepicker-widget.pull-right:after{right:7px;left:auto}.bootstrap-datetimepicker-widget>ul{margin:0;list-style-type:none}.bootstrap-datetimepicker-widget .timepicker-hour,.bootstrap-datetimepicker-widget .timepicker-minute,.bootstrap-datetimepicker-widget .timepicker-second{width:100%;font-size:1.2em;font-weight:bold}.bootstrap-datetimepicker-widget table[data-hour-format="12"] .separator{width:4px;padding:0;margin:0}.bootstrap-datetimepicker-widget .datepicker>div{display:none}.bootstrap-datetimepicker-widget .picker-switch{text-align:center}.bootstrap-datetimepicker-widget table{width:100%;margin:0}.bootstrap-datetimepicker-widget td,.bootstrap-datetimepicker-widget th{width:20px;height:20px;text-align:center;border-radius:4px}.bootstrap-datetimepicker-widget td.day:hover,.bootstrap-datetimepicker-widget td.hour:hover,.bootstrap-datetimepicker-widget td.minute:hover,.bootstrap-datetimepicker-widget td.second:hover{cursor:pointer;background:#eee}.bootstrap-datetimepicker-widget td.old,.bootstrap-datetimepicker-widget td.new{color:#999}.bootstrap-datetimepicker-widget td.active,.bootstrap-datetimepicker-widget td.active:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#428bca}.bootstrap-datetimepicker-widget td.disabled,.bootstrap-datetimepicker-widget td.disabled:hover{color:#999;cursor:not-allowed;background:0}.bootstrap-datetimepicker-widget td span{display:block;float:left;width:47px;height:54px;margin:2px;line-height:54px;cursor:pointer;border-radius:4px}.bootstrap-datetimepicker-widget td span:hover{background:#eee}.bootstrap-datetimepicker-widget td span.active{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#428bca}.bootstrap-datetimepicker-widget td span.old{color:#999}.bootstrap-datetimepicker-widget td span.disabled,.bootstrap-datetimepicker-widget td span.disabled:hover{color:#999;cursor:not-allowed;background:0}.bootstrap-datetimepicker-widget th.switch{width:145px}.bootstrap-datetimepicker-widget th.next,.bootstrap-datetimepicker-widget th.prev{font-size:21px}.bootstrap-datetimepicker-widget th.disabled,.bootstrap-datetimepicker-widget th.disabled:hover{color:#999;cursor:not-allowed;background:0}.bootstrap-datetimepicker-widget thead tr:first-child th{cursor:pointer}.bootstrap-datetimepicker-widget thead tr:first-child th:hover{background:#eee}.input-group.date .input-group-addon span{display:block;width:16px;height:16px;cursor:pointer}.bootstrap-datetimepicker-widget.left-oriented:before{right:6px;left:auto}.bootstrap-datetimepicker-widget.left-oriented:after{right:7px;left:auto}.bootstrap-datetimepicker-widget ul.list-unstyled li.in div.timepicker div.timepicker-picker table.table-condensed tbody>tr>td{padding:0!important}
0 10 \ No newline at end of file
... ...
src/static/third-party/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +/**
  2 + * version 1.0.6
  3 + * @license
  4 + * =========================================================
  5 + * bootstrap-datetimepicker.js
  6 + * http://www.eyecon.ro/bootstrap-datepicker
  7 + * =========================================================
  8 + * Copyright 2012 Stefan Petre
  9 + *
  10 + * Contributions:
  11 + * - Andrew Rowls
  12 + * - Thiago de Arruda
  13 + * - updated for Bootstrap v3 by Jonathan Peterson @Eonasdan
  14 + *
  15 + * Licensed under the Apache License, Version 2.0 (the "License");
  16 + * you may not use this file except in compliance with the License.
  17 + * You may obtain a copy of the License at
  18 + *
  19 + * http://www.apache.org/licenses/LICENSE-2.0
  20 + *
  21 + * Unless required by applicable law or agreed to in writing, software
  22 + * distributed under the License is distributed on an "AS IS" BASIS,
  23 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24 + * See the License for the specific language governing permissions and
  25 + * limitations under the License.
  26 + * =========================================================
  27 + */
  28 +(function(i){var q=(window.orientation!==undefined);var b=function(s,k){this.id=n++;this.init(s,k)};var o=function(k){if(typeof k==="string"){return new Date(k)}return k};b.prototype={constructor:b,init:function(s,k){var t=false;this.useMoment=(typeof moment!="undefined");if(!(k.pickTime||k.pickDate)){throw new Error("Must choose at least one picker")}this.options=k;this.$element=i(s);this.language=k.language in a?k.language:"en";this.pickDate=k.pickDate;this.pickTime=k.pickTime;this.isInput=this.$element.is("input");this.component=false;if(this.$element.hasClass("input-group")){this.component=this.$element.find(".input-group-addon")}this.format=k.format;if(!this.format){if(a[this.language].format!=null){this.format=a[this.language].format}else{if(this.isInput){this.format=this.$element.data("format")}else{this.format=this.$element.find("input").data("format")}}if(!this.format){this.format=(this.pickDate?"MM/dd/yyyy":"")}this.format+=(this.pickTime?" hh:mm":"")+(this.pickSeconds?":ss":"")}this._compileFormat();if(this.component){t=this.component.find("span")}if(this.pickTime){if(t&&t.length){this.timeIcon=t.data("time-icon");this.upIcon=t.data("up-icon");this.downIcon=t.data("down-icon")}if(!this.timeIcon){this.timeIcon="glyphicon glyphicon-time"}if(!this.upIcon){this.upIcon="glyphicon glyphicon-chevron-up"}if(!this.downIcon){this.downIcon="glyphicon glyphicon-chevron-down"}if(t){t.addClass(this.timeIcon)}}if(this.pickDate){if(t&&t.length){this.dateIcon=t.data("date-icon")}if(!this.dateIcon){this.dateIcon="glyphicon glyphicon-calendar"}if(t){t.removeClass(this.timeIcon);t.addClass(this.dateIcon)}}this.widget=i(d(this.timeIcon,this.upIcon,this.downIcon,k.pickDate,k.pickTime,k.pick12HourFormat,k.pickSeconds,k.collapse)).appendTo("body");this.minViewMode=k.minViewMode||this.$element.data("date-minviewmode")||0;if(typeof this.minViewMode==="string"){switch(this.minViewMode){case"months":this.minViewMode=1;break;case"years":this.minViewMode=2;break;default:this.minViewMode=0;break}}this.viewMode=k.viewMode||this.$element.data("date-viewmode")||0;if(typeof this.viewMode==="string"){switch(this.viewMode){case"months":this.viewMode=1;break;case"years":this.viewMode=2;break;default:this.viewMode=0;break}}if(k.defaultDate!==""){this.setValue(k.defaultDate)}this.startViewMode=this.viewMode;this.weekStart=k.weekStart||this.$element.data("date-weekstart")||0;this.weekEnd=this.weekStart===0?6:this.weekStart-1;setStartDate(k.startDate||this.$element.data("date-startdate"));this.setEndDate(k.endDate||this.$element.data("date-enddate"));this.fillDow();this.fillMonths();this.fillHours();this.fillMinutes();this.fillSeconds();this.update();this.showMode();this._attachDatePickerEvents()},show:function(k){this.widget.show();this.height=this.component?this.component.outerHeight():this.$element.outerHeight();this.place();this.$element.trigger({type:"show",date:this._date});this._attachDatePickerGlobalEvents();if(k){k.stopPropagation();k.preventDefault()}},disable:function(){this.$element.find("input").prop("disabled",true);this._detachDatePickerEvents()},enable:function(){this.$element.find("input").prop("disabled",false);this._attachDatePickerEvents()},hide:function(){var t=this.widget.find(".collapse");for(var k=0;k<t.length;k++){var s=t.eq(k).data("collapse");if(s&&s.transitioning){return}}this.widget.hide();this.viewMode=this.startViewMode;this.showMode();this.$element.trigger({type:"hide",date:this._date});this._detachDatePickerGlobalEvents()},set:function(){var s="";if(!this._unset){if(this.useMoment){s=moment.utc(this._date).format(this.format)}else{s=this.formatDate(this._date)}}if(!this.isInput){if(this.component){var k=this.$element.find("input");k.val(s);this._resetMaskPos(k)}this.$element.data("date",s)}else{this.$element.val(s);this._resetMaskPos(this.$element)}if(!this.pickTime){this.hide()}},setValue:function(k){if(!k){this._unset=true}else{this._unset=false}if(typeof k==="string"){this._date=this.parseDate(k)}else{if(k){this._date=new Date(k)}}this.set();this.viewDate=new m(this._date.getUTCFullYear(),this._date.getUTCMonth(),1,0,0,0,0);this.fillDate();this.fillTime()},getDate:function(){if(this._unset){return null}return new Date(this._date.valueOf())},setDate:function(k){if(!k){this.setValue(null)}else{this.setValue(k.valueOf())}},setEndDate:function(k){if(k instanceof Date){this.endDate=k}else{if(typeof k==="string"){this.endDate=new m(k);if(!this.endDate.getUTCFullYear()){this.endDate=Infinity}}else{this.endDate=Infinity}}if(this.viewDate){this.update()}},getLocalDate:function(){if(this._unset){return null}var k=this._date;return new Date(k.getUTCFullYear(),k.getUTCMonth(),k.getUTCDate(),k.getUTCHours(),k.getUTCMinutes(),k.getUTCSeconds(),k.getUTCMilliseconds())},setLocalDate:function(k){if(!k){this.setValue(null)}else{this.setValue(Date.UTC(k.getFullYear(),k.getMonth(),k.getDate(),k.getHours(),k.getMinutes(),k.getSeconds(),k.getMilliseconds()))}},place:function(){var k="absolute";var t=this.component?this.component.offset():this.$element.offset();this.width=this.component?this.component.outerWidth():this.$element.outerWidth();t.top=t.top+this.$element.outerHeight();var s=i(window);if(t.top+this.widget.height()>s.height()){t.top=t.top-(this.widget.height()+this.height+10)}if(this.options.width!==undefined){this.widget.width(this.options.width)}if(this.options.orientation==="left"){this.widget.addClass("left-oriented");t.left=t.left-this.widget.width()+20}if(this._isInFixed()){k="fixed";t.top-=s.scrollTop();t.left-=s.scrollLeft()}if(s.width()<t.left+this.widget.outerWidth()){t.right=s.width()-t.left-this.width;t.left="auto";this.widget.addClass("pull-right")}else{t.right="auto";this.widget.removeClass("pull-right")}this.widget.css({position:k,top:t.top,left:t.left,right:t.right})},notifyChange:function(){this.$element.trigger({type:"changeDate",date:this.getDate(),localDate:this.getLocalDate()})},update:function(k){var s=k;if(!s){if(this.isInput){s=this.$element.val()}else{s=this.$element.find("input").val()}if(s){this._date=this.parseDate(s)}if(!this._date){var t=new Date();this._date=new m(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}}this.viewDate=new m(this._date.getUTCFullYear(),this._date.getUTCMonth(),1,0,0,0,0);this.fillDate();this.fillTime()},fillDow:function(){var k=this.weekStart;var s=i("<tr>");while(k<this.weekStart+7){s.append('<th class="dow">'+a[this.language].daysMin[(k++)%7]+"</th>")}this.widget.find(".datepicker-days thead").append(s)},fillMonths:function(){var s="";var k=0;while(k<12){s+='<span class="month">'+a[this.language].monthsShort[k++]+"</span>"}this.widget.find(".datepicker-months td").append(s)},fillDate:function(){var D=this.viewDate.getUTCFullYear();var B=this.viewDate.getUTCMonth();var s=m(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),0,0,0,0);var C=typeof this.startDate==="object"?this.startDate.getUTCFullYear():-Infinity;var F=typeof this.startDate==="object"?this.startDate.getUTCMonth():-1;var G=typeof this.endDate==="object"?this.endDate.getUTCFullYear():Infinity;var z=typeof this.endDate==="object"?this.endDate.getUTCMonth():12;this.widget.find(".datepicker-days").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-months").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-years").find(".disabled").removeClass("disabled");this.widget.find(".datepicker-days th:eq(1)").text(a[this.language].months[B]+" "+D);var v=m(D,B-1,28,0,0,0,0);var E=j.getDaysInMonth(v.getUTCFullYear(),v.getUTCMonth());v.setUTCDate(E);v.setUTCDate(E-(v.getUTCDay()-this.weekStart+7)%7);if((D==C&&B<=F)||D<C){this.widget.find(".datepicker-days th:eq(0)").addClass("disabled")}if((D==G&&B>=z)||D>G){this.widget.find(".datepicker-days th:eq(2)").addClass("disabled")}var y=new Date(v.valueOf());y.setUTCDate(y.getUTCDate()+42);y=y.valueOf();var x=[];var H;var u;while(v.valueOf()<y){if(v.getUTCDay()===this.weekStart){H=i("<tr>");x.push(H)}u="";if(v.getUTCFullYear()<D||(v.getUTCFullYear()==D&&v.getUTCMonth()<B)){u+=" old"}else{if(v.getUTCFullYear()>D||(v.getUTCFullYear()==D&&v.getUTCMonth()>B)){u+=" new"}}if(v.valueOf()===s.valueOf()){u+=" active"}if((v.valueOf()+86400000)<=this.startDate){u+=" disabled"}if(v.valueOf()>this.endDate){u+=" disabled"}H.append('<td class="day'+u+'">'+v.getUTCDate()+"</td>");v.setUTCDate(v.getUTCDate()+1)}this.widget.find(".datepicker-days tbody").empty().append(x);var A=this._date.getUTCFullYear();var k=this.widget.find(".datepicker-months").find("th:eq(1)").text(D).end().find("span").removeClass("active");if(A===D){k.eq(this._date.getUTCMonth()).addClass("active")}if(A-1<C){this.widget.find(".datepicker-months th:eq(0)").addClass("disabled")}if(A+1>G){this.widget.find(".datepicker-months th:eq(2)").addClass("disabled")}for(var w=0;w<12;w++){if((D==C&&F>w)||(D<C)){i(k[w]).addClass("disabled")}else{if((D==G&&z<w)||(D>G)){i(k[w]).addClass("disabled")}}}x="";D=parseInt(D/10,10)*10;var t=this.widget.find(".datepicker-years").find("th:eq(1)").text(D+"-"+(D+9)).end().find("td");this.widget.find(".datepicker-years").find("th").removeClass("disabled");if(C>D){this.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled")}if(G<D+9){this.widget.find(".datepicker-years").find("th:eq(2)").addClass("disabled")}D-=1;for(var w=-1;w<11;w++){x+='<span class="year'+(w===-1||w===10?" old":"")+(A===D?" active":"")+((D<C||D>G)?" disabled":"")+'">'+D+"</span>";D+=1}t.html(x)},fillHours:function(){var u=this.widget.find(".timepicker .timepicker-hours table");u.parent().hide();var t="";if(this.options.pick12HourFormat){var v=1;for(var s=0;s<3;s+=1){t+="<tr>";for(var k=0;k<4;k+=1){var w=v.toString();t+='<td class="hour">'+f(w,2,"0")+"</td>";v++}t+="</tr>"}}else{var v=0;for(var s=0;s<6;s+=1){t+="<tr>";for(var k=0;k<4;k+=1){var w=v.toString();t+='<td class="hour">'+f(w,2,"0")+"</td>";v++}t+="</tr>"}}u.html(t)},fillMinutes:function(){var u=this.widget.find(".timepicker .timepicker-minutes table");u.parent().hide();var t="";var v=0;for(var s=0;s<5;s++){t+="<tr>";for(var k=0;k<4;k+=1){var w=v.toString();t+='<td class="minute">'+f(w,2,"0")+"</td>";v+=3}t+="</tr>"}u.html(t)},fillSeconds:function(){var u=this.widget.find(".timepicker .timepicker-seconds table");u.parent().hide();var t="";var v=0;for(var s=0;s<5;s++){t+="<tr>";for(var k=0;k<4;k+=1){var w=v.toString();t+='<td class="second">'+f(w,2,"0")+"</td>";v+=3}t+="</tr>"}u.html(t)},fillTime:function(){if(!this._date){return}var x=this.widget.find(".timepicker span[data-time-component]");var u=x.closest("table");var t=this.options.pick12HourFormat;var k=this._date.getUTCHours();var w="AM";if(t){if(k>=12){w="PM"}if(k===0){k=12}else{if(k!=12){k=k%12}}this.widget.find(".timepicker [data-action=togglePeriod]").text(w)}k=f(k.toString(),2,"0");var v=f(this._date.getUTCMinutes().toString(),2,"0");var s=f(this._date.getUTCSeconds().toString(),2,"0");x.filter("[data-time-component=hours]").text(k);x.filter("[data-time-component=minutes]").text(v);x.filter("[data-time-component=seconds]").text(s)},click:function(y){y.stopPropagation();y.preventDefault();this._unset=false;var x=i(y.target).closest("span, td, th");if(x.length===1){if(!x.is(".disabled")){switch(x[0].nodeName.toLowerCase()){case"th":switch(x[0].className){case"switch":this.showMode(1);break;case"prev":case"next":var s=this.viewDate;var t=j.modes[this.viewMode].navFnc;var v=j.modes[this.viewMode].navStep;if(x[0].className==="prev"){v=v*-1}s["set"+t](s["get"+t]()+v);this.fillDate();break}break;case"span":if(x.is(".month")){var w=x.parent().find("span").index(x);this.viewDate.setUTCMonth(w)}else{var u=parseInt(x.text(),10)||0;this.viewDate.setUTCFullYear(u)}if(this.viewMode!==0){this._date=m(this.viewDate.getUTCFullYear(),this.viewDate.getUTCMonth(),this.viewDate.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds());this.notifyChange()}this.showMode(-1);this.fillDate();break;case"td":if(x.is(".day")){var k=parseInt(x.text(),10)||1;var w=this.viewDate.getUTCMonth();var u=this.viewDate.getUTCFullYear();if(x.is(".old")){if(w===0){w=11;u-=1}else{w-=1}}else{if(x.is(".new")){if(w==11){w=0;u+=1}else{w+=1}}}this._date=m(u,w,k,this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds());this.viewDate=m(u,w,Math.min(28,k),0,0,0,0);this.fillDate();this.set();this.notifyChange()}break}}}},actions:{incrementHours:function(k){this._date.setUTCHours(this._date.getUTCHours()+1)},incrementMinutes:function(k){this._date.setUTCMinutes(this._date.getUTCMinutes()+1)},incrementSeconds:function(k){this._date.setUTCSeconds(this._date.getUTCSeconds()+1)},decrementHours:function(k){this._date.setUTCHours(this._date.getUTCHours()-1)},decrementMinutes:function(k){this._date.setUTCMinutes(this._date.getUTCMinutes()-1)},decrementSeconds:function(k){this._date.setUTCSeconds(this._date.getUTCSeconds()-1)},togglePeriod:function(s){var k=this._date.getUTCHours();if(k>=12){k-=12}else{k+=12}this._date.setUTCHours(k)},showPicker:function(){this.widget.find(".timepicker > div:not(.timepicker-picker)").hide();this.widget.find(".timepicker .timepicker-picker").show()},showHours:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-hours").show()},showMinutes:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-minutes").show()},showSeconds:function(){this.widget.find(".timepicker .timepicker-picker").hide();this.widget.find(".timepicker .timepicker-seconds").show()},selectHour:function(t){var u=i(t.target);var k=parseInt(u.text(),10);if(this.options.pick12HourFormat){var s=this._date.getUTCHours();if(s>=12){if(k!=12){k=(k+12)%24}}else{if(k===12){k=0}else{k=k%12}}}this._date.setUTCHours(k);this.actions.showPicker.call(this)},selectMinute:function(s){var t=i(s.target);var k=parseInt(t.text(),10);this._date.setUTCMinutes(k);this.actions.showPicker.call(this)},selectSecond:function(s){var t=i(s.target);var k=parseInt(t.text(),10);this._date.setUTCSeconds(k);this.actions.showPicker.call(this)}},doAction:function(s){s.stopPropagation();s.preventDefault();if(!this._date){this._date=m(1970,0,0,0,0,0,0)}var k=i(s.currentTarget).data("action");var t=this.actions[k].apply(this,arguments);this.set();this.fillTime();this.notifyChange();return t},stopEvent:function(k){k.stopPropagation();k.preventDefault()},keydown:function(v){var u=this,t=v.which,s=i(v.target);if(t==8||t==46){setTimeout(function(){u._resetMaskPos(s)})}},keypress:function(v){var u=v.which;if(u==8||u==46){return}var t=i(v.target);var x=String.fromCharCode(u);var w=t.val()||"";w+=x;var s=this._mask[this._maskPos];if(!s){return false}if(s.end!=w.length){return}if(!s.pattern.test(w.slice(s.start))){w=w.slice(0,w.length-1);while((s=this._mask[this._maskPos])&&s.character){w+=s.character;this._maskPos++}w+=x;if(s.end!=w.length){t.val(w);return false}else{if(!s.pattern.test(w.slice(s.start))){t.val(w.slice(0,s.start));return false}else{t.val(w);this._maskPos++;return false}}}else{this._maskPos++}},change:function(s){var k=i(s.target);var t=k.val();if(this._formatPattern.test(t)){this.update();this.setValue(this._date.getTime());this.notifyChange();this.set()}else{if(t&&t.trim()){this.setValue(this._date.getTime());if(this._date){this.set()}else{k.val("")}}else{if(this._date){this.setValue(null);this.notifyChange();this._unset=true}}}this._resetMaskPos(k)},showMode:function(k){if(k){this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+k))}this.widget.find(".datepicker > div").hide().filter(".datepicker-"+j.modes[this.viewMode].clsName).show()},destroy:function(){this._detachDatePickerEvents();this._detachDatePickerGlobalEvents();this.widget.remove();this.$element.removeData("datetimepicker");this.component.removeData("datetimepicker")},formatDate:function(k){return this.format.replace(c,function(u){var t,v,w,s=u.length;if(u==="ms"){s=1}v=p[u].property;if(v==="Hours12"){w=k.getUTCHours();if(w===0){w=12}else{if(w!==12){w=w%12}}}else{if(v==="Period12"){if(k.getUTCHours()>=12){return"PM"}else{return"AM"}}else{t="get"+v;w=k[t]()}}if(t==="getUTCMonth"){w=w+1}if(t==="getUTCYear"){w=w+1900-2000}return f(w.toString(),s,"0")}).trim()},parseDate:function(y){if(this.useMoment){var x=moment(y);return x}var t,u,w,s,v,k={};if(!(t=this._formatPattern.exec(y))){return null}for(u=1;u<t.length;u++){w=this._propertiesByIndex[u];if(!w){continue}v=t[u];if(/^\d+$/.test(v)){v=parseInt(v,10)}k[w]=v}return this._finishParsingDate(k)},_resetMaskPos:function(k){var t=k.val();for(var s=0;s<this._mask.length;s++){if(this._mask[s].end>t.length){this._maskPos=s;break}else{if(this._mask[s].end===t.length){this._maskPos=s+1;break}}}},_finishParsingDate:function(s){var w,x,u,k,v,y,t;w=s.UTCFullYear;if(s.UTCYear){w=2000+s.UTCYear}if(!w){w=1970}if(s.UTCMonth){x=s.UTCMonth-1}else{x=0}u=s.UTCDate||1;k=s.UTCHours||0;v=s.UTCMinutes||0;y=s.UTCSeconds||0;t=s.UTCMilliseconds||0;if(s.Hours12){k=s.Hours12}if(s.Period12){if(/pm/i.test(s.Period12)){if(k!=12){k=(k+12)%24}}else{k=k%12}}return m(w,x,u,k,v,y,t)},_compileFormat:function(){var u,t,w=[],s=[],x=this.format,k={},v=0,y=0;while(u=h.exec(x)){t=u[0];if(t in p){v++;k[v]=p[t].property;w.push("\\s*"+p[t].getPattern(this)+"\\s*");s.push({pattern:new RegExp(p[t].getPattern(this)),property:p[t].property,start:y,end:y+=t.length})}else{w.push(g(t));s.push({pattern:new RegExp(g(t)),character:t,start:y,end:++y})}x=x.slice(t.length)}this._mask=s;this._maskPos=0;this._formatPattern=new RegExp("^\\s*"+w.join("")+"\\s*$");this._propertiesByIndex=k},_attachDatePickerEvents:function(){var k=this;this.widget.on("click",".datepicker *",i.proxy(this.click,this));this.widget.on("click","[data-action]",i.proxy(this.doAction,this));this.widget.on("mousedown",i.proxy(this.stopEvent,this));if(this.pickDate&&this.pickTime){this.widget.on("click.togglePicker",".accordion-toggle",function(x){x.stopPropagation();var w=i(this);var v=w.closest("ul");var t=v.find(".in");var s=v.find(".collapse:not(.in)");if(t&&t.length){var u=t.data("collapse");if(u&&u.transitioning){return}t.collapse("hide");s.collapse("show");w.find("span").toggleClass(k.timeIcon+" "+k.dateIcon);k.$element.find(".input-group-addon span").toggleClass(k.timeIcon+" "+k.dateIcon)}})}if(this.isInput){this.$element.on({focus:i.proxy(this.show,this),change:i.proxy(this.change,this),blur:i.proxy(this.hide,this)});if(this.options.maskInput){this.$element.on({keydown:i.proxy(this.keydown,this),keypress:i.proxy(this.keypress,this)})}}else{this.$element.on({change:i.proxy(this.change,this)},"input");if(this.options.maskInput){this.$element.on({keydown:i.proxy(this.keydown,this),keypress:i.proxy(this.keypress,this)},"input")}if(this.component){this.component.on("click",i.proxy(this.show,this))}else{this.$element.on("click",i.proxy(this.show,this))}}},_attachDatePickerGlobalEvents:function(){i(window).on("resize.datetimepicker"+this.id,i.proxy(this.place,this));if(!this.isInput){i(document).on("mousedown.datetimepicker"+this.id,i.proxy(this.hide,this))}},_detachDatePickerEvents:function(){this.widget.off("click",".datepicker *",this.click);this.widget.off("click","[data-action]");this.widget.off("mousedown",this.stopEvent);if(this.pickDate&&this.pickTime){this.widget.off("click.togglePicker")}if(this.isInput){this.$element.off({focus:this.show,change:this.change});if(this.options.maskInput){this.$element.off({keydown:this.keydown,keypress:this.keypress})}}else{this.$element.off({change:this.change},"input");if(this.options.maskInput){this.$element.off({keydown:this.keydown,keypress:this.keypress},"input")}if(this.component){this.component.off("click",this.show)}else{this.$element.off("click",this.show)}}},_detachDatePickerGlobalEvents:function(){i(window).off("resize.datetimepicker"+this.id);if(!this.isInput){i(document).off("mousedown.datetimepicker"+this.id)}},_isInFixed:function(){if(this.$element){var s=this.$element.parents();var k=false;for(var t=0;t<s.length;t++){if(i(s[t]).css("position")=="fixed"){k=true;break}}return k}else{return false}}};this.setStartDate=function(k){if(k instanceof Date){this.startDate=k}else{if(typeof k==="string"){this.startDate=new m(k);if(!this.startDate.getUTCFullYear()){this.startDate=-Infinity}}else{this.startDate=-Infinity}}if(this.viewDate){this.update()}};i.fn.datetimepicker=function(k,s){return this.each(function(){var v=i(this),u=v.data("datetimepicker"),t=typeof k==="object"&&k;if(!u){v.data("datetimepicker",(u=new b(this,i.extend({},i.fn.datetimepicker.defaults,t))))}if(typeof k==="string"){u[k](s)}})};i.fn.datetimepicker.defaults={maskInput:false,pickDate:true,pickTime:true,pick12HourFormat:false,pickSeconds:true,startDate:-Infinity,endDate:Infinity,collapse:true,defaultDate:""};i.fn.datetimepicker.Constructor=b;var n=0;var a=i.fn.datetimepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}};var p={dd:{property:"UTCDate",getPattern:function(){return"(0?[1-9]|[1-2][0-9]|3[0-1])\\b"}},MM:{property:"UTCMonth",getPattern:function(){return"(0?[1-9]|1[0-2])\\b"}},yy:{property:"UTCYear",getPattern:function(){return"(\\d{2})\\b"}},yyyy:{property:"UTCFullYear",getPattern:function(){return"(\\d{4})\\b"}},hh:{property:"UTCHours",getPattern:function(){return"(0?[0-9]|1[0-9]|2[0-3])\\b"}},mm:{property:"UTCMinutes",getPattern:function(){return"(0?[0-9]|[1-5][0-9])\\b"}},ss:{property:"UTCSeconds",getPattern:function(){return"(0?[0-9]|[1-5][0-9])\\b"}},ms:{property:"UTCMilliseconds",getPattern:function(){return"([0-9]{1,3})\\b"}},HH:{property:"Hours12",getPattern:function(){return"(0?[1-9]|1[0-2])\\b"}},PP:{property:"Period12",getPattern:function(){return"(AM|PM|am|pm|Am|aM|Pm|pM)\\b"}}};var r=[];for(var e in p){r.push(e)}r[r.length-1]+="\\b";r.push(".");var h=new RegExp(r.join("\\b|"));r.pop();var c=new RegExp(r.join("\\b|"),"g");function g(k){return k.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function f(t,k,u){if(k<t.length){return t}else{return Array(k-t.length+1).join(u||" ")+t}}function d(w,y,v,u,k,s,t,x){if(u&&k){return('<div class="bootstrap-datetimepicker-widget dropdown-menu" style="z-index:9999 !important;"><ul class="list-unstyled"><li'+(x?' class="collapse in"':"")+'><div class="datepicker">'+j.template+'</div></li><li class="picker-switch accordion-toggle"><a class="btn" style="width:100%"><span class="'+w+'"></span></a></li><li'+(x?' class="collapse"':"")+'><div class="timepicker">'+l.getTemplate(s,t,y,v)+"</div></li></ul></div>")}else{if(k){return('<div class="bootstrap-datetimepicker-widget dropdown-menu"><div class="timepicker">'+l.getTemplate(s,t,y,v)+"</div></div>")}else{return('<div class="bootstrap-datetimepicker-widget dropdown-menu"><div class="datepicker">'+j.template+"</div></div>")}}}function m(){return new Date(Date.UTC.apply(Date,arguments))}var j={modes:[{clsName:"days",navFnc:"UTCMonth",navStep:1},{clsName:"months",navFnc:"UTCFullYear",navStep:1},{clsName:"years",navFnc:"UTCFullYear",navStep:10}],isLeapYear:function(k){return(((k%4===0)&&(k%100!==0))||(k%400===0))},getDaysInMonth:function(k,s){return[31,(j.isLeapYear(k)?29:28),31,30,31,30,31,31,30,31,30,31][s]},headTemplate:'<thead><tr><th class="prev">&lsaquo;</th><th colspan="5" class="switch"></th><th class="next">&rsaquo;</th></tr></thead>',contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>'};j.template='<div class="datepicker-days"><table class="table-condensed">'+j.headTemplate+'<tbody></tbody></table></div><div class="datepicker-months"><table class="table-condensed">'+j.headTemplate+j.contTemplate+'</table></div><div class="datepicker-years"><table class="table-condensed">'+j.headTemplate+j.contTemplate+"</table></div>";var l={hourTemplate:'<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>',minuteTemplate:'<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>',secondTemplate:'<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>'};l.getTemplate=function(k,s,u,t){return('<div class="timepicker-picker"><table class="table-condensed"'+(k?' data-hour-format="12"':"")+'><tr><td><a href="#" class="btn" data-action="incrementHours"><span class="'+u+'"></span></a></td><td class="separator"></td><td><a href="#" class="btn" data-action="incrementMinutes"><span class="'+u+'"></span></a></td>'+(s?'<td class="separator"></td><td><a href="#" class="btn" data-action="incrementSeconds"><span class="'+u+'"></span></a></td>':"")+(k?'<td class="separator"></td>':"")+"</tr><tr><td>"+l.hourTemplate+'</td> <td class="separator">:</td><td>'+l.minuteTemplate+"</td> "+(s?'<td class="separator">:</td><td>'+l.secondTemplate+"</td>":"")+(k?'<td class="separator"></td><td><button type="button" class="btn btn-primary" data-action="togglePeriod"></button></td>':"")+'</tr><tr><td><a href="#" class="btn" data-action="decrementHours"><span class="'+t+'"></span></a></td><td class="separator"></td><td><a href="#" class="btn" data-action="decrementMinutes"><span class="'+t+'"></span></a></td>'+(s?'<td class="separator"></td><td><a href="#" class="btn" data-action="decrementSeconds"><span class="'+t+'"></span></a></td>':"")+(k?'<td class="separator"></td>':"")+'</tr></table></div><div class="timepicker-hours" data-action="selectHour"><table class="table-condensed"></table></div><div class="timepicker-minutes" data-action="selectMinute"><table class="table-condensed"></table></div>'+(s?'<div class="timepicker-seconds" data-action="selectSecond"><table class="table-condensed"></table></div>':""))}})(window.jQuery);
... ...
src/templates/search/search.html
1 1 {% extends "base.html" %}
2 2 {% load i18n highlight superarchives %}
3 3  
  4 +{% block head_js %}
  5 +<script type="text/javascript" src="{{ STATIC_URL }}third-party/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
  6 +
  7 +<script type="text/javascript">
  8 + $(function () {
  9 + $('#datepicker_since, #datepicker_until').datetimepicker({
  10 + pickTime: false
  11 + });
  12 + });
  13 +</script>
  14 +{% endblock %}
  15 +
  16 +{% block head_css %}
  17 +<link rel="stylesheet" href="{{ STATIC_URL }}third-party/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"/>
  18 +{% endblock %}
  19 +
4 20 {% block main-content %}
5 21 <div class="row">
6 22 <div class="col-lg-12">
7 23 <h2>{% trans "Search" %}</h2>
8   - <p class="text-right quiet">
9   - {{ page.paginator.count }} {% trans "documents found" %}
10   - </p>
  24 + <p class="text-right quiet">
  25 + {{ page.paginator.count }} {% trans "documents found" %}
  26 + </p>
11 27 </div>
12 28 </div>
13 29  
... ... @@ -45,9 +61,11 @@
45 61 {% endifequal %}
46 62 </div>
47 63 {% endfor %}
48   - <button type="submit" class="btn btn-default pull-right"><span class="glyphicon glyphicon-filter"></span> {% trans 'Filter' %}</button>
  64 + <button type="submit" class="btn btn-default pull-right">
  65 + <span class="glyphicon glyphicon-filter"></span> {% trans 'Filter' %}
  66 + </button>
49 67 </form>
50   - <br /><hr />
  68 + <br /><br /><hr />
51 69 {% endif %}
52 70  
53 71 <h4>{% trans "Sort by" %}</h4>
... ... @@ -92,6 +110,35 @@
92 110 </li>
93 111 </ul>
94 112 {% endif %}
  113 + <hr />
  114 + <form role="form">
  115 + {% for name, value in request.GET.items %}
  116 + {% if value and not name == "since" and not name == "until" %}
  117 + <input type="hidden" name="{{ name }}" value="{{ value }}" />
  118 + {% endif %}
  119 + {% endfor %}
  120 + <div class="form-group">
  121 + <label for="since">{% trans "Since" %}</label>
  122 + <div class="input-group date" id="datepicker_since">
  123 + <input type="text" class="form-control" placeholder="{% trans "Since" %}" name="since" value="{{ request.GET.since }}" data-format="MM/dd/yyyy" />
  124 + <span class="input-group-addon">
  125 + <span class="glyphicon glyphicon-calendar"></span>
  126 + </span>
  127 + </div>
  128 + </div>
  129 + <div class="form-group">
  130 + <label for="until">{% trans "Until" %}</label>
  131 + <div class="input-group date" id="datepicker_until">
  132 + <input type="text" class="form-control" placeholder="{% trans "Until" %}" name="until" value="{{ request.GET.until }}" data-format="MM/dd/yyyy" />
  133 + <span class="input-group-addon">
  134 + <span class="glyphicon glyphicon-calendar"></span>
  135 + </span>
  136 + </div>
  137 + </div>
  138 + <button type="submit" class="btn btn-default pull-right">
  139 + <span class="glyphicon glyphicon-filter"></span> {% trans "Filter" %}
  140 + </button>
  141 + </form>
95 142 </div>
96 143  
97 144 <div class="col-lg-10">
... ...