diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py
index ed1ef3c630ee6c39c2a503f68ac70a6a1236b30a..62faca8f5622f39ed1968173cdc0deb42cc0151b 100644
--- a/VIPSWeb/settings.py
+++ b/VIPSWeb/settings.py
@@ -137,6 +137,7 @@ INSTALLED_APPS = (
'cerealblotchmodels',
'calculators',
'roughage',
+ 'applefruitmoth',
'fusarium',
'security',
'VIPSWeb'
diff --git a/VIPSWeb/urls.py b/VIPSWeb/urls.py
index 5d4f571e35625867a6481e466d87176e854b7ad1..df85d26b345093e558a613013da5d682592a7212 100644
--- a/VIPSWeb/urls.py
+++ b/VIPSWeb/urls.py
@@ -50,6 +50,7 @@ urlpatterns = patterns('',
url(r'^roughage/', include('roughage.urls', namespace = "roughage")),
url(r'^security/', include('security.urls', namespace = "security")),
url(r'^fusarium/', include('fusarium.urls', namespace = "fusarium")),
+ url(r'^applefruitmoth/', include('applefruitmoth.urls', namespace = "applefruitmoth")),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^tinymce/', include('tinymce.urls')),
diff --git a/applefruitmoth/__init__.py b/applefruitmoth/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/applefruitmoth/admin.py b/applefruitmoth/admin.py
new file mode 100644
index 0000000000000000000000000000000000000000..8c38f3f3dad51e4585f3984282c2a4bec5349c1e
--- /dev/null
+++ b/applefruitmoth/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/applefruitmoth/locale/nb/LC_MESSAGES/django.mo b/applefruitmoth/locale/nb/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000000000000000000000000000000000..8059c528026978fb9ef90f9de92b26a52f068b24
Binary files /dev/null and b/applefruitmoth/locale/nb/LC_MESSAGES/django.mo differ
diff --git a/applefruitmoth/locale/nb/LC_MESSAGES/django.po b/applefruitmoth/locale/nb/LC_MESSAGES/django.po
new file mode 100644
index 0000000000000000000000000000000000000000..78fbdcee2ed067df7e7d41796157c36819882ab3
--- /dev/null
+++ b/applefruitmoth/locale/nb/LC_MESSAGES/django.po
@@ -0,0 +1,33 @@
+# 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"
+
diff --git a/applefruitmoth/migrations/__init__.py b/applefruitmoth/migrations/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/applefruitmoth/models.py b/applefruitmoth/models.py
new file mode 100644
index 0000000000000000000000000000000000000000..71a836239075aa6e6e4ecb700e9c42c95c022d91
--- /dev/null
+++ b/applefruitmoth/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/applefruitmoth/static/applefruitmoth/js/map.js b/applefruitmoth/static/applefruitmoth/js/map.js
new file mode 100644
index 0000000000000000000000000000000000000000..9730a1449c484ddce2754c9e7fa68417c0472533
--- /dev/null
+++ b/applefruitmoth/static/applefruitmoth/js/map.js
@@ -0,0 +1,101 @@
+/*
+ * 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
diff --git a/applefruitmoth/templates/applefruitmoth/index.html b/applefruitmoth/templates/applefruitmoth/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..b1af8b4e99d270619c84cc476a870056b5271127
--- /dev/null
+++ b/applefruitmoth/templates/applefruitmoth/index.html
@@ -0,0 +1,77 @@
+{% 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
diff --git a/applefruitmoth/tests.py b/applefruitmoth/tests.py
new file mode 100644
index 0000000000000000000000000000000000000000..7ce503c2dd97ba78597f6ff6e4393132753573f6
--- /dev/null
+++ b/applefruitmoth/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/applefruitmoth/urls.py b/applefruitmoth/urls.py
new file mode 100644
index 0000000000000000000000000000000000000000..a4afed3764a751cf2af5382b124f819f5e271c83
--- /dev/null
+++ b/applefruitmoth/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 applefruitmoth import views
+
+urlpatterns = patterns('',
+ url(r'^$', views.index, name='index'),
+)
\ No newline at end of file
diff --git a/applefruitmoth/views.py b/applefruitmoth/views.py
new file mode 100644
index 0000000000000000000000000000000000000000..2323013643a75e207d2c1e57fb531fe20c0cec46
--- /dev/null
+++ b/applefruitmoth/views.py
@@ -0,0 +1,9 @@
+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)