Landing page

* started to implement a landing page
* started news implementation
pull/2/head
mipel 3 years ago
parent f654826003
commit 7968d7d355

@ -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)

@ -37,4 +37,13 @@ class UnitEnum(BaseEnum):
qkm = "qkm" qkm = "qkm"
ha = "ha" ha = "ha"
st = "St." # pieces st = "St." # pieces
class ServerMessageImportance(BaseEnum):
"""
Defines importance levels for server messages
"""
DEFAULT = "DEFAULT"
INFO = "INFO"
WARNING = "WARNING"

@ -11,6 +11,8 @@ from django.contrib.auth.models import User
from django.contrib.gis.db.models import MultiPolygonField from django.contrib.gis.db.models import MultiPolygonField
from django.db import models from django.db import models
from konova.enums import ServerMessageImportance
class BaseResource(models.Model): class BaseResource(models.Model):
""" """
@ -69,3 +71,14 @@ class Geometry(BaseResource):
""" """
geom = MultiPolygonField(null=True, blank=True) 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))

@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
# Load other settings # Load other settings
from konova.enums import ServerMessageImportance
from konova.sub_settings.django_settings import * from konova.sub_settings.django_settings import *
# Num of days if user enables Remember-me on login # Num of days if user enables Remember-me on login
@ -54,3 +55,10 @@ DEFAULT_ZOOM = 8.0
DEFAULT_GROUP = _("Default") DEFAULT_GROUP = _("Default")
ZB_GROUP = _("Registration office") ZB_GROUP = _("Registration office")
ETS_GROUP = _("Conservation 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",
}

@ -18,6 +18,10 @@ body{
margin-bottom: 40px; /* Margin bottom by footer height */ margin-bottom: 40px; /* Margin bottom by footer height */
} }
.body-content{
margin: 1rem 0rem 0 0rem;
}
.footer { .footer {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@ -63,4 +67,18 @@ nav{
Overwrites bootstrap default nav-link colouring Overwrites bootstrap default nav-link colouring
*/ */
color: white; 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;
} }

@ -1,44 +1,38 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n %} {% load i18n ksp_filters %}
{% block body %}
<div id="server-messages" class="row px-3">
<h4 class="row">{% trans 'News' %}</h4>
<div class="row px-3">
{% for msg in msgs %}
<div class="card col-md {{msg.importance|bootstrap_cls}}">
<div class="card-body">
<h6 class="card-title">{{msg.subject}}</h6>
<small>{% trans 'Published on' %} {{msg.publish_on}}</small>
<article class="card-text">{{msg.body|safe}}</article>
</div>
</div>
{% endfor %}
<div class="card col-md {{msg.importance|bootstrap_cls}} align-items-center justify-content-center">
<a class="w-100 h-100 align-middle text-center" href="{% url 'home' %}">
<div class="card-body">
<h5 class="card-title">{% trans 'Older ...' %}</h5>
</div>
</a>
</div>
</div>
</div>
{% block body_middle %}
<h1>Kompensationsverzeichnis</h1>
<h2>Service Portal</h2>
<hr> <hr>
{% if user.is_anonymous %}
<a href="{% url 'simple-sso-login' %}">
<button class="button middle">
{% trans 'Proceed with login' %}
</button>
</a>
{% else %}
<article>
{% trans 'Logged in as' %} <strong>{{ user.username }}</strong>
<br>
{% trans 'Last login on' %} {{ user.last_login }}
</article>
<form action="{{form.action_url}}" method="post"> <div id="quickstart" class="col-md px-3">
{% csrf_token %} <h4 class="row">{% trans 'Quickstart' %}</h4>
<table> <div class="row px-3">
{% comment %} <div class="col-md">{% trans 'Intervention' %}</div>
This is an alternative to using the <article></article> <div class="col-md">{% trans 'Compensation' %}</div>
<tr> <div class="col-md">{% trans 'Eco-account' %}</div>
<td>{% trans 'Logged in as' %}</td> </div>
<td><strong>{{ user.username }}</strong></td> </div>
</tr>
<tr>
<td>{% trans 'Last login on' %}</td>
<td><strong>{{ user.last_login }}</strong></td>
</tr>
{% endcomment %}
{% for field in form %}
<tr>
<td>{{ field.label }}</td>
<td>{{ field }}</td>
</tr>
{% endfor %}
</table>
</form>
{% endif %}
{% endblock %} {% endblock %}

