From 391a327653b2d01a3c0a8cd31a12bcf329da0e27 Mon Sep 17 00:00:00 2001 From: Tom Teichler <tom.teichler@teckids.org> Date: Sun, 3 May 2020 14:28:58 +0200 Subject: [PATCH] [Reformat] black again --- aleksis/core/mixins.py | 5 +++-- aleksis/core/preferences.py | 13 +++---------- aleksis/core/settings.py | 3 +-- aleksis/core/util/apps.py | 1 + aleksis/core/util/core_helpers.py | 5 ++++- aleksis/core/views.py | 1 + 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/aleksis/core/mixins.py b/aleksis/core/mixins.py index a08295116..94283722c 100644 --- a/aleksis/core/mixins.py +++ b/aleksis/core/mixins.py @@ -65,8 +65,9 @@ class ExtensibleModel(models.Model): # Defines a material design icon associated with this type of model icon_ = "radio_button_unchecked" - site = models.ForeignKey(Site, on_delete=models.CASCADE, - default=Site.objects.get_current, editable=False) + site = models.ForeignKey( + Site, on_delete=models.CASCADE, default=Site.objects.get_current, editable=False + ) objects = CurrentSiteManager() objects_all_sites = models.Manager() diff --git a/aleksis/core/preferences.py b/aleksis/core/preferences.py index 56e7b48d5..9aed9b455 100644 --- a/aleksis/core/preferences.py +++ b/aleksis/core/preferences.py @@ -3,16 +3,9 @@ from django.forms import EmailField, ImageField, URLField from django.utils.translation import gettext_lazy as _ from dynamic_preferences.preferences import Section -from dynamic_preferences.types import ( - ChoicePreference, - FilePreference, - StringPreference, -) - -from .registries import ( - person_preferences_registry, - site_preferences_registry, -) +from dynamic_preferences.types import ChoicePreference, FilePreference, StringPreference + +from .registries import person_preferences_registry, site_preferences_registry from .util.notifications import get_notification_choices_lazy general = Section("general") diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py index 20107037d..f7e2dcd4c 100644 --- a/aleksis/core/settings.py +++ b/aleksis/core/settings.py @@ -480,8 +480,7 @@ PWA_APP_SPLASH_SCREEN = [ title="pwa_icon", size=192, rel="apple", default=STATIC_URL + "icons/apple_180.png" ), "media": ( - "(device-width: 320px) and (device-height: 568px) and" - "(-webkit-device-pixel-ratio: 2)" + "(device-width: 320px) and (device-height: 568px) and" "(-webkit-device-pixel-ratio: 2)" ), } ] diff --git a/aleksis/core/util/apps.py b/aleksis/core/util/apps.py index 009cd2ad3..0f101a11d 100644 --- a/aleksis/core/util/apps.py +++ b/aleksis/core/util/apps.py @@ -15,6 +15,7 @@ from .core_helpers import copyright_years class AppConfig(django.apps.AppConfig): """An extended version of DJango's AppConfig container.""" + def ready(self): super().ready() diff --git a/aleksis/core/util/core_helpers.py b/aleksis/core/util/core_helpers.py index b24f48c8c..79bf50594 100644 --- a/aleksis/core/util/core_helpers.py +++ b/aleksis/core/util/core_helpers.py @@ -10,9 +10,9 @@ from uuid import uuid4 from django.conf import settings from django.db.models import Model from django.http import HttpRequest +from django.shortcuts import get_object_or_404 from django.utils import timezone from django.utils.functional import lazy -from django.shortcuts import get_object_or_404 def copyright_years(years: Sequence[int], seperator: str = ", ", joiner: str = "–") -> str: @@ -113,6 +113,7 @@ def lazy_preference(section: str, name: str) -> Callable[[str, str], Any]: to other global settings to make them available to third-party apps that are not aware of dynamic preferences. """ + def _get_preference(section: str, name: str) -> Any: return get_site_preferences()[f"{section}__{name}"] @@ -125,6 +126,7 @@ def lazy_get_favicon_url( title: str, size: int, rel: str, default: Optional[str] = None ) -> Callable[[str, str], Any]: """Lazily get the URL to a favicon image.""" + def _get_favicon_url(size: int, rel: str) -> Any: from favicon.models import Favicon # noqa @@ -220,6 +222,7 @@ def objectgetter_optional( model: Model, default: Optional[Any] = None, default_eval: bool = False ) -> Callable[[HttpRequest, Optional[int]], Model]: """Get an object by pk, defaulting to None.""" + def get_object(request: HttpRequest, id_: Optional[int] = None) -> Model: if id_ is not None: return get_object_or_404(model, pk=id_) diff --git a/aleksis/core/views.py b/aleksis/core/views.py index d6387901a..350e6fc34 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -380,6 +380,7 @@ def searchbar_snippets(request: HttpRequest) -> HttpResponse: class PermissionSearchView(PermissionRequiredMixin, SearchView): """Wrapper to apply permission to haystack's search view.""" + permission_required = "core.search" def create_response(self): -- GitLab