Skip to content
Snippets Groups Projects
local_settings.py 14.70 KiB
# -*- coding: UTF-8 -*-

#    Copyright (C) 2023 NIBIO
#
#    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/>.

## Settings for local instance of this application
## Change these for every new instance of the app
import os
# MUST be lazy, otherwise the app crashes
from django.utils.translation import gettext_lazy as _

DEBUG = False
MAINTENANCE_MODE = False
TEMPLATE_DEBUG = DEBUG

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
# Use 'python manage.py collectstatic' to put stuff into here
STATIC_ROOT = '/opt/jboss/static'

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
        "demovips.nibio.no",
        "localhost"
]

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'FooBarVIPS2000'

ADMINS = (
    ('Tor-Einar Skog', 'tor-einar.skog@nibio.no'),
)

MANAGERS = ADMINS

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'nb'

AVAILABLE_LANGUAGES = ["nb", "en"]


# Preferred language in VIPSLogic
VIPSLOGIC_LANGUAGE_CODE = "nb"

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Oslo'

# This can be used for testing purposes. Is valid locally for
# this web page, not the VIPSLogic application.
SYSTEM_TIME_OFFSET_MONTHS = 0;

# This is for testing purposes. It overrides SYSTEM_TIME_OFFSET_MONTHS
# It's valid locally for this web page, not the VIPSLogic application
# Ideally, they should be synchronized.  
# Valid values are None, "" or "%Y-%m-%d" 
# Example: SYSTEM_TIME_EXACT = "2019-06-15"
# We add this using the ${SYSTEM_TIME_EXACT_DATE} passed in from docker run


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': os.path.join(SITE_ROOT, 'default.sqlite3'),  # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

# Caching with memcached
#CACHES = {
#    'default': {
#        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
####        'LOCATION': 'unix:/tmp/memcached.sock',
#        'LOCATION': '127.0.0.1:11211',
#    }
#}


# Convenience method for building URL to self
VIPSWEB_PROTOCOL = "http"
# The server name used for VIPSLogic
VIPSLOGIC_SERVER_NAME = "localhost:8080/VIPSLogic"
# VIPSLogic protocol
VIPSLOGIC_PROTOCOL = "http"
# This organization's ID in VIPSLogic/CoreManager
VIPS_ORGANIZATION_ID = 1
INCLUDE_ORGANIZATION_IDS =[1]
# The server name used for VIPSCoreManager
VIPSCOREMANAGER_SERVER_NAME = "localhost:8080/VIPSCore"
# Local path to self signed certificate of VIPSCoreManager.
# Set to none if using certificate signed by a CA
#VIPSCOREMANAGER_SSLCERT_PATH ="/home/django-vipsweb/coremanager.crt"
VIPSCOREMANAGER_SSLCERT_PATH = None
# Date format for dates from VIPSLogic
VIPSLOGIC_DATE_FORMAT = "%Y-%m-%d"

# Site name - appears in header of all pages
SITE_NAME = "Varsling Innen <br/>PlanteSkadegjørere [DEMOVIPS]"

# Insert Web Analytics Script?
INSERT_WEB_ANALYTICS = False
WEB_ANALYTICS_SCRIPT = """
<script defer data-domain="vips-landbruk.no" src="https://www.vips-landbruk.no/js/script.js"></script>
"""


# Site owner info
SITE_OWNER_NAME = {
                   "nb": "NIBIO - Norsk institutt for bioøkonomi",
                   "en":"NIBIO - Norwegian Institute of Bioeconomy Research"
                   }
SITE_OWNER_URL = "https://www.nibio.no/"

# Risk maps settings
WMS_SERVER_URL = "https://gridweb.vips.nibio.no/cgi-bin/"
AVAILABLE_GRID_MODELS = [
      {"model_id":"PSILARTEMP", "model_name": {"nb":"Gulrotflue svermetidspunktmodell", "en":"Carrot rust fly (Psila rosae) temperature model"}, "url": "%sPSILARTEMP_DEMO" % WMS_SERVER_URL},
      {"model_id":"NAERSTADMO", "model_name": {"nb":"Nærstads modell", "en":"Nærstad's potato late blight model"}, "url": "%sNAERSTADMO_DEMO" % WMS_SERVER_URL}
      ]


# OpenLayers Map initial configuration
# Longitude and latitude in WGS84 format
# See http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS_84
MAP_CENTER_LONGITUDE = 17
MAP_CENTER_LATITUDE = 65.0
# The zoom level (1-15, 1 is world wide view, 15 is greatest zoom)
MAP_ZOOMLEVEL = 5
# The height of the map in pixels on the screen
MAP_HEIGHT = 680
# The attribution text that appears in a corner of the map
MAP_ATTRIBUTION = "&copy; <a href='http://www.openstreetmap.org'>OpenStreetMap</a> contributors"
# Based on your country/region map, you may want to place the legend
# where it stays out of the way of your weather stations
# 1 = top left, 2 = top right, 3 = bottom left, 4 = bottom right
MAP_WARNING_LEGEND_PLACEMENT = 4

# The message tags to use on the front page
FRONTPAGE_MESSAGE_TAG_IDS = [2,3]

# For setting up groups of crops with forecasts
# Sample: {"crop_group_id": 1, "name":{"en":"Fruit", "nb":"Frukt"},"crop_ids":[23,44,53]}
CROP_GROUPS=[
    {"crop_group_id": 1, "name":{"en":"Fruit", "nb":"Frukt"},"crop_ids":[3]},
    {"crop_group_id": 2, "name":{"en":"Potato", "nb":"Potet"},"crop_ids":[5]},
    {"crop_group_id": 3, "name":{"en":"Cabbage","nb":"K&aring;l"},"crop_ids":[16]},
    {"crop_group_id": 4, "name":{"en":"Onions","nb":"L&oslash;k"},"crop_ids":[99]}
]

MAIN_MENU=[
    {"url":"/forecasts", "label": "Forecasts"},
    {
        "label": _("Risk maps"),
        "child_items": [
            {
                "url": "/spatial",
                "label": _("About risk maps"),
            },
            {
                "url": "/spatial/gridmap/NAERSTADMO/",
                "label": _("Naerstad Late Blight Model"),
            },
            {
                "url": "/spatial/gridmap/PSILARTEMP/",
                "label": _("Carrot rust fly temperature model"),
            }
        ],
    },
    {"url":"/observations","label":"Observations"},
    {"url":"/messages", "label": "Messages"}
]

# 12 % Number of columns must be 0 (12 needs to be divisible by number of columns)
FRONTPAGE_MENU=[
    {
         "label": _("Cereals and oilseeds"),
         "items":[
                     {"url":"http://vipsugras.ipmwise.com/", "label": "VIPS Ugras"},
                     {"url":"/forecasts/models/LEAFBLOTCH/","label":"Bladflekker i v&aring;rhvete - risikomodell"},
                     {"url":"/blotch/septoriahumidity","label":"Bladflekker i korn - fuktmodell"},
                     {"url":"/blotch/barleynetblotch/", "label": "Byggbrunflekk - Elens modell"},
                     {"url":"/forecasts/models/FINNCEREAL/","label":"Byggbrunflekk - FinBladflekkmodellen"},
                     {"url":"/fusarium/","label": "Blomstringsmodell i havre"},
                     {"url":"/information/12/#rapsglansbille","label":"Skadedyr i korn og oljevekster"},
                     {"url":"/information/33/","label":"DON (mykotoksin) i havre - risiko"},
                     {"url":"https://www.vips-landbruk.no/messages/244/", "label": u"<span class='inverseSign'>UTG&Aring;TT</span> <em>Bladflekksjukdommer i v&aring;rhvete</em>"},
                     {"url":"https://www.vips-landbruk.no/messages/244/", "label": u"<span class='inverseSign'>UTG&Aring;TT</span> <em>Bladflekksjukdommer i h&oslash;sthvete</em>"},
                     {"url":"https://www.vips-landbruk.no/messages/244/", "label": u"<span class='inverseSign'>UTG&Aring;TT</span> <em>Storknolla r&aring;tesopp</em>"},
         ]
     },
     {
         "label": _("Potato and vegetables"),
         "items":[
                     {"url":"https://agro.au.dk/forskning/internationale-platforme/euroblight/late-blight-survey-mapper", "label": u"EuroBlight: Tidlige funn av t&oslash;rr&aring;te"},
                     {"url":"/observations/?from=2023-01-01&to=2023-12-31&pestId=14&cropId=5&cropCategoryId=2&includeNegative=true", "label":u"Tidlige t&oslash;rr&aring;tefunn i Norge"},
             {"url":"/information/12/#potetsikade","label":"Potetsikade"},
         ]
     },
     {
         "label": _("Fruits and berries"),
         "items":[
             {"url":"/information/12/#RimproEpleskurv", "label": "RIMPro (epleskurv, eplevikler)"},
             {"url":"/cydiapomonella", "label": "Eplevikler"},
                {"url":"/applefruitmoth/", "label": u"Rogneb&aelig;rm&oslash;ll"},
              {"url":"http://das.smartcampo.com", "label": u"Strawberry Advisory System (gr&aring;skimmel)"},
         ]
     },
     {
         "label": _("Other models and services"),
         "items":[
                {"url":"https://lmtweb02.nibio.no/vatning/index.php?valgt_stasjon=5&type=360", "label":"Vanning"},
              {"url":"https://lmt.nibio.no/irrigation/", "label":"Beregning av vanningsbalanse"},
                {"url":"https://lmt.nibio.no/information/6/", "label":"Varmesum og nedb&oslash;rsmengde"},
                {"url":"https://lmt.nibio.no/agrometbase/ncalc","label":"Kalkulator for opptak og utvasking av nitrogen"},
              {"url":"https://lmt.nibio.no/husdyrn/","label":"Nitrogenkalkulator for husdyrgj&oslash;dsel"},
                        {"url":"/roughage/nutrition/", "label": u"Grovf&ocirc;rmodellen"},
                        {"url":"/information/30/", "label": u"Spr&oslash;yteteknikk"},
             {"url":"https://www.nibio.no/tema/plantehelse/integrert-plantevern", "label":"Informasjon om integrert plantevern"},
                {"url":"https://lmt.nibio.no/", "label":"LandbruksMeteorologisk Tjeneste (LMT)"},
                        {"url":"https://www.plantevernguiden.no/", "label": u"Plantevernguiden"},
                        {"url":"https://leksikon.nibio.no/", "label": u"Plantevernleksikonet"},
                        {"url":"https://www.nibio.no/tjenester/synops-web-norge", "label": u"SYNOPS WEB Norge"},
                        {"url":"/mobil", "label": u"VIPS Mobil"}
         ]
     }
 ]