@ -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
"""

@ -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, "")

@ -9,8 +9,10 @@ from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpRequest from django.http import HttpRequest
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.utils import timezone
from konova.contexts import BaseContext from konova.contexts import BaseContext
from konova.models import ServerMessage
from konova.settings import SSO_SERVER_BASE from konova.settings import SSO_SERVER_BASE
@ -40,7 +42,18 @@ def home_view(request: HttpRequest):
A redirect A redirect
""" """
template = "konova/home.html" template = "konova/home.html"
now = timezone.now()
additional_context = {} # 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 = {
"msgs": msgs,
}
context = BaseContext(request, additional_context).context context = BaseContext(request, additional_context).context
return render(request, template, context) return render(request, template, context)

Binary file not shown.

@ -9,7 +9,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -43,7 +43,8 @@ msgstr "Aktionen"
msgid "Compensations" msgid "Compensations"
msgstr "Kompensationen" 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" msgid "Compensation"
msgstr "Kompensation" msgstr "Kompensation"
@ -139,7 +140,8 @@ msgid "Interventions"
msgstr "Eingriffe" msgstr "Eingriffe"
#: intervention/tables.py:57 intervention/tables.py:68 #: 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" msgid "Intervention"
msgstr "Eingriff" msgstr "Eingriff"
@ -183,29 +185,49 @@ msgstr "Entferne"
msgid "You are about to remove {} {}" msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen" msgstr "Sie sind dabei {} {} zu löschen"
#: konova/settings.py:54 #: konova/settings.py:55
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: konova/settings.py:55 #: konova/settings.py:56
msgid "Registration office" msgid "Registration office"
msgstr "Zulassungsbehörde" msgstr "Zulassungsbehörde"
#: konova/settings.py:56 #: konova/settings.py:57
msgid "Conservation office" msgid "Conservation office"
msgstr "Naturschutzbehörde" msgstr "Naturschutzbehörde"
#: konova/templates/konova/home.html:11 #: konova/templates/konova/home.html:6
msgid "Proceed with login" msgid "News"
msgstr "Mit Login fortfahren" msgstr ""
#: konova/templates/konova/home.html:12
msgid "Published on"
msgstr "Veröffentlicht am"
#: konova/templates/konova/home.html:16 #: konova/templates/konova/home.html:20
msgid "Logged in as" msgid "Older ..."
msgstr "Eingeloggt als" msgstr "Ältere ..."
#: konova/templates/konova/home.html:18 #: konova/templates/konova/home.html:30
msgid "Last login on" msgid "Quickstart"
msgstr "Zuletzt eingeloggt am" 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 #: templates/generic_table_form.html:37
msgid "Fields with * are required." msgid "Fields with * are required."
@ -227,35 +249,35 @@ msgstr ""
msgid "KSP" msgid "KSP"
msgstr "" msgstr ""
#: templates/navbar.html:10 #: templates/navbar.html:14
msgid "Home" msgid "Home"
msgstr "Home" msgstr "Home"
#: templates/navbar.html:28 #: templates/navbar.html:38
msgid "Eco-account"
msgstr "Ökokonto"
#: templates/navbar.html:34
msgid "More" msgid "More"
msgstr "Mehr" msgstr "Mehr"
#: templates/navbar.html:37 #: templates/navbar.html:41
msgid "EMA" msgid "EMA"
msgstr "" msgstr ""
#: templates/navbar.html:38 #: templates/navbar.html:42
msgid "Import..." msgid "Import..."
msgstr "" msgstr ""
#: templates/navbar.html:39 #: templates/navbar.html:43
msgid "Export..." msgid "Export..."
msgstr "" msgstr ""
#: templates/navbar.html:40 #: templates/navbar.html:44
msgid "Reports" msgid "Reports"
msgstr "Berichte" msgstr "Berichte"
#: templates/navbar.html:51 #: templates/navbar.html:56
msgid "Settings"
msgstr "Einstellungen"
#: templates/navbar.html:57
msgid "Logout" msgid "Logout"
msgstr "Abmelden" msgstr "Abmelden"
@ -1466,6 +1488,15 @@ msgstr ""
msgid "A fontawesome icon field" msgid "A fontawesome icon field"
msgstr "" 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" #~ msgid "Add new intervention"
#~ msgstr "Neuen Eingriff hinzufügen" #~ msgstr "Neuen Eingriff hinzufügen"
@ -1559,12 +1590,6 @@ msgstr ""
#~ msgid "Annual report" #~ msgid "Annual report"
#~ msgstr "Jahresbericht" #~ msgstr "Jahresbericht"
#~ msgid "Settings"
#~ msgstr "Einstellungen"
#~ msgid "Help"
#~ msgstr "Hilfe"
#~ msgid "User" #~ msgid "User"
#~ msgstr "Nutzer" #~ msgstr "Nutzer"

@ -18,8 +18,10 @@
{% include 'navbar.html' %} {% include 'navbar.html' %}
{% endblock %} {% endblock %}
</header> </header>
<div class="container-fluid"> <div class="container-fluid mt-3 px-5">
{% block body %}
{% endblock %}
</div> </div>
{% block footer %} {% block footer %}

Loading…
Cancel
Save