Skip to content
Snippets Groups Projects
Commit ccd946c0 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Apple fruit moth module Alpha 1

parent 0e762bb5
Branches
No related tags found
No related merge requests found
...@@ -137,6 +137,7 @@ INSTALLED_APPS = ( ...@@ -137,6 +137,7 @@ INSTALLED_APPS = (
'cerealblotchmodels', 'cerealblotchmodels',
'calculators', 'calculators',
'roughage', 'roughage',
'applefruitmoth',
'fusarium', 'fusarium',
'security', 'security',
'VIPSWeb' 'VIPSWeb'
......
...@@ -50,6 +50,7 @@ urlpatterns = patterns('', ...@@ -50,6 +50,7 @@ urlpatterns = patterns('',
url(r'^roughage/', include('roughage.urls', namespace = "roughage")), url(r'^roughage/', include('roughage.urls', namespace = "roughage")),
url(r'^security/', include('security.urls', namespace = "security")), url(r'^security/', include('security.urls', namespace = "security")),
url(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")), url(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")),
url(r'^applefruitmoth/', include('applefruitmoth.urls', namespace = "applefruitmoth")),
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^tinymce/', include('tinymce.urls')), url(r'^tinymce/', include('tinymce.urls')),
......
from django.contrib import admin
# Register your models here.
File added
# 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-04-08 16:28+0200\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/applefruitmoth/index.html:25
#: templates/applefruitmoth/index.html:27
msgid "Apple fruit moth forecasting"
msgstr "Rognebærmøllvarsling"
#: templates/applefruitmoth/index.html:32
msgid "Description of apple fruit moth forecasting"
msgstr "Beskrivelse av rognebærmøllvarslingen"
#: templates/applefruitmoth/index.html:33
msgid "Messages"
msgstr "Meldinger"
from django.db import models
# Create your models here.
/*
* 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/>.
*
*/
var initMap = function(container, mapAttribution)
{
// Creating background layer, Open Street Map is default
var backgroundLayer = new ol.layer.Tile({
source: new ol.source.OSM({
attributions: [
new ol.Attribution({
html: mapAttribution
})
]
})
});
forecastLayer = new ol.layer.Vector({
source: new ol.source.Vector({
url: "http://" + settings.vipslogicServerName + "/rest/applefruitmoth/observationsites/kml/2016",
format: new ol.format.KML({"extractAttributes":true}),
projection: ol.proj.get('EPSG:3857')
})
});
// Layer for popup
var popOverlay = new ol.Overlay({
element: document.getElementById("popover")
});
// Creating the map
map = new ol.Map({
target: container,
layers: [backgroundLayer, forecastLayer],
overlays: [popOverlay],
renderer: 'canvas'
});
// Setting zoom and center for the map (need to do this after creating map. so that we can transform our
// center to correct map projection)
var view = new ol.View({
center: ol.proj.transform([9,61], 'EPSG:4326', map.getView().getProjection().getCode()),
zoom: 6
});
map.setView(view);
// Using Bootstrap's popover plugin. See http://getbootstrap.com/javascript/#popovers
var poiDetails = $("#popover");
// State cariable
var currentClickedFeature = false;
// Displays popup with forecasts for a given station
// (if there is a station where the click event is fired)
var displayFeatureDetails = function(pixel, coordinate) {
var feature = map.forEachFeatureAtPixel(pixel, function(feature,layer){
return feature;
});
if (feature) {
// Position the popup, and hiding it
// Resetting information from (possible) former popups
var geometry = feature.getGeometry();
popOverlay.setPosition(geometry.getCoordinates());
poiDetails.popover('destroy');
currentClickedFeature = feature;
poiDetails.popover({
animation: true,
trigger: 'manual',
html: true,
placement: "auto top",
title: feature.get("name"),
content: feature.get("description")
});
poiDetails.popover('show');
} else {
currentClickedFeature = null;
poiDetails.popover('destroy');
}
};
// On click, display forecasts in popup
map.on('singleclick', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureDetails(pixel);
});
}
\ No newline at end of file
{% extends "base.html" %}
{% load staticfiles %}
{% comment %}
#
# 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/>.
#
{% endcomment %}
{% load i18n %}
{% block title%}{% trans "Apple fruit moth forecasting" %}{%endblock%}
{% block content %}
<h1>{% trans "Apple fruit moth forecasting" %}</h1>
<div class="singleBlockContainer">
<div class="row">
<div class="col-md-6">
<p>{% trans "Description of apple fruit moth forecasting"%}</p>
<h2>{% trans "Messages" %}</h2>
{% for message in vips_messages %}
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{message.message_id}}">
{{message.date_pub|date:"Y-m-d"}}: {{message.heading}}</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse{% if forloop.first %} in{% endif %}">
<div class="panel-body">
<p class="lead">{{message.lead_paragraph}}</p>
<p>{{message.body}}</p>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="col-md-6">
<div id="appleFruitMothForecastMap" class="map" style="height: 600px;"><div id="popover"></div></div>
</div>
</div>
</div>
{% endblock %}
{% block customCSS %}
<link rel="stylesheet" href="{% static "css/3rdparty/ol.css" %}" type="text/css">
{% endblock %}
{% block customJS %}
<script type="text/javascript" src="{% static "js/3rdparty/ol-debug.js" %}"></script>
<script type="text/javascript" src="{% url "views.settings_js" %}"></script>
<script type="text/javascript" src="{% static "js/util.js" %}"></script>
<script type="text/javascript" src="{% static "applefruitmoth/js/map.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
initMap("appleFruitMothForecastMap","{{settings.MAP_ATTRIBUTION|safe}}");
});
</script>
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
#
# 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 applefruitmoth import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
)
\ No newline at end of file
from django.shortcuts import render
# Create your views here.
from vips_messages.models import Message, MessageTag
def index(request):
vips_messages = Message.get_messages_by_tag(4) # Getting apple fruit moth messages
context = {"vips_messages": vips_messages}
return render(request, 'applefruitmoth/index.html', context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment