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

Upload logo, PWA, and favicon files to public namespace

parent 0bacbedd
No related branches found
No related tags found
1 merge request!837Resolve "Icons/logo should be uploaded to public/"
# flake8: noqa: DJ12
import os
from datetime import datetime
from typing import Any, Callable, List, Optional, Union
......@@ -21,6 +22,8 @@ from django.views.generic import CreateView, UpdateView
from django.views.generic.edit import DeleteView, ModelFormMixin
import reversion
from dynamic_preferences.settings import preferences_settings
from dynamic_preferences.types import FilePreference
from guardian.admin import GuardedModelAdmin
from guardian.core import ObjectPermissionChecker
from jsonstore.fields import IntegerField, JSONFieldMixin
......@@ -529,3 +532,14 @@ class SchoolTermRelatedExtensibleForm(ExtensibleForm):
kwargs["initial"] = {"school_term": SchoolTerm.current}
super().__init__(*args, **kwargs)
class PublicFilePreferenceMixin(FilePreference):
"""Uploads a file to the public namespace."""
upload_path = "public"
def get_upload_path(self):
return os.path.join(
self.upload_path, preferences_settings.FILE_PREFERENCE_UPLOAD_DIR, self.identifier()
)
......@@ -16,6 +16,7 @@ from dynamic_preferences.types import (
)
from oauth2_provider.models import AbstractApplication
from .mixins import PublicFilePreferenceMixin
from .models import Group, Person
from .registries import person_preferences_registry, site_preferences_registry
from .util.notifications import get_notification_choices_lazy
......@@ -78,7 +79,7 @@ class ColourSecondary(StringPreference):
@site_preferences_registry.register
class Logo(FilePreference):
class Logo(PublicFilePreferenceMixin, FilePreference):
"""Logo of your AlekSIS instance."""
section = theme
......@@ -88,7 +89,7 @@ class Logo(FilePreference):
@site_preferences_registry.register
class Favicon(FilePreference):
class Favicon(PublicFilePreferenceMixin, FilePreference):
"""Favicon of your AlekSIS instance."""
section = theme
......@@ -98,7 +99,7 @@ class Favicon(FilePreference):
@site_preferences_registry.register
class PWAIcon(FilePreference):
class PWAIcon(PublicFilePreferenceMixin, FilePreference):
"""PWA-Icon of your AlekSIS instance."""
section = theme
......
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