Skip to content
Commits on Source (14)
......@@ -6,6 +6,22 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_,
and this project adheres to `Semantic Versioning`_.
`2.7.2`_ - 2022-01-31
---------------------
Changed
~~~~~~~
* [Dev] The (undocumented) setting PDF_CONTEXT_PROCESSORS is now named NON_REQUEST_CONTEXT_PROCESSORS
* [Docker] Cache is now cleared if migrations are applied
* Update German translations.
Fixed
~~~~~
* Celery progress could be inaccurate if recording progress during a transaction
`2.7.1`_ - 2022-01-28
---------------------
......@@ -692,3 +708,4 @@ Fixed
.. _2.6: https://edugit.org/AlekSIS/Official/AlekSIS/-/tags/2.6
.. _2.7: https://edugit.org/AlekSIS/Official/AlekSIS/-/tags/2.7
.. _2.7.1: https://edugit.org/AlekSIS/Official/AlekSIS/-/tags/2.7.1
.. _2.7.2: https://edugit.org/AlekSIS/Official/AlekSIS/-/tags/2.7.2
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -18,18 +18,18 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr ""
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr ""
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr ""
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: 2021-10-28 14:37+0000\n"
"Last-Translator: Jonathan Weth <teckids@jonathanweth.de>\n"
"Language-Team: German <https://translate.edugit.org/projects/aleksis/aleksis-core-js/de/>\n"
......@@ -18,18 +18,18 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.8\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr "Heute"
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr "Abbrechen"
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr "OK"
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr "Diese Seite enthält vielleicht veraltete Informationen, da es keine Internetverbindung gibt."
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -18,18 +18,18 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr ""
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr ""
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr ""
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,18 +17,18 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr ""
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr ""
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr ""
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,18 +17,18 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr ""
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr ""
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr ""
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-10 17:26+0100\n"
"POT-Creation-Date: 2022-01-31 17:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,18 +17,18 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: aleksis/core/static/js/main.js:15
#: aleksis/core/static/js/main.js:66
msgid "Today"
msgstr ""
#: aleksis/core/static/js/main.js:16
#: aleksis/core/static/js/main.js:67
msgid "Cancel"
msgstr ""
#: aleksis/core/static/js/main.js:17
#: aleksis/core/static/js/main.js:68
msgid "OK"
msgstr ""
#: aleksis/core/static/js/main.js:131
#: aleksis/core/static/js/main.js:191
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
......@@ -12,6 +12,7 @@ from .util.core_helpers import get_app_packages, merge_app_settings, monkey_patc
monkey_patch()
IN_PYTEST = "PYTEST_CURRENT_TEST" in os.environ or "TOX_ENV_DIR" in os.environ
PYTEST_SETUP_DATABASES = [("default", "default_oot")]
ENVVAR_PREFIX_FOR_DYNACONF = "ALEKSIS"
DIRS_FOR_DYNACONF = ["/etc/aleksis"]
......@@ -203,7 +204,7 @@ TEMPLATES = [
# Attention: The following context processors must accept None
# as first argument (in addition to a HttpRequest object)
PDF_CONTEXT_PROCESSORS = [
NON_REQUEST_CONTEXT_PROCESSORS = [
"django.template.context_processors.i18n",
"django.template.context_processors.tz",
"aleksis.core.util.core_helpers.custom_information_processor",
......@@ -227,6 +228,13 @@ DATABASES = {
}
}
# Duplicate default database for out-of-transaction updates
DATABASES["default_oot"] = DATABASES["default"].copy()
DATABASE_ROUTERS = [
"aleksis.core.util.core_helpers.OOTRouter",
]
DATABASE_OOT_LABELS = ["django_celery_results"]
merge_app_settings("DATABASES", DATABASES, False)
REDIS_HOST = _settings.get("redis.host", "localhost")
......
......@@ -390,3 +390,54 @@ def create_default_celery_schedule():
PeriodicTask.objects.create(
name=f"{name} (default schedule)", task=name, **{attr: db_schedule}
)
class OOTRouter:
"""Database router for operations that should run out of transaction.
This router routes database operations for certain apps through
the separate default_oot connection, to ensure that data get
updated immediately even during atomic transactions.
"""
default_db = "default"
oot_db = "default_oot"
@property
def oot_labels(self):
return settings.DATABASE_OOT_LABELS
@property
def default_dbs(self):
return set((self.default_db, self.oot_db))
def is_same_db(self, db1: str, db2: str):
return set((db1, db2)).issubset(self.default_dbs)
def db_for_read(self, model: Model, **hints) -> Optional[str]:
if model._meta.app_label in self.oot_labels:
return self.oot_db
return None
def db_for_write(self, model: Model, **hints) -> Optional[str]:
return self.db_for_read(model, **hints)
def allow_relation(self, obj1: Model, obj2: Model, **hints) -> Optional[bool]:
# Allow relations between default database and OOT connection
# They are the same database
if self.is_same_db(obj1._state.db, obj2._state.db):
return True
return None
def allow_migrate(
self, db: str, app_label: str, model_name: Optional[str] = None, **hints
) -> Optional[bool]:
# Never allow any migrations on the default_oot database
# It connects to the same database as default, so everything
# migrated there
if db == self.oot_db:
return False
return None
......@@ -15,7 +15,7 @@ def send_email(
**kwargs,
):
"""Send templated email with data from context processors."""
processed_context = process_custom_context_processors(settings.PDF_CONTEXT_PROCESSORS)
processed_context = process_custom_context_processors(settings.NON_REQUEST_CONTEXT_PROCESSORS)
processed_context.update(context)
if not from_email:
from_address = get_site_preferences()["mail__address"]
......
......@@ -74,7 +74,9 @@ def generate_pdf_from_template(
) -> Tuple[PDFFile, AsyncResult]:
"""Start a PDF generation task and return the matching file object and Celery result."""
if not request:
processed_context = process_custom_context_processors(settings.PDF_CONTEXT_PROCESSORS)
processed_context = process_custom_context_processors(
settings.NON_REQUEST_CONTEXT_PROCESSORS
)
processed_context.update(context)
else:
processed_context = context
......
......@@ -48,7 +48,11 @@ wait_database() {
prepare_database() {
# Migrate database; should only be run in app container or job
aleksis-admin migrate && aleksis-admin createinitialrevisions
if aleksis-admin migrate --check >/dev/null 2>&1; then
aleksis-admin migrate && \
aleksis-admin clear_cache && \
aleksis-admin createinitialrevisions
fi
}
# Wait for database to be reachable under all conditions
......
......@@ -31,7 +31,7 @@ author = "The AlekSIS Team"
# The short X.Y version
version = "2.7"
# The full version, including alpha/beta/rc tags
release = "2.7.1"
release = "2.7.2"
# -- General configuration ---------------------------------------------------
......
[tool.poetry]
name = "AlekSIS-Core"
version = "2.7.1"
version = "2.7.2"
packages = [
{ include = "aleksis" }
]
......