# Text and formatting (HTML) for the footer to be
# shown on all web pages. Language code must be specified
# Language selection is as follows:
# 1. The user's selected language
# 2. The default language for the site
# 3. English
# 4. The first language in the list of texts
# Example:
# FOOTER HTML = {
#        "en": "VIPS is an automatic forecasting system for agricultural pests and diseases",
#        "nb": "VIPS er et automatisk varslingssystem for skadegjørere i landbruket"
# }
FOOTER_HTML_1= {
        "nb":
        """<p>VIPS (Varsling Innen PlanteSkadegjørere) er utviklet av <a href="http://www.nibio.no/" target="new">NIBIO</a>
        og <a href="http://www.lr.no/" target="new">Norsk Landbruksrådgiving</a>. Rådgivningstjenesten
        registrerer angrep av skadegjørere i felt, mens NIBIO leverer klimadata og tar seg av utvikling, drift og
        vedlikehold av systemet. <a href="http://met.no/" target="new">Meteorologisk institutt</a> leverer værprognoser som brukes i varslingsmodellene.
        <em>Samarbeidspartnerne har ikke &oslash;konomisk ansvar for tap som m&aring;tte oppst&aring; ved bruk av tjenesten.</em></p>
        <p>
        I 2022 omfatter tjenesten beregning av behandlingsbehov mot ugras i vårkorn og høstkorn,
        varsling av bladflekksjukdommer i hvete, byggbrunflekk, storknolla råtesopp
        i oljevekster, tørråte i potet, salatbladskimmel,
        løkbladskimmel, selleribladflekk, stor og liten kålflue, kålfly, håret engtege, gulrotflue,
        epleskurv, eplevikler og rognebærmøll og gråskimmel i jordbær, og beregning av blomstringstid i havre.
        VIPS inneholder skadeterskler for vurdering av
        bekjempingsbehov mot potetsikade i potet, bladlus i korn og rapsglansbille i oljevekster.
        Tjenesten omfatter også meldinger om overvåking av skadegjørere, fagmeldinger og driftsmeldinger.
        </p>""",
        "en":
        """<p>VIPS is an automatic forecasting system for agricultural pests and diseases, developed by
        <a href="http://www.nibio.no/" target="new">NIBIO</a> (the Norwegian Institute of Bioeconomy Research)
        and <a href="http://www.lr.no/" target="new">Norsk landbruksrådgivning</a>
        (The Norwegian agricultural extension service). <em>The cooperating partners have no economic
        responsibility whatsoever for losses due to using this service</em></p>

        """
}

FOOTER_HTML_2= {
        "nb":
        """
        <p><a href="http://www.nibio.no/" target="new"><img src="/static/images/logo_nibio.svg" style="width: 77px;"/></a></p>
	<p><a href="http://www.nlr.no/" target="new"><img src="/static/images/logo_NLR.gif" style="width: 150px;"/></a></p>
        <p>VIPS-prosjektleder: <a href="http://www.nibio.no/ansatte/berit-nordskog" target="new">Berit Nordskog</a></p>
        <p>Kontakt: vips[at]nibio.no</p>

        """,
        "en":
        """
	<p><a href="http://www.nibio.no/" target="new"><img src="/static/images/logo_nibio.svg" style="width: 77px;"/></a></p>
        <p><a href="http://www.nlr.no/" target="new"><img src="/static/images/logo_NLR.gif" style="width: 150px;"/></a></p>
        <p>VIPS project leader: <a href="http://www.nibio.no/en/employees/berit-nordskog" target="new">Berit Nordskog</a></p>
        <p>Contact: vips[at]nibio.no</p>
        """
}

# If set to True, the link to VIPS Mobile (per now a Norwegian only web app)
# will be visible on small screens (like smart phones).
SHOW_VIPS_MOBILE_LINK_ON_SMALL_SCREENS = True

# Settings for the JQueryUI date picker used as a replacement for
# browser's built in date picker when input type="date"
# See JQuery UI docs: https://api.jqueryui.com/datepicker/
DATE_PICKER_CONFIG = { "dateFormat": 'yy-mm-dd', "firstDay": 1, "changeYear": "true", "changeMonth": "true" }