Merged the latest master into siarheipuhach-feature/flake8
This commit is contained in:
		
				commit
				
					
						f9c3c80864
					
				
			
		
					 13 changed files with 205 additions and 140 deletions
				
			
		
							
								
								
									
										15
									
								
								utils/context_processor.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								utils/context_processor.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| from django.conf import settings | ||||
| 
 | ||||
| 
 | ||||
| def google_analytics(request): | ||||
|     """ | ||||
|     Use the variables returned in this function to | ||||
|     render your Google Analytics tracking code template. | ||||
|     """ | ||||
|     host = request.get_host() | ||||
|     ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(host) | ||||
|     if not settings.DEBUG and ga_prop_id: | ||||
|         return { | ||||
|             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id | ||||
|         } | ||||
|     return {} | ||||
							
								
								
									
										17
									
								
								utils/middleware.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								utils/middleware.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| class MultipleProxyMiddleware(object): | ||||
|     FORWARDED_FOR_FIELDS = [ | ||||
|         'HTTP_X_FORWARDED_FOR', | ||||
|         'HTTP_X_FORWARDED_HOST', | ||||
|         'HTTP_X_FORWARDED_SERVER', | ||||
|     ] | ||||
| 
 | ||||
|     def process_request(self, request): | ||||
|         """ | ||||
|         Rewrites the proxy headers so that only the most | ||||
|         recent proxy is used. | ||||
|         """ | ||||
|         for field in self.FORWARDED_FOR_FIELDS: | ||||
|             if field in request.META: | ||||
|                 if ',' in request.META[field]: | ||||
|                     parts = request.META[field].split(',') | ||||
|                     request.META[field] = parts[-1].strip() | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue