diff --git a/aleksis/core/models.py b/aleksis/core/models.py index 8995d6d578095fe60713fe1aa2a0a5bb2caaed64..40b0b53339b90311fa8f7aaaa459e91b7db0cdb4 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -31,6 +31,10 @@ class School(ExtensibleModel): logo = ImageCropField(verbose_name=_("School logo"), blank=True, null=True) logo_cropping = ImageRatioField("logo", "600x600", size_warning=True) + @classmethod + def get_default(cls): + return cls.objects.first() + @property def current_term(self): return SchoolTerm.objects.get(current=True) diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py index c314e3a7305a2c1655de57df9d4ac05220b4238a..0a4bd992518fb89281f36b756bd330c0b57956ea 100644 --- a/aleksis/core/settings.py +++ b/aleksis/core/settings.py @@ -130,6 +130,7 @@ TEMPLATES = [ "maintenance_mode.context_processors.maintenance_mode", "settings_context_processor.context_processors.settings", "constance.context_processors.config", + "aleksis.core.util.core_helpers.school_information_processor", ], }, }, @@ -248,6 +249,7 @@ YARN_INSTALLED_APPS = [ "materialize-css", "material-design-icons-iconfont", "select2", + "paper-css", ] merge_app_settings("YARN_INSTALLED_APPS", YARN_INSTALLED_APPS, True) @@ -266,6 +268,7 @@ ANY_JS = { "material-design-icons": { "css_url": JS_URL + "/material-design-icons-iconfont/dist/material-design-icons.css" }, + "paper-css": {"css_url": JS_URL + "/paper-css/paper.min.css"}, } merge_app_settings("ANY_JS", ANY_JS, True) diff --git a/aleksis/core/static/print.css b/aleksis/core/static/print.css new file mode 100644 index 0000000000000000000000000000000000000000..4c511a1aec0e871778890bbee305e48130d65d36 --- /dev/null +++ b/aleksis/core/static/print.css @@ -0,0 +1,90 @@ +.sheet.infinite { + height: auto !important; +} + +@page { + size: A4; + padding: 30mm; +} + +header { + display: block; + width: 190mm; +} + + +#print-header { + display: block !important; + border-bottom: 1px solid; + margin-bottom: 0; + height: 22mm; + background: white; +} + +header, main, footer { + margin: 0; +} + +#print-header .col.right-align { + padding: 15px; +} + +.sheet { + padding: 10mm; +} + + +.header-space, .footer-space { + height: 0; +} + +.print-layout-table td { + padding: 0; +} + +.print-layout-table .no-border { + border: 0; +} + + +footer { + margin-top: 5mm; + text-align: center; + width: 190mm; + +} + +header .row, header .col { + padding: 0 !important; + margin: 0 !important; +} + +#print-logo { + padding: 2mm; + height: 22mm; + width: auto; +} + +@media print { + .header-space { + height: 35mm; + } + + .footer-space { + height: 20mm + } + + header, footer { + height: 22mm; + } + + header { + position: fixed; + top: 10mm; + } + + footer { + position: fixed; + bottom: 0; + } +} diff --git a/aleksis/core/static/style.scss b/aleksis/core/static/style.scss index ab23bc22313797502d2c27bec66041e1f9ddc70e..c9421f5a31e7d20e8befa3409e009ad956b9232a 100644 --- a/aleksis/core/static/style.scss +++ b/aleksis/core/static/style.scss @@ -252,7 +252,7 @@ span.badge .material-icons { /* Table*/ -table.striped > tbody > tr:nth-child(odd) { +table.striped > tbody > tr:nth-child(odd), table tr.striped, table tbody.striped tr { background-color: rgba(208, 208, 208, 0.5); } diff --git a/aleksis/core/templates/core/base.html b/aleksis/core/templates/core/base.html index a461e88fa37859b9220e5910e6f9046bf25388db..cfe2f1ce00259825d6cc240709ca60b5b1f487a8 100644 --- a/aleksis/core/templates/core/base.html +++ b/aleksis/core/templates/core/base.html @@ -7,10 +7,7 @@ <!DOCTYPE html> <html lang="de"> <head> - <meta charset="utf-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width,initial-scale=1"> - <meta name="description" content="{% blocktrans %}AlekSIS is a web-based school information system (SIS) which can be used to manage and/or publish organisational data of educational in titutions.{% endblocktrans %}"> + {% include "core/meta.html" %} <title> {% block no_browser_title %} @@ -19,14 +16,6 @@ {{ config.SITE_TITLE }} </title> - {# Favicons #} - <link href="{% static "icons/favicon_16.png" %}" rel="icon" type="image/png" sizes="16x16"> - <link href="{% static "icons/favicon_32.png" %}" rel="icon" type="image/png" sizes="32x32"> - <link href="{% static "icons/favicon_48.png" %}" rel="icon" type="image/png" sizes="48x48"> - - <!-- PWA --> - {% progressive_web_app_meta %} - {# CSS #} {% include_css "material-design-icons" %} <link rel="stylesheet" href="{% sass_src 'style.scss' %}"> diff --git a/aleksis/core/templates/core/base_print.html b/aleksis/core/templates/core/base_print.html new file mode 100644 index 0000000000000000000000000000000000000000..abd42a1c7205de95bacbc84d6d3aa8c29952ecd7 --- /dev/null +++ b/aleksis/core/templates/core/base_print.html @@ -0,0 +1,78 @@ +{% load static i18n any_js sass_tags cropping %} + +<!DOCTYPE html> +<html> +<head> + {% include "core/meta.html" %} + + <title> + {% block no_browser_title %} + {% block browser_title %}{% endblock %} — + {% endblock %} + {{ config.SITE_TITLE }} + </title> + + {% include_css "material-design-icons" %} + {% include_css "paper-css" %} + <link rel="stylesheet" href="{% sass_src 'style.scss' %}"/> + <link rel="stylesheet" href="{% static "print.css" %}"/> + + {% block extra_head %}{% endblock %} +</head> + +<body class="A4 print-body"> +<main class="sheet infinite"> + <div style="margin-top: -10mm;"></div> + + <table class="print-layout-table"> + <thead> + <tr class="no-border"> + <td> + <div class="header-space"> </div> + </td> + </tr> + </thead> + + <tbody> + <tr class="no-border"> + <td> + <div class="content"> + <header> + <div id="print-header" class="row"> + <div class="col s6 logo"> + <img src="{% cropped_thumbnail SCHOOL 'logo_cropping' max_size="85x85" %}" alt="Logo" id="print-logo"/> + </div> + <div class="col s6 right-align"> + <h5>{% block page_title %}{% endblock %}</h5> + {% now "DATETIME_FORMAT" %} + </div> + </div> + </header> + + {% block content %}{% endblock %} + + <footer> + <div class="left"> + {{ SCHOOL.name }} + </div> + + <div class="right"> + {% trans "Powered by AlekSIS" %} + </div> + </footer> + </div> + </td> + </tr> + </tbody> + + <tfoot> + <tr class="no-border"> + <td> + <div class="footer-space"> </div> + </td> + </tr> + </tfoot> + </table> +</main> +</body> +</html> diff --git a/aleksis/core/templates/core/meta.html b/aleksis/core/templates/core/meta.html new file mode 100644 index 0000000000000000000000000000000000000000..4b0be929e8f421a3df4b3d5efedd5909ccc542b4 --- /dev/null +++ b/aleksis/core/templates/core/meta.html @@ -0,0 +1,16 @@ +{% load i18n static pwa %} + +{# Basic meta #} +<meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width,initial-scale=1"> +<meta name="description" + content="{% blocktrans %}AlekSIS is a web-based school information system (SIS) which can be used to manage and/or publish organisational data of educational in titutions.{% endblocktrans %}"> + +{# Favicons #} +<link href="{% static "icons/favicon_16.png" %}" rel="icon" type="image/png" sizes="16x16"> +<link href="{% static "icons/favicon_32.png" %}" rel="icon" type="image/png" sizes="32x32"> +<link href="{% static "icons/favicon_48.png" %}" rel="icon" type="image/png" sizes="48x48"> + +{# PWA meta #} +{% progressive_web_app_meta %} diff --git a/aleksis/core/util/core_helpers.py b/aleksis/core/util/core_helpers.py index bc0700b03b8c755220b5bedfd609aa5d810a86d1..f273016659cf08bf7d4e924296d2950dc9e20694 100644 --- a/aleksis/core/util/core_helpers.py +++ b/aleksis/core/util/core_helpers.py @@ -139,3 +139,12 @@ def path_and_rename(instance, filename: str, upload_to: str = "files") -> str: # return the whole path to the file return os.path.join(upload_to, new_filename) + + +def school_information_processor(request: HttpRequest) -> dict: + """ Provides default School object in all templates """ + + from ..models import School + return { + "SCHOOL": School.get_default, + }