diff --git a/aleksis/core/db_settings.py b/aleksis/core/db_settings.py new file mode 100644 index 0000000000000000000000000000000000000000..7e5c8229396c2c273d4e991c4c94f072a26dd4c5 --- /dev/null +++ b/aleksis/core/db_settings.py @@ -0,0 +1,29 @@ +from django.utils.translation import ugettext_lazy as _ + +import dbsettings + + +class ThemeSettings(dbsettings.Group): + colour_primary = dbsettings.StringValue(_("Primary colour"), default="#007bff") + colour_secondary = dbsettings.StringValue(_("Secondary colour"), default="#007bff") + + +class MailSettings(dbsettings.Group): + mail_out_name = dbsettings.StringValue(_("Mail out name"), default="AlekSIS", required=False) + mail_out = dbsettings.StringValue(_("Mail out address"), default="no-reply@aleksis.org") + + +class FooterSettings(dbsettings.Group): + privacy_url = dbsettings.StringValue(_("Link to privacy policy"), default="") + impress_url = dbsettings.StringValue(_("Link to impress"), default="") + + +theme_settings = ThemeSettings(_("Global theme settings")) +mail_settings = MailSettings(_("Mail settings")) +footer_settings = FooterSettings(_("Footer links")) + +db_settings = { + "theme": theme_settings, + "mail": mail_settings, + "footer": footer_settings +} diff --git a/aleksis/core/mailer.py b/aleksis/core/mailer.py index 6cd4c0c98cb0927e6aa72c0561a5327c10a67cad..8ae90edb9f3397b4e401e668dc2cc2fbe14d870b 100644 --- a/aleksis/core/mailer.py +++ b/aleksis/core/mailer.py @@ -1,10 +1,13 @@ from django.core.mail import send_mail from django.template.loader import render_to_string -SENDER_EMAIL = 'SchoolApps <infoplan@katharineum.de>' +from aleksis.core.db_settings import mail_settings +mail_out = "{} <{}>".format(mail_settings.mail_out_name, + mail_settings.mail_out) if mail_settings.mail_out_name != "" else mail_settings.mail_out -def send_mail_with_template(title, receivers, plain_template, html_template, context={}, sender_email=SENDER_EMAIL): + +def send_mail_with_template(title, receivers, plain_template, html_template, context={}, mail_out=mail_out): msg_plain = render_to_string(plain_template, context) msg_html = render_to_string(html_template, context) @@ -12,7 +15,7 @@ def send_mail_with_template(title, receivers, plain_template, html_template, con send_mail( title, msg_plain, - sender_email, + mail_out, receivers, html_message=msg_html, ) diff --git a/aleksis/core/menus.py b/aleksis/core/menus.py index c4ba24e2ab87e783a358721d90028e0a8c77b96a..a7662bc719438e5486d620bbb64127dfd347c7a5 100644 --- a/aleksis/core/menus.py +++ b/aleksis/core/menus.py @@ -129,8 +129,9 @@ MENUS = { }, ], "FOOTER_MENU_CORE": [ - {"name": _("Website"), "url": "https://aleksis.edugit.org/"}, + {"name": _("Website"), "url": "https://aleksis.edugit.io/"}, {"name": "Teckids e.V.", "url": "https://www.teckids.org/"}, + {"name": "Katharineum zu Lübeck", "url": "https://katharineum-zu-luebeck.de"} ], "DATA_MANAGEMENT_MENU": [], "SCHOOL_MANAGEMENT_MENU": [ diff --git a/aleksis/core/models.py b/aleksis/core/models.py index 811cfaeb03c17393a95668abce719e4e7470544c..c3faec8d52d4b86df75202d5ab4ba3f0afca6d0d 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -5,8 +5,6 @@ from django.contrib.auth.models import User from django.db import models from django.utils import timezone from django.utils.translation import ugettext_lazy as _ - -import dbsettings from image_cropping import ImageCropField, ImageRatioField from phonenumber_field.modelfields import PhoneNumberField @@ -14,14 +12,6 @@ from .mailer import send_mail_with_template from .mixins import ExtensibleModel -class ThemeSettings(dbsettings.Group): - colour_primary = dbsettings.StringValue(default="#007bff") - colour_secondary = dbsettings.StringValue(default="#007bff") - - -theme_settings = ThemeSettings("Global theme settings") - - class School(models.Model): """A school that will have many other objects linked to it. AlekSIS has multi-tenant support by linking all objects to a school, diff --git a/aleksis/core/processors.py b/aleksis/core/processors.py new file mode 100644 index 0000000000000000000000000000000000000000..fcfe15407d10b354dd01a43f8d9921a67ccef89a --- /dev/null +++ b/aleksis/core/processors.py @@ -0,0 +1,5 @@ +from aleksis.core.db_settings import db_settings + + +def db_settings_processor(request): + return {"DB_SETTINGS": db_settings} diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py index 6270c7d126627ca3ddb27f8e2346ac7a9aa35373..a27912a7a99fe6b4f4fd4fa50fd592a11afe6ce5 100644 --- a/aleksis/core/settings.py +++ b/aleksis/core/settings.py @@ -119,6 +119,7 @@ TEMPLATES = [ "django.contrib.messages.context_processors.messages", "maintenance_mode.context_processors.maintenance_mode", "settings_context_processor.context_processors.settings", + "aleksis.core.processors.db_settings_processor" ], }, }, diff --git a/aleksis/core/templates/core/base.html b/aleksis/core/templates/core/base.html index 62635310eb8c158a9efb816b9d9a9d04d6bb1c91..a612ec66af3e782faa6ec441b0303425995fc474 100644 --- a/aleksis/core/templates/core/base.html +++ b/aleksis/core/templates/core/base.html @@ -118,28 +118,35 @@ </div> <div class="footer-copyright"> <div class="container"> - <span class="left"> - <a class="blue-text text-lighten-4" href="https://aleksis.edugit.org/"> - AlekSIS — The Free School Information System - </a> - © The AlekSIS Team @ - <a class="blue-text text-lighten-4" href="https://www.teckids.org"> - Teckids e.V. - </a> - and - <a class="blue-text text-lighten-4" href="https://katharineum-zu-luebeck.de"> - Katharineum zu Lübeck - </a> - </span> - <span class="right"> - <span id="doit"></span> - - <a class="blue-text text-lighten-4" href="https://katharineum-zu-luebeck.de/impressum/">Impressum</a> - · - <a class="blue-text text-lighten-4" href="https://katharineum-zu-luebeck.de/datenschutzerklaerung/"> - Datenschutzerklärung - </a> - </span> + <div class="left"> + <a class="blue-text text-lighten-4" href="https://aleksis.edugit.org/"> + AlekSIS — The Free School Information System + </a> + © The AlekSIS Team @ + <a class="blue-text text-lighten-4" href="https://www.teckids.org"> + Teckids e.V. + </a> + and + <a class="blue-text text-lighten-4" href="https://katharineum-zu-luebeck.de"> + Katharineum zu Lübeck + </a> + </div> + <div class="right"> + <span id="doit"></span> + {% if DB_SETTINGS.footer.impress_url %} + <a class="blue-text text-lighten-4" href="{{ DB_SETTINGS.footer.impress_url }}"> + {% trans "Impress" %} + </a> + {% endif %} + {% if DB_SETTINGS.footer.privacy_url and DB_SETTINGS.footer.impress_url %} + · + {% endif %} + {% if DB_SETTINGS.footer.privacy_url %} + <a class="blue-text text-lighten-4" href="{{ DB_SETTINGS.footer.privacy_url }}"> + {% trans "Privacy Policy" %} + </a> + {% endif %} + </div> </div> </div> </footer> diff --git a/aleksis/core/util/sass_helpers.py b/aleksis/core/util/sass_helpers.py index 2bb44b09c62a55219272d3021a78daf4aaa07b98..0c883ffd42ca22a3de6e8758890819f1fd96814d 100644 --- a/aleksis/core/util/sass_helpers.py +++ b/aleksis/core/util/sass_helpers.py @@ -1,7 +1,7 @@ from colour import web2hex from sass import SassColor -from aleksis.core.models import theme_settings +from aleksis.core.db_settings import theme_settings def get_colour(html_colour: str) -> SassColor: