misc: move station and audio_streams to context_processors (in order to have them available in accounts views)
This commit is contained in:
		
							
								
								
									
										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
 | 
			
		||||
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        kwargs.setdefault("station", self.station)
 | 
			
		||||
        kwargs.setdefault("page", self.get_page())
 | 
			
		||||
        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:
 | 
			
		||||
            model = getattr(self, "model", None) or hasattr(self, "object") and type(self.object)
 | 
			
		||||
            kwargs["model"] = model
 | 
			
		||||
 | 
			
		||||
@ -238,6 +238,7 @@ TEMPLATES = [
 | 
			
		||||
                "django.template.context_processors.static",
 | 
			
		||||
                "django.template.context_processors.tz",
 | 
			
		||||
                "django.contrib.messages.context_processors.messages",
 | 
			
		||||
                "aircox.context_processors.station",
 | 
			
		||||
            ),
 | 
			
		||||
            "loaders": (
 | 
			
		||||
                "django.template.loaders.filesystem.Loader",
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user