misc: move station and audio_streams to context_processors (in order to have them available in accounts views)
This commit is contained in:
parent
c8b0d1c5fb
commit
8b3d3a2483
3
aircox/context_processors/__init__.py
Normal file
3
aircox/context_processors/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
def station(request):
|
||||||
|
station = request.station
|
||||||
|
return {"station": station, "audio_streams": station.streams}
|
|
@ -50,13 +50,9 @@ class BaseView(TemplateResponseMixin, ContextMixin):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs.setdefault("station", self.station)
|
|
||||||
kwargs.setdefault("page", self.get_page())
|
kwargs.setdefault("page", self.get_page())
|
||||||
kwargs.setdefault("header_template_name", self.header_template_name)
|
kwargs.setdefault("header_template_name", self.header_template_name)
|
||||||
|
|
||||||
if "audio_streams" not in kwargs:
|
|
||||||
kwargs["audio_streams"] = self.station.streams
|
|
||||||
|
|
||||||
if "model" not in kwargs:
|
if "model" not in kwargs:
|
||||||
model = getattr(self, "model", None) or hasattr(self, "object") and type(self.object)
|
model = getattr(self, "model", None) or hasattr(self, "object") and type(self.object)
|
||||||
kwargs["model"] = model
|
kwargs["model"] = model
|
||||||
|
|
|
@ -238,6 +238,7 @@ TEMPLATES = [
|
||||||
"django.template.context_processors.static",
|
"django.template.context_processors.static",
|
||||||
"django.template.context_processors.tz",
|
"django.template.context_processors.tz",
|
||||||
"django.contrib.messages.context_processors.messages",
|
"django.contrib.messages.context_processors.messages",
|
||||||
|
"aircox.context_processors.station",
|
||||||
),
|
),
|
||||||
"loaders": (
|
"loaders": (
|
||||||
"django.template.loaders.filesystem.Loader",
|
"django.template.loaders.filesystem.Loader",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user