Landing page
* started to implement a landing page * started news implementation
This commit is contained in:
parent
b59b9839ff
commit
f069baa260
21
konova/admin.py
Normal file
21
konova/admin.py
Normal file
@ -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)
|
@ -38,3 +38,12 @@ class UnitEnum(BaseEnum):
|
|||||||
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;
|
||||||
@ -64,3 +68,17 @@ nav{
|
|||||||
*/
|
*/
|
||||||
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_middle %}
|
{% block body %}
|
||||||
<h1>Kompensationsverzeichnis</h1>
|
<div id="server-messages" class="row px-3">
|
||||||
<h2>Service Portal</h2>
|
<h4 class="row">{% trans 'News' %}</h4>
|
||||||
<hr>
|
<div class="row px-3">
|
||||||
{% if user.is_anonymous %}
|
{% for msg in msgs %}
|
||||||
<a href="{% url 'simple-sso-login' %}">
|
<div class="card col-md {{msg.importance|bootstrap_cls}}">
|
||||||
<button class="button middle">
|
<div class="card-body">
|
||||||
{% trans 'Proceed with login' %}
|
<h6 class="card-title">{{msg.subject}}</h6>
|
||||||
</button>
|
<small>{% trans 'Published on' %} {{msg.publish_on}}</small>
|
||||||
</a>
|
<article class="card-text">{{msg.body|safe}}</article>
|
||||||
{% else %}
|
</div>
|
||||||
<article>
|
</div>
|
||||||
{% trans 'Logged in as' %} <strong>{{ user.username }}</strong>
|
|
||||||
<br>
|
|
||||||
{% trans 'Last login on' %} {{ user.last_login }}
|
|
||||||
</article>
|
|
||||||
|
|
||||||
<form action="{{form.action_url}}" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<table>
|
|
||||||
{% comment %}
|
|
||||||
This is an alternative to using the <article></article>
|
|
||||||
<tr>
|
|
||||||
<td>{% trans 'Logged in as' %}</td>
|
|
||||||
<td><strong>{{ user.username }}</strong></td>
|
|
||||||
</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 %}
|
{% endfor %}
|
||||||
</table>
|
<div class="card col-md {{msg.importance|bootstrap_cls}} align-items-center justify-content-center">
|
||||||
</form>
|
<a class="w-100 h-100 align-middle text-center" href="{% url 'home' %}">
|
||||||
{% endif %}
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">{% trans 'Older ...' %}</h5>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div id="quickstart" class="col-md px-3">
|
||||||
|
<h4 class="row">{% trans 'Quickstart' %}</h4>
|
||||||
|
<div class="row px-3">
|
||||||
|
<div class="col-md">{% trans 'Intervention' %}</div>
|
||||||
|
<div class="col-md">{% trans 'Compensation' %}</div>
|
||||||
|
<div class="col-md">{% trans 'Eco-account' %}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
7
konova/templatetags/__init__.py
Normal file
7
konova/templatetags/__init__.py
Normal file
@ -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
|
||||||
|
|
||||||
|
"""
|
28
konova/templatetags/ksp_filters.py
Normal file
28
konova/templatetags/ksp_filters.py
Normal file
@ -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()
|
||||||
|
# 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
|
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:16
|
#: konova/templates/konova/home.html:12
|
||||||
msgid "Logged in as"
|
msgid "Published on"
|
||||||
msgstr "Eingeloggt als"
|
msgstr "Veröffentlicht am"
|
||||||
|
|
||||||
#: konova/templates/konova/home.html:18
|
#: konova/templates/konova/home.html:20
|
||||||
msgid "Last login on"
|
msgid "Older ..."
|
||||||
msgstr "Zuletzt eingeloggt am"
|
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
|
#: 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…
Reference in New Issue
Block a user