Skip to content
Snippets Groups Projects
Verified Commit aec973fb authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add context processor and helpers for passing default school to templates

parent 6be70234
No related branches found
No related tags found
1 merge request!143Add base template for printing views
Pipeline #762 failed
......@@ -30,6 +30,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)
......
......@@ -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,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment