From d1007e490f5fb36948e2318bcac1a13767dc0f85 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@bioforsk.no> Date: Tue, 23 Feb 2016 15:06:07 +0100 Subject: [PATCH] Adding oat flowering model form and Google Analytics stuff --- VIPSWeb/local_settings_sample.py | 15 + VIPSWeb/settings.py | 1 + VIPSWeb/templates/base.html | 10 +- VIPSWeb/templates/settings.js | 1 + VIPSWeb/urls.py | 1 + fusarium/__init__.py | 0 fusarium/admin.py | 3 + fusarium/locale/nb/LC_MESSAGES/django.mo | Bin 0 -> 493 bytes fusarium/locale/nb/LC_MESSAGES/django.po | 25 ++ fusarium/migrations/__init__.py | 0 fusarium/models.py | 3 + .../fusarium/js/oatFloweringModelForm.js | 393 ++++++++++++++++++ .../templates/fusarium/oat_flowering.html | 51 +++ fusarium/tests.py | 3 + fusarium/urls.py | 25 ++ fusarium/views.py | 8 + security/models.py | 1 + 17 files changed, 534 insertions(+), 6 deletions(-) create mode 100644 fusarium/__init__.py create mode 100644 fusarium/admin.py create mode 100644 fusarium/locale/nb/LC_MESSAGES/django.mo create mode 100644 fusarium/locale/nb/LC_MESSAGES/django.po create mode 100644 fusarium/migrations/__init__.py create mode 100644 fusarium/models.py create mode 100644 fusarium/static/fusarium/js/oatFloweringModelForm.js create mode 100644 fusarium/templates/fusarium/oat_flowering.html create mode 100644 fusarium/tests.py create mode 100644 fusarium/urls.py create mode 100644 fusarium/views.py diff --git a/VIPSWeb/local_settings_sample.py b/VIPSWeb/local_settings_sample.py index 0ee25778..5c9ce16a 100644 --- a/VIPSWeb/local_settings_sample.py +++ b/VIPSWeb/local_settings_sample.py @@ -94,6 +94,21 @@ DATABASES = { # Site name - appears in header of all pages SITE_NAME = "Example site title" +# Insert Google Analytics Script? +INSERT_GOOGLE_ANALYTICS = False +GOOGLE_ANALYTICS_SCRIPT = """ +<!-- Google Analytics --> +<script> + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); + + ga('create', '[YOUR CODE HERE]', '[YOUR CONFIG HERE]'); + +</script> +""" + # The server name used for VIPSLogic VIPSLOGIC_SERVER_NAME = "vipslogic" # This organization's ID in VIPSLogic/CoreManager diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py index e767e056..ed1ef3c6 100644 --- a/VIPSWeb/settings.py +++ b/VIPSWeb/settings.py @@ -137,6 +137,7 @@ INSTALLED_APPS = ( 'cerealblotchmodels', 'calculators', 'roughage', + 'fusarium', 'security', 'VIPSWeb' ) diff --git a/VIPSWeb/templates/base.html b/VIPSWeb/templates/base.html index e1594733..8b16ca75 100644 --- a/VIPSWeb/templates/base.html +++ b/VIPSWeb/templates/base.html @@ -41,6 +41,9 @@ <script src="{% static "js/3rdparty/html5shiv.js" %}"></script> <script src="{% static "js/3rdparty/respond.min.js" %}"></script> <![endif]--> + {% if settings.INSERT_GOOGLE_ANALYTICS == True %} + {{ settings.GOOGLE_ANALYTICS_SCRIPT|safe }} + {% endif %} <title>{% block title %}Template{% endblock %} - VIPSWeb</title> </head> <body> @@ -64,16 +67,12 @@ <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse navbar-ex1-collapse" style="clear: both;"> - <ul class="nav navbar-nav navbar-right"> - {% generate_main_menu %} - </ul> </div><!-- /.navbar-collapse --> <div id="loginAndLanguageInfo"> - {% get_current_language as LANGUAGE_CODE %} <form action="/i18n/setlang/" method="post" class="form-inline"> <div class="form-group"> @@ -90,8 +89,7 @@ <div id="signInAndOut"> {% if request.session.vips_logic_user != None %} <a href="http://{{settings.VIPSLOGIC_SERVER_NAME}}" target="new" class="signinLink" title="{% trans "Administration" %}"><span class="fa fa-cogs"></span></a> - {{ request.session.vips_logic_user.firstName}} - {{ request.session.vips_logic_user.lastName}} + <a href="http://{{settings.VIPSLOGIC_SERVER_NAME}}/user?action=viewUser&userId={{request.session.vips_logic_user.userId}}" target="new">{{ request.session.vips_logic_user.firstName}} {{ request.session.vips_logic_user.lastName}}</a> <a href="/security/logout" class="signinLink" title="{% trans "Sign out" %}"> <span class="fa fa-sign-out"></span> </a> diff --git a/VIPSWeb/templates/settings.js b/VIPSWeb/templates/settings.js index b5d53df7..f29a3873 100644 --- a/VIPSWeb/templates/settings.js +++ b/VIPSWeb/templates/settings.js @@ -11,6 +11,7 @@ var settings = { vipsOrganizationId: {{settings.VIPS_ORGANIZATION_ID}}, vipslogicServerName: "{{settings.VIPSLOGIC_SERVER_NAME}}", + vipsCoremanagerServerName : "{{settings.VIPSCOREMANAGER_SERVER_NAME}}", mapZoomlevel: {{settings.MAP_ZOOMLEVEL}}, diff --git a/VIPSWeb/urls.py b/VIPSWeb/urls.py index d27cb482..5d4f571e 100644 --- a/VIPSWeb/urls.py +++ b/VIPSWeb/urls.py @@ -49,6 +49,7 @@ urlpatterns = patterns('', url(r'^calculators/', include('calculators.urls', namespace = "calculators")), url(r'^roughage/', include('roughage.urls', namespace = "roughage")), url(r'^security/', include('security.urls', namespace = "security")), + url(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), url(r'^tinymce/', include('tinymce.urls')), diff --git a/fusarium/__init__.py b/fusarium/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fusarium/admin.py b/fusarium/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/fusarium/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/fusarium/locale/nb/LC_MESSAGES/django.mo b/fusarium/locale/nb/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..10e23878d8b764891d18e69b8854d6b6d0a4bb27 GIT binary patch literal 493 zcmca7#4?qEfq{XEfq_AWfq_AXfq{XQfq}sWB*?(P5Wv8|Ak4tP5Xiv5kj==zkjlWo zAkDzQaFLOLff1?(M1k~!Xa@hp5{0y!{PNVI%)E4k-29Z(9EO0R{H)aE5?#*}-LTZ6 z;>`R!D}?|@XKzP$SA{UwpkPmbKdzwEg8ZTqUEkvL%oJUx()428kbElzt^ofKUFV|I z#FEVXJYAQ>l2j`NBLhP-T>~RsBVz?aQ!4`_Z39CC1Fisn-JsO6OpxJFb&;-)LAt*F zx-O0i9{yIop4w6Vey&_TiNz(lAw`LK#W{&3`9)R=ZlOLt3Vx2ht_n7;zK)(g4vsD^ zL9W5Uc3eJ*dFiEz>8ZLQsfoE(3O<g0?x7$j+xYl6<YemQ7o{WASSfJ%diuH|{AZ|V zz~!8uSCX1nq8n0KkZPq+l3G!sUyzfSnP;t#oRL^moLXWV8sesFflvo>R$6M2u4`U$ zeoAIux|M=OQf3KPKu&2<Vvep`eo=0*l|o(tm|JXXWUT;U+G^w}DB3C*YFcwKIOXK$ Y7MFkmzZe|&ISOg{MG6^-WksnB08a{s;s5{u literal 0 HcmV?d00001 diff --git a/fusarium/locale/nb/LC_MESSAGES/django.po b/fusarium/locale/nb/LC_MESSAGES/django.po new file mode 100644 index 00000000..6be96eff --- /dev/null +++ b/fusarium/locale/nb/LC_MESSAGES/django.po @@ -0,0 +1,25 @@ +# 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: 2016-02-23 15:02+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/fusarium/oat_flowering.html:3 +#: templates/fusarium/oat_flowering.html:9 +msgid "Oat flowering model" +msgstr "Blomstringsmodell for havre" + diff --git a/fusarium/migrations/__init__.py b/fusarium/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fusarium/models.py b/fusarium/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/fusarium/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/fusarium/static/fusarium/js/oatFloweringModelForm.js b/fusarium/static/fusarium/js/oatFloweringModelForm.js new file mode 100644 index 00000000..95f07fa8 --- /dev/null +++ b/fusarium/static/fusarium/js/oatFloweringModelForm.js @@ -0,0 +1,393 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.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/>. + * + */ +/** + * Self-serving application that calculates flowering period for oat. + * Depending on: + * <ul> + * <li>weather data source</li> + * <li>the oat flowering model in the VIPS forecasting system </li> + * <li>moment.js and moment-timezone.js (http://momentjs.com)</li> + * <li>settings.js from main app (VIPSWeb)</li> + * <li>Twitter Bootstrap (getbootstrap.com) for form layout</li> + * </ul> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ + +// *********** Configuration section **************** + +// Internal ID for the form +var theFormId = "_oatFloweringModelForm"; +var detailURL = null; +var DEBUG = false; + +// Settings for VIPS forecasting system +var serverUri = settings.vipsCoremanagerServerName; +//var serverUri = "https://coremanager.vips.nibio.no"; +//var serverUri = "http://vipscoremanager"; +var runUri= "http://" + serverUri + "/models/OATFLOWERM/run"; +var coreUserName = ""; +var corePass = ""; + +// Location of weather data source +var weatherDataBaseUri = "http://lmt.nibio.no/agrometbase/export/getSeasonDailyTemperaturesJSON.php"; +//var weatherDataBaseUri = "http://agrometbase-local/agrometbase/export/getSeasonDailyTemperaturesJSON.php"; + +// Setting current time +var now = moment(); +//var now = moment("2014-07-04"); + + +// ************ End configuration section ************ + +/** + * Initializes the application. Sets up form, based on given options + */ +var oatForm = function(options) +{ + // Get options, validate + this.target = options.target; + this.weatherStations = options.weatherStations; + coreUsername = options.coreUserName; + corePass = options.corePass; + //console.log(options.now); + now = options.now != undefined ? moment(options.now) : now; + + + // Start stuff + var workspace = document.getElementById(this.target); + var height = workspace.offsetHeight; + var width = workspace.offsetWidth; + DEBUG = options.debug != null ? options.debug : false; + workspace.innerHTML = getStartHTML(); + + var theForm = document.getElementById(theFormId); + + // Then, add weather stations + for(i in this.weatherStations) + { + var option = new Option(this.weatherStations[i].name,this.weatherStations[i].weatherstation_id); + theForm.weatherStationId.options[theForm.weatherStationId.options.length]=option; + } +}; + +/** + * Start the chain of functions that run the model + */ +var submitForm = function() +{ + // TODO: Validate input + // Date of sowing format + if(!getDateOfSowing().isValid()) + { + alert('Ikke gyldig dato. Tips: Skriv eksempelvis 2014-04-02 for 2. april 2014.'); + return; + } + // Date of sowing limit is July 1st + var thisYear = getDateOfSowing().year(); + var dateOfSowingLimit = moment(thisYear + "-07-01","YYYY-MM-DD"); + if(getDateOfSowing().isAfter(dateOfSowingLimit)) + { + alert("Saadato er etter 1. juli. Dette stemmer antakelig ikke. Ingen beregninger er foretatt."); + return; + } + var theForm = document.getElementById(theFormId); + if(theForm.weatherStationId.options[theForm.weatherStationId.selectedIndex].value <= 0) + { + alert("Vennligst velg klimastasjon"); + return; + } + // See if test input now is set + if(DEBUG) + { + now = getNow(); + } + + // Erase previous results + displayResultHTML(""); + + // Start chain of async functions + createConfig(); + +} + +/** + * Creates the configuration for weather data. Moves on to running model after data returns + */ +var createConfig = function(){ + + + var theForm = document.getElementById(theFormId); + var weatherStationId = theForm.weatherStationId.options[theForm.weatherStationId.selectedIndex].value; + var dateOfSowing = getDateOfSowing(); + // Challenge: Get weather data asynchronously first.... + //Tip: Use jQuery.stringify + //var theConfig = + var weatherDataUri = [weatherDataBaseUri, + "?startDate=", dateOfSowing.format("YYYY-MM-DD"), + (DEBUG ? "&today=" + now.format("YYYY-MM-DD") : ""), + "&weatherStationId=", weatherStationId//, + //"&callback=?" + ].join(""); + + + var jqxhr = $.ajax( { + url:weatherDataUri, + dataType: "json" + }) + .done(function(data, textStatus, jqXHR) { + runModel(data); + }) + .fail(function( jqXHR, textStatus,errorThrown ) { + alert( "Request failed: " + errorThrown ); + }) + .always(function() { + //alert( "complete" ); + }) + ; + + +}; + +/** + * Calls the oatFlowering model in the VIPS forecasting system + * Displays data when results are returned + */ +var runModel = function(data) +{ + //console.log("runModel"); + var dateOfSowing = getDateOfSowing(); + var modelConfig = { + "loginInfo":{ + "username":"testuser", + "password":"testpass" + }, + "modelId":"OATFLOWERM", + "configParameters":{ + //"dateOfSowing":"2013-04-01T00:00:00+02:00", + "dateOfSowing":dateOfSowing.format("YYYY-MM-DD"), + "observations": data + } + }; + + //console.log(data); + var request = $.ajax({ + type:"POST", + url: runUri, + data: JSON.stringify(modelConfig), + dataType: "json", + contentType: "application/json; charset=utf-8", + }) + .done(function(data, textStatus, jqXHR) { + displayResults(data); + }) + .fail(function( jqXHR, textStatus,errorThrown ) { + alert( "Request failed: " + errorThrown ); + }) + .always(function() { + //alert( "complete" ); + }) + ; + +} + +/** + * Analyze and display results from the OatFlowering model in VIPS + */ +var displayResults = function(data) +{ + // getting the dates + var dateOfSowing = getDateOfSowing(); + var dateZ60 = getDateForZ(data,60); + var weekZ625 = getWeekForZ(data,62.5); + var dateZ69 = getDateForZ(data,69); + now = getNow(); + var weekNow = now.week(); + var weeksFromNowToZ625 = Math.abs(weekZ625-weekNow); + /*console.log("now: " + now.tz("Europe/Oslo").format()); + console.log("z60: " + dateZ60.tz("Europe/Oslo").format()); + console.log("z62.5: " + getDateForZ(data,62.5).tz("Europe/Oslo").format()); + console.log("z69: " + dateZ69.tz("Europe/Oslo").format());*/ + + + // Scenario 1: Today is before date of sowing + if(now.isBefore(dateOfSowing)) + { + displayResultHTML( ["Havre sådd ", dateOfSowing.tz("Europe/Oslo").format("YYYY-MM-DD"), + " antas å være i blomstring i uke ", weekZ625, " (om ", weeksFromNowToZ625, " uker). ", + "Vi gjør oppmerksom på at oppgitt sådato er frem i tid. ", + "Beregningen vil derfor kun være basert på prognoser og historiske værdata. ", + "Dette anslaget vil ha større grad av sikkerhet når dagens dato nærmer seg ", + "tidspunktet for antatt blomstring.<br/>", + (DEBUG ? getRawResults(data) : "") + ].join("") + ); + } + // Scenario 2: Today is after date of sowing, but more than 10 days before z60 + else if(moment(now).add(10,"days").isBefore(dateZ60)) + { + displayResultHTML( ["Havre sådd ", dateOfSowing.tz("Europe/Oslo").format("YYYY-MM-DD"), + " antas å være i blomstring i uke ", weekZ625, " (om ", weeksFromNowToZ625, " uker). ", + "Vi gjør oppmerksom på at beregningen er basert på observerte værdata, ", + "i tillegg til prognoser og historiske værdata. ", + "Dette anslaget vil ha større grad av sikkerhet når dagens dato nærmer seg ", + "tidspunktet for antatt blomstring.<br/>", + (DEBUG ? getRawResults(data) : "") + ].join("") + ); + } + // Scenario 3: Today is after date of sowing, and 0-10 days before z60 OR before z69 + else if((now.isBefore(dateZ60) && moment(now).add("days",11).isAfter(dateZ60)) || now.isBefore(dateZ69)) + { + displayResultHTML(["Havre sådd ", dateOfSowing.tz("Europe/Oslo").format("YYYY-MM-DD"), + " antas å være i blomstring i perioden fra ", + moment(dateZ60).add("days",-5).tz("Europe/Oslo").format("YYYY-MM-DD"), + " til ", + moment(dateZ60).add("days",5).tz("Europe/Oslo").format("YYYY-MM-DD"), + ,". ", + "Dersom værforholdene ligger til rette for utvikling av mykotoksiner (DON)*, ", + "kan fungicidbehandling vurderes foretatt i perioden fra ",dateZ60.tz("Europe/Oslo").format("YYYY-MM-DD"), + " og en uke fremover i tid. Beregningen er basert på observerte værdata ", + "i tillegg til prognoser. ", + (DEBUG ? getRawResults(data) : "") + ].join("") + ); + } + + // Scenario 4: Today is after z69. Too late + else + { + displayResultHTML(["Havre sådd ", dateOfSowing.tz("Europe/Oslo").format("YYYY-MM-DD"), + " antas å ha vært i blomstring i uke ", weekZ625, " (for ", weeksFromNowToZ625, " uker siden). ", + "Det er antakelig for sent å behandle med fungicid for å redusere risikoen ", + "for utvikling av DON.<br/>", + (DEBUG ? getRawResults(data) : "") + ].join("") + ); + } + //console.log(data); +} + +/** + * Util/DEBUG function for displaying the results returned from VIPS + */ +var getRawResults = function(data) +{ + var result = "<h2>Rådata</h2><ul>"; + for(var key in data) + { + result +="<li>"; + result += "z" + data[key].allValues["OATFLOWERM.ZREACHED"] + " nådd " + + moment(data[key].resultValidTime).tz("Europe/Oslo").format("YYYY-MM-DD") + + " (uke " + data[key].allValues["OATFLOWERM.WEEK_IN_YEAR"] + ")<br/>"; + result +="</li>"; + } + result +="</ul>"; + return result; +} + +/** + * Interface for displaing the results + */ +var displayResultHTML = function(text) +{ + document.getElementById("oatFloweringModelResults").innerHTML= "<h2>Resultater</h2>" + text; +} + +/** + * Loops through results from VIPS, returns date for stadium Z + * Possible values for Z are [60,62.5,69] + */ +var getDateForZ = function(data,z) +{ + for(var key in data) + { + if(data[key].allValues["OATFLOWERM.ZREACHED"] == z) + { + return moment(data[key].resultValidTime); + } + } +} + +/** + * Loops through results from VIPS, returns week number (in year) for stadium Z + * Possible values for Z are [60,62.5,69] + */ +var getWeekForZ = function(data,z) +{ + for(var key in data) + { + if(data[key].allValues["OATFLOWERM.ZREACHED"] == z) + { + return data[key].allValues["OATFLOWERM.WEEK_IN_YEAR"]; + } + } +} + +/** + * Get date of sowing from form + */ +var getDateOfSowing = function() +{ + var theForm = document.getElementById(theFormId); + var dateOfSowing = moment(theForm.dateOfSowing.value,"YYYY-MM-DD"); + return dateOfSowing; +} + +/** + * Util function for getting current time + * @returns + */ +function getNow() +{ + var theForm = document.getElementById(theFormId); + if(theForm.now != undefined) + { + var formNow = moment(theForm.now.value,"YYYY-MM-DD"); + return formNow.isValid() ? formNow : now; + } + else return now; +} + +/** + * @return the HTML for the form + */ +var getStartHTML = function() +{ + return [ + + "<form id='",theFormId,"' role='form'>", + "<div class='form-group'>", + "<label for='dateOfSowing'>Sådato</label> ", + "<input class='form-control' type='date' name='dateOfSowing', value='",now.format("YYYY-MM-DD"),"'/><br/>", + "</div>", + (DEBUG ? "<div class='form-group'>" :""), + (DEBUG ? "<label for='now'>Nådato </label>" : ""), + (DEBUG ? ["<input type='date' class='form-control' name='now' value='", now.format("YYYY-MM-DD"), "'/><br/>"].join("") : ""), + (DEBUG ? "</div>" :""), + "<div class='form-group'>", + "<label for='weatherStationId'>Målestasjon</label>", + "<select name='weatherStationId' class='form-control'>", + "<option value='-1'>-- Vennligst velg målestasjon --</option>", + "</select><br/>", + "<button type='button' class='btn btn-default' onclick='submitForm();'>Beregn</button>", + "</form>", + "</div>", + "<div id='resultsTable'></div>" + ].join(""); +} diff --git a/fusarium/templates/fusarium/oat_flowering.html b/fusarium/templates/fusarium/oat_flowering.html new file mode 100644 index 00000000..ea6f331f --- /dev/null +++ b/fusarium/templates/fusarium/oat_flowering.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% load i18n staticfiles %} +{% block title%}{% trans "Oat flowering model" %}{%endblock%} +{% block extendCSS %} + +{% endblock %} +{% block content %} +<div class="singleBlockContainer"> + <h1>{% trans "Oat flowering model" %}</h1> + <p> + Her kan du beregne tidspunkt for når havren er i blomst og dermed når + en eventuell behandling med soppmiddel mot Fusarium må utføres. + <a href='http://gamlevips.nibio.no/information/if105s.jsp?HTTP_REFERRER=/information/if105s.jsp&BUTTON=kapittel&menyValg=4#blomstringsmodell_havre' target='new'>Les mer</a> + </p> + <div id="oatFloweringModelForm" style="width:100%"></div> + <div id="oatFloweringModelResults" style="width:100%;"></div> +</div> +{% endblock %} +{% block extendJS%} + +{% endblock %} +{% block customJS%} +<script type="text/javascript" src="{% static "js/3rdparty/moment.min.js" %}"></script> +<script type="text/javascript" src="{% static "js/3rdparty/moment-timezone-with-data.min.js" %}"></script> +<script type="text/javascript" src="{% static "js/3rdparty/modernizr_custom.js"%}"></script> +<script type="text/javascript" src="{% url "views.settings_js" %}"></script> +<script src="{% static "fusarium/js/oatFloweringModelForm.js" %}"></script> +<script type="text/javascript"> + + var weatherStations = []; + $(document).ready(function() { + $.getJSON("http://lmt.nibio.no/agrometbase/export/getNormalDataStationsJSON.php", function( json ) { + weatherStations = json; + var formApp = new oatForm({ + target:"oatFloweringModelForm", + weatherStations:weatherStations, + //coreUsername:"gamlevips", + //corePass:"gamlevips123" + coreUsername:"testuser", + corePass:"testpass", + debug : false + }); + + // Date picker fallback + if (!Modernizr.inputtypes.date) { + $('input[type=date]').datepicker({ dateFormat: 'yy-mm-dd' }); + } + }); + }); +</script> +{% endblock %} diff --git a/fusarium/tests.py b/fusarium/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/fusarium/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/fusarium/urls.py b/fusarium/urls.py new file mode 100644 index 00000000..d5bbfe9e --- /dev/null +++ b/fusarium/urls.py @@ -0,0 +1,25 @@ +# +# Copyright (c) 2016 NIBIO <http://www.nibio.no/>. +# +# This file is part of VIPSWeb. +# VIPSWeb is free software: you can redistribute it and/or modify +# it under the terms of the NIBIO Open Source License as published by +# NIBIO, either version 1 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 +# NIBIO Open Source License for more details. +# +# You should have received a copy of the NIBIO Open Source License +# along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. +# + +from django.conf.urls import patterns, url + +from fusarium import views + +urlpatterns = patterns('', + url(r'^$', views.index, name='index'), +) \ No newline at end of file diff --git a/fusarium/views.py b/fusarium/views.py new file mode 100644 index 00000000..35d201f9 --- /dev/null +++ b/fusarium/views.py @@ -0,0 +1,8 @@ +from django.shortcuts import render + +# Create your views here. + + +def index(request): + context = {} + return render(request, 'fusarium/oat_flowering.html', context) \ No newline at end of file diff --git a/security/models.py b/security/models.py index 40c943b5..ad58a49d 100644 --- a/security/models.py +++ b/security/models.py @@ -54,6 +54,7 @@ class VipsLogicUser: request_result = requests.get("http://%s/rest/user/uuid/%s" % (settings.VIPSLOGIC_SERVER_NAME,user_uuid)) if request_result.status_code == 200: #return VipsLogicUser.get_instance_from_dict(request_result.json()) + #print request_result.json() return request_result.json() else: return None -- GitLab