diff --git a/konova/admin.py b/konova/admin.py
new file mode 100644
index 00000000..a5c81175
--- /dev/null
+++ b/konova/admin.py
@@ -0,0 +1,21 @@
+"""
+Author: Michel Peltriaux
+Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
+Contact: michel.peltriaux@sgdnord.rlp.de
+Created on: 05.07.21
+
+"""
+from django.contrib import admin
+
+from konova.models import ServerMessage
+
+
+class ServerMessageAdmin(admin.ModelAdmin):
+ list_display = [
+ "id",
+ "subject",
+ "publish_on",
+ "is_active",
+ ]
+
+admin.site.register(ServerMessage, ServerMessageAdmin)
diff --git a/konova/enums.py b/konova/enums.py
index 8cb545c6..cabb9788 100644
--- a/konova/enums.py
+++ b/konova/enums.py
@@ -37,4 +37,13 @@ class UnitEnum(BaseEnum):
qkm = "qkm"
ha = "ha"
- st = "St." # pieces
\ No newline at end of file
+ st = "St." # pieces
+
+
+class ServerMessageImportance(BaseEnum):
+ """
+ Defines importance levels for server messages
+ """
+ DEFAULT = "DEFAULT"
+ INFO = "INFO"
+ WARNING = "WARNING"
diff --git a/konova/models.py b/konova/models.py
index c7348cbc..bb7eebb2 100644
--- a/konova/models.py
+++ b/konova/models.py
@@ -11,6 +11,8 @@ from django.contrib.auth.models import User
from django.contrib.gis.db.models import MultiPolygonField
from django.db import models
+from konova.enums import ServerMessageImportance
+
class BaseResource(models.Model):
"""
@@ -69,3 +71,14 @@ class Geometry(BaseResource):
"""
geom = MultiPolygonField(null=True, blank=True)
+
+class ServerMessage(BaseResource):
+ """
+ Holds messages, which can be displayed on the user's dashboard
+ """
+ subject = models.CharField(max_length=500, null=False, blank=False)
+ body = models.TextField()
+ is_active = models.BooleanField(default=True)
+ publish_on = models.DateTimeField()
+ unpublish_on = models.DateTimeField()
+ importance = models.CharField(max_length=100, choices=ServerMessageImportance.as_choices(drop_empty_choice=True))
diff --git a/konova/settings.py b/konova/settings.py
index a25f0cd7..5f47f5b8 100644
--- a/konova/settings.py
+++ b/konova/settings.py
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from django.utils.translation import gettext_lazy as _
# Load other settings
+from konova.enums import ServerMessageImportance
from konova.sub_settings.django_settings import *
# Num of days if user enables Remember-me on login
@@ -54,3 +55,10 @@ DEFAULT_ZOOM = 8.0
DEFAULT_GROUP = _("Default")
ZB_GROUP = _("Registration office")
ETS_GROUP = _("Conservation office")
+
+# ServerMessageImportance bootstrap resolver
+SVI_BOOTSTRAP_CLS_MAP = {
+ ServerMessageImportance.DEFAULT.value: None,
+ ServerMessageImportance.WARNING.value: "alert-danger",
+ ServerMessageImportance.INFO.value: "alert-info",
+}
diff --git a/konova/static/css/konova.css b/konova/static/css/konova.css
index 95f35ccb..341d5e22 100644
--- a/konova/static/css/konova.css
+++ b/konova/static/css/konova.css
@@ -18,6 +18,10 @@ body{
margin-bottom: 40px; /* Margin bottom by footer height */
}
+.body-content{
+ margin: 1rem 0rem 0 0rem;
+}
+
.footer {
position: absolute;
bottom: 0;
@@ -63,4 +67,18 @@ nav{
Overwrites bootstrap default nav-link colouring
*/
color: white;
+}
+
+.card{
+ margin: 0 0.5rem 0.5rem 0;
+ font-size: 12px;
+}
+.card:hover{
+ box-shadow: 1px 1px 3px var(--rlp-gray-light);
+}
+
+.card .card-text{
+ font-size: 12px;
+ max-height: 150px;
+ overflow: auto;
}
\ No newline at end of file
diff --git a/konova/templates/konova/home.html b/konova/templates/konova/home.html
index ae7704ac..87b2554a 100644
--- a/konova/templates/konova/home.html
+++ b/konova/templates/konova/home.html
@@ -1,44 +1,38 @@
{% extends 'base.html' %}
-{% load i18n %}
+{% load i18n ksp_filters %}
-{% block body_middle %}
-
Kompensationsverzeichnis
- Service Portal
-
-{% if user.is_anonymous %}
-
-
-
-{% else %}
-
- {% trans 'Logged in as' %} {{ user.username }}
-
- {% trans 'Last login on' %} {{ user.last_login }}
-
-
-
-{% endif %}
+
+
+
+
+
+
+
+
{% trans 'Quickstart' %}
+
+
{% trans 'Intervention' %}
+
{% trans 'Compensation' %}
+
{% trans 'Eco-account' %}
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/konova/templatetags/__init__.py b/konova/templatetags/__init__.py
new file mode 100644
index 00000000..e6632d6a
--- /dev/null
+++ b/konova/templatetags/__init__.py
@@ -0,0 +1,7 @@
+"""
+Author: Michel Peltriaux
+Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
+Contact: michel.peltriaux@sgdnord.rlp.de
+Created on: 05.07.21
+
+"""
diff --git a/konova/templatetags/ksp_filters.py b/konova/templatetags/ksp_filters.py
new file mode 100644
index 00000000..6ee3dd34
--- /dev/null
+++ b/konova/templatetags/ksp_filters.py
@@ -0,0 +1,28 @@
+"""
+Author: Michel Peltriaux
+Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
+Contact: michel.peltriaux@sgdnord.rlp.de
+Created on: 05.07.21
+
+"""
+from django import template
+from konova.settings import SVI_BOOTSTRAP_CLS_MAP
+
+# Create custom library
+register = template.Library()
+
+
+@register.filter("bootstrap_cls")
+def bootstrap_cls(value):
+ """ Returns a bootstrap html class name
+
+ Resolves ServerMessageImportance enum into a html class name
+
+ Args:
+ value ():
+ arg ():
+
+ Returns:
+
+ """
+ return SVI_BOOTSTRAP_CLS_MAP.get(value, "")
diff --git a/konova/views.py b/konova/views.py
index 09030525..daaa447a 100644
--- a/konova/views.py
+++ b/konova/views.py
@@ -9,8 +9,10 @@ from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
from django.http import HttpRequest
from django.shortcuts import redirect, render
+from django.utils import timezone
from konova.contexts import BaseContext
+from konova.models import ServerMessage
from konova.settings import SSO_SERVER_BASE
@@ -40,7 +42,18 @@ def home_view(request: HttpRequest):
A redirect
"""
template = "konova/home.html"
+ now = timezone.now()
+ # Fetch the four newest active and published ServerMessages
+ msgs = ServerMessage.objects.filter(
+ is_active=True,
+ publish_on__lte=now,
+ unpublish_on__gte=now,
+ ).order_by(
+ "-publish_on"
+ )[:4]
- additional_context = {}
+ additional_context = {
+ "msgs": msgs,
+ }
context = BaseContext(request, additional_context).context
return render(request, template, context)
diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo
index 4ed51b01..847f6c43 100644
Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ
diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po
index 9a1f6521..2ee96d0b 100644
--- a/locale/de/LC_MESSAGES/django.po
+++ b/locale/de/LC_MESSAGES/django.po
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-07-02 12:56+0200\n"
+"POT-Creation-Date: 2021-07-05 14:48+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -43,7 +43,8 @@ msgstr "Aktionen"
msgid "Compensations"
msgstr "Kompensationen"
-#: compensation/tables.py:48 compensation/tables.py:98 templates/navbar.html:22
+#: compensation/tables.py:48 compensation/tables.py:98
+#: konova/templates/konova/home.html:33 templates/navbar.html:26
msgid "Compensation"
msgstr "Kompensation"
@@ -139,7 +140,8 @@ msgid "Interventions"
msgstr "Eingriffe"
#: intervention/tables.py:57 intervention/tables.py:68
-#: intervention/templates/intervention/open.html:8 templates/navbar.html:16
+#: intervention/templates/intervention/open.html:8
+#: konova/templates/konova/home.html:32 templates/navbar.html:20
msgid "Intervention"
msgstr "Eingriff"
@@ -183,29 +185,49 @@ msgstr "Entferne"
msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen"
-#: konova/settings.py:54
+#: konova/settings.py:55
msgid "Default"
msgstr ""
-#: konova/settings.py:55
+#: konova/settings.py:56
msgid "Registration office"
msgstr "Zulassungsbehörde"
-#: konova/settings.py:56
+#: konova/settings.py:57
msgid "Conservation office"
msgstr "Naturschutzbehörde"
-#: konova/templates/konova/home.html:11
-msgid "Proceed with login"
-msgstr "Mit Login fortfahren"
+#: konova/templates/konova/home.html:6
+msgid "News"
+msgstr ""
-#: konova/templates/konova/home.html:16
-msgid "Logged in as"
-msgstr "Eingeloggt als"
+#: konova/templates/konova/home.html:12
+msgid "Published on"
+msgstr "Veröffentlicht am"
-#: konova/templates/konova/home.html:18
-msgid "Last login on"
-msgstr "Zuletzt eingeloggt am"
+#: konova/templates/konova/home.html:20
+msgid "Older ..."
+msgstr "Ältere ..."
+
+#: konova/templates/konova/home.html:30
+msgid "Quickstart"
+msgstr "Schnellstart"
+
+#: konova/templates/konova/home.html:34 templates/navbar.html:32
+msgid "Eco-account"
+msgstr "Ökokonto"
+
+#: templates/footer.html:6
+msgid "Help"
+msgstr "Hilfe"
+
+#: templates/footer.html:9
+msgid "Impressum"
+msgstr ""
+
+#: templates/footer.html:12
+msgid "Contact"
+msgstr ""
#: templates/generic_table_form.html:37
msgid "Fields with * are required."
@@ -227,35 +249,35 @@ msgstr ""
msgid "KSP"
msgstr ""
-#: templates/navbar.html:10
+#: templates/navbar.html:14
msgid "Home"
msgstr "Home"
-#: templates/navbar.html:28
-msgid "Eco-account"
-msgstr "Ökokonto"
-
-#: templates/navbar.html:34
+#: templates/navbar.html:38
msgid "More"
msgstr "Mehr"
-#: templates/navbar.html:37
+#: templates/navbar.html:41
msgid "EMA"
msgstr ""
-#: templates/navbar.html:38
+#: templates/navbar.html:42
msgid "Import..."
msgstr ""
-#: templates/navbar.html:39
+#: templates/navbar.html:43
msgid "Export..."
msgstr ""
-#: templates/navbar.html:40
+#: templates/navbar.html:44
msgid "Reports"
msgstr "Berichte"
-#: templates/navbar.html:51
+#: templates/navbar.html:56
+msgid "Settings"
+msgstr "Einstellungen"
+
+#: templates/navbar.html:57
msgid "Logout"
msgstr "Abmelden"
@@ -1466,6 +1488,15 @@ msgstr ""
msgid "A fontawesome icon field"
msgstr ""
+#~ msgid "Proceed with login"
+#~ msgstr "Mit Login fortfahren"
+
+#~ msgid "Logged in as"
+#~ msgstr "Eingeloggt als"
+
+#~ msgid "Last login on"
+#~ msgstr "Zuletzt eingeloggt am"
+
#~ msgid "Add new intervention"
#~ msgstr "Neuen Eingriff hinzufügen"
@@ -1559,12 +1590,6 @@ msgstr ""
#~ msgid "Annual report"
#~ msgstr "Jahresbericht"
-#~ msgid "Settings"
-#~ msgstr "Einstellungen"
-
-#~ msgid "Help"
-#~ msgstr "Hilfe"
-
#~ msgid "User"
#~ msgstr "Nutzer"
diff --git a/templates/base.html b/templates/base.html
index 8eadff81..38506216 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -18,8 +18,10 @@
{% include 'navbar.html' %}
{% endblock %}
-
+
+ {% block body %}
+ {% endblock %}
{% block footer %}