diff --git a/VIPSWeb/locale/nb/LC_MESSAGES/djangojs.po b/VIPSWeb/locale/nb/LC_MESSAGES/djangojs.po index affce20450050148ebcfc393aedcb0bd1cd9c196..1a4e566dabe1d6e89d8583a367eabfbe4aafc32e 100644 --- a/VIPSWeb/locale/nb/LC_MESSAGES/djangojs.po +++ b/VIPSWeb/locale/nb/LC_MESSAGES/djangojs.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-01-16 12:46+0100\n" +"POT-Creation-Date: 2014-01-16 14:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py index 5d4b71785f6ff4e4bc4e30a1f0be8031a8455aeb..b1854c7f1893946313fc4a4c9d84956b4c5999d7 100644 --- a/VIPSWeb/settings.py +++ b/VIPSWeb/settings.py @@ -113,6 +113,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'common.middleware.whodid.WhodidMiddleware' #'django.middleware.locale.LocaleMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', diff --git a/VIPSWeb/static/css/vipsweb.css b/VIPSWeb/static/css/vipsweb.css index 9404e29d7b74fcf696c0e3ed04363f0956ed4fa5..656e726a240513ee2e033502dd711060ebc51fa6 100644 --- a/VIPSWeb/static/css/vipsweb.css +++ b/VIPSWeb/static/css/vipsweb.css @@ -43,12 +43,19 @@ div.messages_illustration{ height: 400px; } -#tooltip, #popover { +#tooltip{ position: absolute; height: 1px; width: 1px; z-index: 100; } + + + +div.popover { + min-width: 250px; + max-width: 400px !important; +} /* .tooltip.in { opacity: 1; diff --git a/VIPSWeb/static/js/forecastmap.js b/VIPSWeb/static/js/forecastmap.js index 24fd4fa30064f502526e2360f1d9f248dc2e6614..c21881655c795c55e87f7b3ef3232ceb729f228f 100644 --- a/VIPSWeb/static/js/forecastmap.js +++ b/VIPSWeb/static/js/forecastmap.js @@ -124,7 +124,7 @@ function initForecastMap(lonLat, zoomLevel, sourceHostname) top: (pixel[1] - 15) + 'px' }); */ - popOverlay.setPosition(coordinate); + popOverlay.setPosition(coordinate); map.getFeatures({ pixel: pixel, layers: [forecastLayer], @@ -162,15 +162,18 @@ function initForecastMap(lonLat, zoomLevel, sourceHostname) } //console.log(forecastConfiguration); - resultHTML.push("<div class=\"" + alertClass + "\">" + new Date(data.results[index].resultValidTime) + ": <a href=\"/forecasts/" + forecastConfiguration.forecastConfigurationId + "\" class=\"alert-link\">" + forecastConfiguration.modelId + "</a></div>"); + resultHTML.push("<div class=\"" + alertClass + "\">" + moment(data.results[index].resultValidTime).format("YYYY-MM-DD") + ": <a href=\"/forecasts/" + forecastConfiguration.forecastConfigurationId + "\" class=\"alert-link\">" + modelLocalNames[forecastConfiguration.modelId] + "</a></div>"); } if(resultHTML.length == 0) { resultHTML.push(gettext("No forecasts found for") + " " + feature.get("name")); } + + // Testing + //resultHTML = ["Mange små ord mange små ord Få ord"]; poiDetails.popover({ - animation: false, + animation: true, trigger: 'manual', html: true, placement: "auto top", diff --git a/VIPSWeb/static/js/moment.min.js b/VIPSWeb/static/js/moment.min.js new file mode 100644 index 0000000000000000000000000000000000000000..568ad05cecad8a0cde991c6f744df72f9ac8ddea --- /dev/null +++ b/VIPSWeb/static/js/moment.min.js @@ -0,0 +1,6 @@ +//! moment.js +//! version : 2.4.0 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com +(function(a){function b(a,b){return function(c){return i(a.call(this,c),b)}}function c(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function d(){}function e(a){u(a),g(this,a)}function f(a){var b=o(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._input=a,this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function g(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function h(a){return 0>a?Math.ceil(a):Math.floor(a)}function i(a,b){for(var c=a+"";c.length<b;)c="0"+c;return c}function j(a,b,c,d){var e,f,g=b._milliseconds,h=b._days,i=b._months;g&&a._d.setTime(+a._d+g*c),(h||i)&&(e=a.minute(),f=a.hour()),h&&a.date(a.date()+h*c),i&&a.month(a.month()+i*c),g&&!d&&bb.updateOffset(a),(h||i)&&(a.minute(e),a.hour(f))}function k(a){return"[object Array]"===Object.prototype.toString.call(a)}function l(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function m(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&q(a[d])!==q(b[d]))&&g++;return g+f}function n(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Kb[a]||Lb[b]||b}return a}function o(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=n(c),b&&(d[b]=a[c]));return d}function p(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}bb[b]=function(e,f){var g,h,i=bb.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=bb().utc().set(d,a);return i.call(bb.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function q(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function r(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function s(a){return t(a)?366:365}function t(a){return 0===a%4&&0!==a%100||0===a%400}function u(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[gb]<0||a._a[gb]>11?gb:a._a[hb]<1||a._a[hb]>r(a._a[fb],a._a[gb])?hb:a._a[ib]<0||a._a[ib]>23?ib:a._a[jb]<0||a._a[jb]>59?jb:a._a[kb]<0||a._a[kb]>59?kb:a._a[lb]<0||a._a[lb]>999?lb:-1,a._pf._overflowDayOfYear&&(fb>b||b>hb)&&(b=hb),a._pf.overflow=b)}function v(a){a._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function w(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function x(a){return a?a.toLowerCase().replace("_","-"):a}function y(a,b){return b.abbr=a,mb[a]||(mb[a]=new d),mb[a].set(b),mb[a]}function z(a){delete mb[a]}function A(a){var b,c,d,e,f=0,g=function(a){if(!mb[a]&&nb)try{require("./lang/"+a)}catch(b){}return mb[a]};if(!a)return bb.fn._lang;if(!k(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=x(a[f]).split("-"),b=e.length,d=x(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&m(e,d,!0)>=b-1)break;b--}f++}return bb.fn._lang}function B(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function C(a){var b,c,d=a.match(rb);for(b=0,c=d.length;c>b;b++)d[b]=Pb[d[b]]?Pb[d[b]]:B(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function D(a,b){return a.isValid()?(b=E(b,a.lang()),Mb[b]||(Mb[b]=C(b)),Mb[b](a)):a.lang().invalidDate()}function E(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(sb.lastIndex=0;d>=0&&sb.test(a);)a=a.replace(sb,c),sb.lastIndex=0,d-=1;return a}function F(a,b){var c;switch(a){case"DDDD":return vb;case"YYYY":case"GGGG":case"gggg":return wb;case"YYYYY":case"GGGGG":case"ggggg":return xb;case"S":case"SS":case"SSS":case"DDD":return ub;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return zb;case"a":case"A":return A(b._l)._meridiemParse;case"X":return Cb;case"Z":case"ZZ":return Ab;case"T":return Bb;case"SSSS":return yb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"ww":case"W":case"WW":case"e":case"E":return tb;default:return c=new RegExp(N(M(a.replace("\\","")),"i"))}}function G(a){var b=(Ab.exec(a)||[])[0],c=(b+"").match(Hb)||["-",0,0],d=+(60*c[1])+q(c[2]);return"+"===c[0]?-d:d}function H(a,b,c){var d,e=c._a;switch(a){case"M":case"MM":null!=b&&(e[gb]=q(b)-1);break;case"MMM":case"MMMM":d=A(c._l).monthsParse(b),null!=d?e[gb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[hb]=q(b));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=q(b));break;case"YY":e[fb]=q(b)+(q(b)>68?1900:2e3);break;case"YYYY":case"YYYYY":e[fb]=q(b);break;case"a":case"A":c._isPm=A(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[ib]=q(b);break;case"m":case"mm":e[jb]=q(b);break;case"s":case"ss":e[kb]=q(b);break;case"S":case"SS":case"SSS":case"SSSS":e[lb]=q(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=G(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function I(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=K(a),a._w&&null==a._a[hb]&&null==a._a[gb]&&(f=function(b){return b?b.length<3?parseInt(b,10)>68?"19"+b:"20"+b:b:null==a._a[fb]?bb().weekYear():a._a[fb]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=X(f(g.GG),g.W||1,g.E,4,1):(i=A(a._l),j=null!=g.d?T(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&j<i._week.dow&&k++,h=X(f(g.gg),k,j,i._week.doy,i._week.dow)),a._a[fb]=h.year,a._dayOfYear=h.dayOfYear),a._dayOfYear&&(e=null==a._a[fb]?d[fb]:a._a[fb],a._dayOfYear>s(e)&&(a._pf._overflowDayOfYear=!0),c=S(e,0,a._dayOfYear),a._a[gb]=c.getUTCMonth(),a._a[hb]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[ib]+=q((a._tzm||0)/60),l[jb]+=q((a._tzm||0)%60),a._d=(a._useUTC?S:R).apply(null,l)}}function J(a){var b;a._d||(b=o(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],I(a))}function K(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function L(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=A(a._l),h=""+a._i,i=h.length,j=0;for(d=E(a._f,g).match(rb)||[],b=0;b<d.length;b++)e=d[b],c=(F(e,a).exec(h)||[])[0],c&&(f=h.substr(0,h.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),Pb[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),H(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[ib]<12&&(a._a[ib]+=12),a._isPm===!1&&12===a._a[ib]&&(a._a[ib]=0),I(a),u(a)}function M(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function N(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function O(a){var b,c,d,e,f;if(0===a._f.length)return a._pf.invalidFormat=!0,a._d=new Date(0/0),void 0;for(e=0;e<a._f.length;e++)f=0,b=g({},a),v(b),b._f=a._f[e],L(b),w(b)&&(f+=b._pf.charsLeftOver,f+=10*b._pf.unusedTokens.length,b._pf.score=f,(null==d||d>f)&&(d=f,c=b));g(a,c||b)}function P(a){var b,c=a._i,d=Db.exec(c);if(d){for(a._pf.iso=!0,b=4;b>0;b--)if(d[b]){a._f=Fb[b-1]+(d[6]||" ");break}for(b=0;4>b;b++)if(Gb[b][1].exec(c)){a._f+=Gb[b][0];break}Ab.exec(c)&&(a._f+="Z"),L(a)}else a._d=new Date(c)}function Q(b){var c=b._i,d=ob.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?P(b):k(c)?(b._a=c.slice(0),I(b)):l(c)?b._d=new Date(+c):"object"==typeof c?J(b):b._d=new Date(c)}function R(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function S(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function T(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function U(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function V(a,b,c){var d=eb(Math.abs(a)/1e3),e=eb(d/60),f=eb(e/60),g=eb(f/24),h=eb(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",eb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,U.apply({},i)}function W(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=bb(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function X(a,b,c,d,e){var f,g,h=new Date(Date.UTC(a,0)).getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:s(a-1)+g}}function Y(a){var b=a._i,c=a._f;return"undefined"==typeof a._pf&&v(a),null===b?bb.invalid({nullInput:!0}):("string"==typeof b&&(a._i=b=A().preparse(b)),bb.isMoment(b)?(a=g({},b),a._d=new Date(+b._d)):c?k(c)?O(a):L(a):Q(a),new e(a))}function Z(a,b){bb.fn[a]=bb.fn[a+"s"]=function(a){var c=this._isUTC?"UTC":"";return null!=a?(this._d["set"+c+b](a),bb.updateOffset(this),this):this._d["get"+c+b]()}}function $(a){bb.duration.fn[a]=function(){return this._data[a]}}function _(a,b){bb.duration.fn["as"+a]=function(){return+this/b}}function ab(a){var b=!1,c=bb;"undefined"==typeof ender&&(this.moment=a?function(){return!b&&console&&console.warn&&(b=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),c.apply(null,arguments)}:bb)}for(var bb,cb,db="2.4.0",eb=Math.round,fb=0,gb=1,hb=2,ib=3,jb=4,kb=5,lb=6,mb={},nb="undefined"!=typeof module&&module.exports,ob=/^\/?Date\((\-?\d+)/i,pb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,qb=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,rb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,sb=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,tb=/\d\d?/,ub=/\d{1,3}/,vb=/\d{3}/,wb=/\d{1,4}/,xb=/[+\-]?\d{1,6}/,yb=/\d+/,zb=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Ab=/Z|[\+\-]\d\d:?\d\d/i,Bb=/T/i,Cb=/[\+\-]?\d+(\.\d{1,3})?/,Db=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d:?\d\d|Z)?)?$/,Eb="YYYY-MM-DDTHH:mm:ssZ",Fb=["YYYY-MM-DD","GGGG-[W]WW","GGGG-[W]WW-E","YYYY-DDD"],Gb=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Hb=/([\+\-]|\d\d)/gi,Ib="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Jb={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Kb={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Lb={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Mb={},Nb="DDD w W M D d".split(" "),Ob="M D H h m s w W".split(" "),Pb={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return i(this.year()%100,2)},YYYY:function(){return i(this.year(),4)},YYYYY:function(){return i(this.year(),5)},gg:function(){return i(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return i(this.weekYear(),5)},GG:function(){return i(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return i(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return q(this.milliseconds()/100)},SS:function(){return i(q(this.milliseconds()/10),2)},SSS:function(){return i(this.milliseconds(),3)},SSSS:function(){return i(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(a/60),2)+":"+i(q(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(10*a/6),4)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}},Qb=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Nb.length;)cb=Nb.pop(),Pb[cb+"o"]=c(Pb[cb],cb);for(;Ob.length;)cb=Ob.pop(),Pb[cb+cb]=b(Pb[cb],2);for(Pb.DDDD=b(Pb.DDD,3),g(d.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=bb.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=bb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return W(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),bb=function(b,c,d,e){return"boolean"==typeof d&&(e=d,d=a),Y({_i:b,_f:c,_l:d,_strict:e,_isUTC:!1})},bb.utc=function(b,c,d,e){var f;return"boolean"==typeof d&&(e=d,d=a),f=Y({_useUTC:!0,_isUTC:!0,_l:d,_i:b,_f:c,_strict:e}).utc()},bb.unix=function(a){return bb(1e3*a)},bb.duration=function(a,b){var c,d,e,g=bb.isDuration(a),h="number"==typeof a,i=g?a._input:h?{}:a,j=null;return h?b?i[b]=a:i.milliseconds=a:(j=pb.exec(a))?(c="-"===j[1]?-1:1,i={y:0,d:q(j[hb])*c,h:q(j[ib])*c,m:q(j[jb])*c,s:q(j[kb])*c,ms:q(j[lb])*c}):(j=qb.exec(a))&&(c="-"===j[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},i={y:e(j[2]),M:e(j[3]),d:e(j[4]),h:e(j[5]),m:e(j[6]),s:e(j[7]),w:e(j[8])}),d=new f(i),g&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},bb.version=db,bb.defaultFormat=Eb,bb.updateOffset=function(){},bb.lang=function(a,b){var c;return a?(b?y(x(a),b):null===b?(z(a),a="en"):mb[a]||A(a),c=bb.duration.fn._lang=bb.fn._lang=A(a),c._abbr):bb.fn._lang._abbr},bb.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),A(a)},bb.isMoment=function(a){return a instanceof e},bb.isDuration=function(a){return a instanceof f},cb=Qb.length-1;cb>=0;--cb)p(Qb[cb]);for(bb.normalizeUnits=function(a){return n(a)},bb.invalid=function(a){var b=bb.utc(0/0);return null!=a?g(b._pf,a):b._pf.userInvalidated=!0,b},bb.parseZone=function(a){return bb(a).parseZone()},g(bb.fn=e.prototype,{clone:function(){return bb(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return D(bb(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return w(this)},isDSTShifted:function(){return this._a?this.isValid()&&m(this._a,(this._isUTC?bb.utc(this._a):bb(this._a)).toArray())>0:!1},parsingFlags:function(){return g({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=D(this,a||bb.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?bb.duration(+b,a):bb.duration(a,b),j(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?bb.duration(+b,a):bb.duration(a,b),j(this,c,-1),this},diff:function(a,b,c){var d,e,f=this._isUTC?bb(a).zone(this._offset||0):bb(a).local(),g=6e4*(this.zone()-f.zone());return b=n(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-bb(this).startOf("month")-(f-bb(f).startOf("month")))/d,e-=6e4*(this.zone()-bb(this).startOf("month").zone()-(f.zone()-bb(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:h(e)},from:function(a,b){return bb.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(bb(),a)},calendar:function(){var a=this.diff(bb().zone(this.zone()).startOf("day"),"days",!0),b=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.lang().calendar(b,this))},isLeapYear:function(){return t(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=T(a,this.lang()),this.add({d:a-b})):b},month:function(a){var b,c=this._isUTC?"UTC":"";return null!=a?"string"==typeof a&&(a=this.lang().monthsParse(a),"number"!=typeof a)?this:(b=this.date(),this.date(1),this._d["set"+c+"Month"](a),this.date(Math.min(b,this.daysInMonth())),bb.updateOffset(this),this):this._d["get"+c+"Month"]()},startOf:function(a){switch(a=n(a)){case"year":this.month(0);case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),this},endOf:function(a){return a=n(a),this.startOf(a).add("isoWeek"===a?"week":a,1).subtract("ms",1)},isAfter:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)>+bb(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+bb(a).startOf(b)},isSame:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)===+bb(a).startOf(b)},min:function(a){return a=bb.apply(null,arguments),this>a?this:a},max:function(a){return a=bb.apply(null,arguments),a>this?this:a},zone:function(a){var b=this._offset||0;return null==a?this._isUTC?b:this._d.getTimezoneOffset():("string"==typeof a&&(a=G(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,b!==a&&j(this,bb.duration(b-a,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?bb(a).zone():0,0===(this.zone()-a)%60},daysInMonth:function(){return r(this.year(),this.month())},dayOfYear:function(a){var b=eb((bb(this).startOf("day")-bb(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},weekYear:function(a){var b=W(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=W(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=W(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},get:function(a){return a=n(a),this[a]()},set:function(a,b){return a=n(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=A(b),this)}}),cb=0;cb<Ib.length;cb++)Z(Ib[cb].toLowerCase().replace(/s$/,""),Ib[cb]);Z("year","FullYear"),bb.fn.days=bb.fn.day,bb.fn.months=bb.fn.month,bb.fn.weeks=bb.fn.week,bb.fn.isoWeeks=bb.fn.isoWeek,bb.fn.toJSON=bb.fn.toISOString,g(bb.duration.fn=f.prototype,{_bubble:function(){var a,b,c,d,e=this._milliseconds,f=this._days,g=this._months,i=this._data;i.milliseconds=e%1e3,a=h(e/1e3),i.seconds=a%60,b=h(a/60),i.minutes=b%60,c=h(b/60),i.hours=c%24,f+=h(c/24),i.days=f%30,g+=h(f/30),i.months=g%12,d=h(g/12),i.years=d},weeks:function(){return h(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+2592e6*(this._months%12)+31536e6*q(this._months/12)},humanize:function(a){var b=+this,c=V(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},add:function(a,b){var c=bb.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=bb.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=n(a),this[a.toLowerCase()+"s"]()},as:function(a){return a=n(a),this["as"+a.charAt(0).toUpperCase()+a.slice(1)+"s"]()},lang:bb.fn.lang,toIsoString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}});for(cb in Jb)Jb.hasOwnProperty(cb)&&(_(cb,Jb[cb]),$(cb.toLowerCase()));_("Weeks",6048e5),bb.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},bb.lang("en",{ordinal:function(a){var b=a%10,c=1===q(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),nb?(module.exports=bb,ab(!0)):"function"==typeof define&&define.amd?define("moment",function(b,c,d){return d.config().noGlobal!==!0&&ab(d.config().noGlobal===a),bb}):ab()}).call(this); \ No newline at end of file diff --git a/VIPSWeb/templates/base.html b/VIPSWeb/templates/base.html index 4c346124439a08d43ba2e46482ef8b362fd63298..793664a5c045107b7fcd7efca70b89c04f3cfff2 100644 --- a/VIPSWeb/templates/base.html +++ b/VIPSWeb/templates/base.html @@ -55,7 +55,7 @@ <ul class="nav navbar-nav"> <li><a href="/forecasts">{% trans "Forecasts" %}</a></li> <li><a href="/messages">{% trans "Messages" %}</a></li> - <li class="dropdown"> + <!--li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans "Dropdown" %} <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="#">{% trans "Action" %}</a></li> @@ -64,7 +64,7 @@ <li><a href="#">{% trans "Separated link" %}</a></li> <li><a href="#">{% trans "One more separated link" %}</a></li> </ul> - </li> + </li--> </ul> </div><!-- /.navbar-collapse --> diff --git a/VIPSWeb/templates/index.html b/VIPSWeb/templates/index.html index 79a01c1cc4d4b096aa98238bd7c41c54b2c055c8..3e99475aa64b178eeb0698a9db79a964a5786846 100644 --- a/VIPSWeb/templates/index.html +++ b/VIPSWeb/templates/index.html @@ -18,15 +18,17 @@ along with VIPSWeb. If not, see <http://www.gnu.org/licenses/>. {% endcomment %} -{% load i18n l10n staticfiles %} +{% load i18n l10n staticfiles forecast_extras %} {% block title%}{% trans "Welcome" %}{%endblock%} {% block customCSS %} <link rel="stylesheet" href="http://ol3js.org/en/master/build/ol.css" type="text/css"> {% endblock %} {% block customJS %} <script type="text/javascript" src="{% url 'django.views.i18n.javascript_catalog' %}"></script> -<script src="http://ol3js.org/en/master/build/ol.js" type="text/javascript"></script> -<script src="{% static "js/forecastmap.js" %}"></script> +<script type="text/javascript" src="http://ol3js.org/en/master/build/ol.js" type="text/javascript"></script> +<script type="text/javascript" src="/forecasts/models/js/modelLocalNames.js"></script> +<script type="text/javascript" src="{% static "js/moment.min.js" %}"></script> +<script type="text/javascript" src="{% static "js/forecastmap.js" %}"></script> <script type="text/javascript"> $(document).ready(function() { // Init frontpage map. Depending on forecastmap.js. @@ -38,20 +40,32 @@ {% block content %} <div class="row"> <!-- Start map container --> - <div class="col-md-9"> + <div class="col-md-8"> <div id="map" class="map"> <!-- Info window box --> <div id="tooltip"></div> <div id="popover"></div> </div> </div><!-- End map container --> - <div class="col-md-3"> + <div class="col-md-4"> <h1>{% trans "Messages" %}</h1> - <ul> - {% for message in messages %} - <li><a href="{% url 'messages:detail' message.id %}">{{message.headline}}</a></li> - {% endfor %} - </ul> + <table class="table table-hover table-condensed table-striped"> + {% for message_tag in message_tags %} + <thead> + <tr> + <th colspan="2">{{message_tag.title}}</th> + </tr> + </thead> + <tbody> + {% for message in messages_by_tag|lookup:message_tag.id %} + <tr> + <td>{{ message.pub_date|date:"Y-m-d" }}</td> + <td><a href="{% url 'messages:detail' message.id %}">{{message.headline}}</a></td> + </tr> + {% endfor %} + </tbody> + {% endfor %} + </table> </div> </div><!-- End row with sidebar and contents container --> {% endblock %} \ No newline at end of file diff --git a/VIPSWeb/views.py b/VIPSWeb/views.py index 076c95556e3a1e84d0c68bc4fa484eb2df95b147..e684fa160d405714434481b6cdfd06ebd46c5278 100644 --- a/VIPSWeb/views.py +++ b/VIPSWeb/views.py @@ -1,12 +1,27 @@ from django.shortcuts import render - -from messages.models import Message +from django.conf import settings +from messages.models import Message, MessageTag def index(request): + # Get frontpage categories. This is defined in local_settings.py + message_tags = [] + messages_by_tag = {} + for message_tag_id in settings.FRONTPAGE_MESSAGE_TAG_IDS: + message_tag = MessageTag.objects.get(pk=message_tag_id) + print message_tag + message_tags.append(message_tag) + messages = Message.objects.filter(message_tags__pk=message_tag_id) + messages_by_tag[message_tag_id] = messages + #for message in messages: + # print message + #messages_ordered.append(message_tagged) + # Last 10 messages messages = Message.objects.order_by('pub_date').reverse()[:10] context = { 'messages' : messages, + 'message_tags': message_tags, + 'messages_by_tag': messages_by_tag } return render(request, 'index.html', context) diff --git a/common/__init__.py b/common/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/middleware/__init__.py b/common/middleware/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/common/middleware/whodid.py b/common/middleware/whodid.py new file mode 100644 index 0000000000000000000000000000000000000000..00cb7a73b18fd0fcc88836f168080f5ed264b36b --- /dev/null +++ b/common/middleware/whodid.py @@ -0,0 +1,46 @@ +""" + Copyright (C) 2014 Bioforsk/mindlace + + This file is part of VIPSWeb + + VIPSWeb is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + VIPSWeb is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with VIPSWeb. If not, see <http://www.gnu.org/licenses/>. +""" +""" +Add user created_by and modified_by foreign key refs to any model automatically. +Found here: https://gist.github.com/mindlace/3918300 +""" +from django.db.models import signals +from django.utils.functional import curry + +class WhodidMiddleware(object): + def process_request(self, request): + if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): + if hasattr(request, 'user') and request.user.is_authenticated(): + user = request.user + else: + user = None + + mark_whodid = curry(self.mark_whodid, user) + signals.pre_save.connect(mark_whodid, dispatch_uid = (self.__class__, request,), weak = False) + + def process_response(self, request, response): + signals.pre_save.disconnect(dispatch_uid = (self.__class__, request,)) + return response + + def mark_whodid(self, user, sender, instance, **kwargs): + print instance + if not getattr(instance, 'created_by_id', None): + instance.created_by = user + if hasattr(instance,'modified_by_id'): + instance.modified_by = user \ No newline at end of file diff --git a/forecasts/models.py b/forecasts/models.py index 3296795a39e03b4dab1a263735d389b3ca684e8c..af9fbf3231d3185c0b6627192b9840aae3cb8e49 100644 --- a/forecasts/models.py +++ b/forecasts/models.py @@ -180,17 +180,23 @@ class Model: @staticmethod def get_model(model_id): cur_language = translation.get_language() - name = Model.get_local_name_for_model(model_id) + local_name = Model.get_local_name_for_model(model_id) description = requests.get("http://%s/models/%s/description/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language)).text usage = requests.get("http://%s/models/%s/usage/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language)).text sample_config = requests.get("http://%s/models/%s/sampleconfig" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id)).text - return Model(model_id,name, description, usage,sample_config) + return Model(model_id,local_name, description, usage,sample_config) @staticmethod def get_local_name_for_model(model_id): cur_language = translation.get_language() return requests.get("http://%s/models/%s/name/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language)).text - + + @staticmethod + def get_models_local_names(): + cur_language = translation.get_language() + model_ids = requests.get("http://%s/models/json/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME,cur_language)) + return model_ids.json() + """ STUFF IN LOCAL DATABASE """ diff --git a/forecasts/templates/models/detail.html b/forecasts/templates/models/detail.html index f8c2150fe75f24f7a7d255ec810c09c7bf31903d..8bf79f979df046f615948dcc0e4b0c9adde86ea3 100644 --- a/forecasts/templates/models/detail.html +++ b/forecasts/templates/models/detail.html @@ -1,8 +1,8 @@ {% extends "base.html" %} {% load i18n %} -{% block title%}{{model_name}} - {% trans "Models" %}{%endblock%} +{% block title%}{{model.local_name}} - {% trans "Models" %}{%endblock%} {% block content %} -<h1>{{model_name}}</h1> +<h1>{{model.local_name}}</h1> <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#modelDescription">{% trans "Description" %}</a></li> <li><a data-toggle="tab" href="#modelUsage">{% trans "Usage" %}</a></li> diff --git a/forecasts/templates/models/modelLocalNames.js b/forecasts/templates/models/modelLocalNames.js new file mode 100644 index 0000000000000000000000000000000000000000..84556119a50b76c08311162dc6b60dc92a4ed8c2 --- /dev/null +++ b/forecasts/templates/models/modelLocalNames.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Bioforsk <http://www.bioforsk.no/>. + * + * This file is part of VIPSWeb. + * VIPSWeb is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VIPSWeb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with VIPSWeb. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * Include this in your HTML page if you want to avoid fetching local names + * of the models asynchronously from VIPSLogic + * + * @copyright 2014 <a href="http://www.bioforsk.no/">Bioforsk</a> + * @author Tor-Einar Skog <tor-einar.skog@bioforsk.no> + */ +{% load forecast_extras %} +var modelLocalNames= {}; + +{% for model in models_local_names %} +modelLocalNames["{{model|lookup:'modelId'}}"] = "{{model|lookup:'modelName'}}"; +{% endfor %} \ No newline at end of file diff --git a/forecasts/urls.py b/forecasts/urls.py index 43b2bb39181a64e7c37ad557beb6b02aebcbeeb7..06d8389413a4f1f534885c0728c083801cae84aa 100644 --- a/forecasts/urls.py +++ b/forecasts/urls.py @@ -9,6 +9,7 @@ urlpatterns = patterns('', url(r'^(?P<forecast_id>\d+)/detail_highcharts_json/$', views.detail_highcharts_json, name='detail_highcharts_json'), url(r'^(?P<forecast_id>\d+)/$', views.detail, name='detail'), url(r'^models/(?P<model_id>\w+)/$', views.models_detail, name='models_detail'), + url(r'^models/js/modelLocalNames.js', views.model_local_names_js, name='model_local_names_js'), url(r'^models/$', views.models_index, name='models_index'), ) \ No newline at end of file diff --git a/forecasts/views.py b/forecasts/views.py index 75646fd8e92c7721e2ea8bfec77867af5f26794d..8a2b439679ba33d1651c3631933fb87ec2320ef0 100644 --- a/forecasts/views.py +++ b/forecasts/views.py @@ -35,6 +35,12 @@ def models_detail(request, model_id): context = {'model': model} return render(request, 'models/detail.html', context) +def model_local_names_js(request): + models_local_names = Model.get_models_local_names() + #print models_local_names + context = {'models_local_names': models_local_names} + return render(request,'models/modelLocalNames.js', context, content_type="application/javascript;charset=UTF-8") + # Converting JSON results to Highcharts timeseries def detail_highcharts_json(request, forecast_id): results_json = ForecastResult.get_forecast_results_as_json(forecast_id) diff --git a/messages/admin.py b/messages/admin.py index cbe1c5ead0959950b1d753aa44c0c8b1717c55ec..6365e6dc11987767ee476c9d1fced7d0e74a627d 100644 --- a/messages/admin.py +++ b/messages/admin.py @@ -1,4 +1,9 @@ from django.contrib import admin -from messages.models import Message +from messages.models import Message, MessageTag -admin.site.register(Message) +class MessageAdmin(admin.ModelAdmin): + list_display = ['pub_date','headline','created_by'] + list_filter = ['message_tags'] + +admin.site.register(Message, MessageAdmin) +admin.site.register(MessageTag) diff --git a/messages/locale/nb/LC_MESSAGES/django.mo b/messages/locale/nb/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..459f325dff160b877fbe2df91de5120c3e97567a Binary files /dev/null and b/messages/locale/nb/LC_MESSAGES/django.mo differ diff --git a/messages/locale/nb/LC_MESSAGES/django.po b/messages/locale/nb/LC_MESSAGES/django.po new file mode 100644 index 0000000000000000000000000000000000000000..17c02c5699ff5aee14243decbb7197e5bc120ef9 --- /dev/null +++ b/messages/locale/nb/LC_MESSAGES/django.po @@ -0,0 +1,41 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-01-16 15:31+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: templates/messages/index.html:3 +#: templates/messages/index.html.py:5 +msgid "Messages" +msgstr "Meldinger" + +#: templates/messages/index.html:12 +msgid "Publish date" +msgstr "Publiseringsdato" + +#: templates/messages/index.html:13 +msgid "Headline" +msgstr "Overskrift" + +#: templates/messages/index.html:14 +msgid "Author" +msgstr "Forfatter" + +#: templates/messages/index.html:24 +msgid "Details" +msgstr "Detaljer" + diff --git a/messages/models.py b/messages/models.py index 260d32b9af9910072dce2d40651b763c7741e0fa..e472cb5ced9f8a7e39bce78dd4f06046c1884e10 100644 --- a/messages/models.py +++ b/messages/models.py @@ -1,16 +1,27 @@ from django.db import models +from django.contrib.auth.models import User from datetime import timedelta # Create your models here. +class MessageTag(models.Model): + title = models.CharField(max_length=255) + + def __unicode__(self): + return self.title + class Message(models.Model): headline = models.CharField(max_length=255) lead = models.TextField(blank=True) body_text = models.TextField() pub_date = models.DateField() - mod_date = models.DateField() valid_to_date = models.DateField(blank=True) # Default is 14 days after pub_date. See self.save illustration = models.ImageField(upload_to='images/messages', blank=True) - + created_by = models.ForeignKey(User, related_name='messages_message_created_by', editable=False) + modified_by = models.ForeignKey(User, related_name='messages_message_modified_by', editable=False) + created_date = models.DateTimeField(auto_now_add=True, editable=False) + modified_date = models.DateTimeField(auto_now=True, editable=False) + message_tags = models.ManyToManyField(MessageTag) + def __unicode__(self): return self.headline @@ -19,4 +30,6 @@ class Message(models.Model): if self.valid_to_date == None: self.valid_to_date = self.pub_date + timedelta(days=14) super(Message, self).save(*args, **kwargs) - \ No newline at end of file + + + \ No newline at end of file diff --git a/messages/templates/messages/index.html b/messages/templates/messages/index.html index 78ee863b799240d5a176dae92ec0f87fc456b2ed..6cc1427edcc7d2bd89bd72fd83ca15d57b12f917 100644 --- a/messages/templates/messages/index.html +++ b/messages/templates/messages/index.html @@ -4,8 +4,31 @@ {% block content %} <h1>{% trans "Messages" %}</h1> <ul> -{% for message in messages reversed %} -<li><a href="{% url 'messages:detail' message.id %}">{{message.headline}}</a></li> -{% endfor %} + +<div class="table-responsive"> + <table id="resultTable" class="table table-striped"> + <thead> + <tr> + <th>{% trans "Publish date" %}</th> + <th>{% trans "Headline" %}</th> + <th>{% trans "Tags" %} + <th>{% trans "Author" %}</th> + <th></th> + </tr> + </thead> + <tbody> + {% for message in messages reversed %} + <tr> + <td>{{ message.pub_date }}</td> + <td>{{ message.headline}}</td> + <td>{{ message.message_tags.all|join:","}}</td> + <td>{{ message.created_by}}</td> + <td><a href="{% url 'messages:detail' message.id %}">{% trans "Details" %}</a></td> + </tr> + {% endfor %} + </tbody> + </table> +</div> + </ul> {% endblock %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..cdfe72a7208f84b7b6f2fc96df85f04bd48bc4b3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,20 @@ +# Copyright (C) 2014 Bioforsk +# +# This file is part of VIPSWeb +# +# VIPSWeb is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# VIPSWeb is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with VIPSWeb. If not, see <http://www.gnu.org/licenses/>. + +# Please add requirements here +# Read docs for how this works: http://www.pip-installer.org/en/latest/cookbook.html +Django==1.6.1 \ No newline at end of file