Move SITE_FUNDGOAL configuration to settings/base.py
				
					
				
			This changes more often than the surrounding code, so should live with the other configuration.
This commit is contained in:
		
							parent
							
								
									1792c7ed8b
								
							
						
					
					
						commit
						0b8ae2ca77
					
				
					 5 changed files with 19 additions and 25 deletions
				
			
		
							
								
								
									
										1
									
								
								TODO.md
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO.md
									
										
									
									
									
								
							|  | @ -10,6 +10,7 @@ | |||
| 
 | ||||
| # Done | ||||
| 
 | ||||
| * move `SITE_FUNDGOAL` configuration to `settings.py` | ||||
| * move `sponsors.py` and `sponsors.html` into `supporters` app | ||||
| * use `<detail>` elements for supporter page hidden sections, rather than | ||||
|   complex jQuery | ||||
|  |  | |||
							
								
								
									
										14
									
								
								conservancy/context_processors.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								conservancy/context_processors.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| from django.conf import settings | ||||
| 
 | ||||
| from .fundgoal.models import FundraisingGoal | ||||
| 
 | ||||
| def sitefundraiser(request): | ||||
|     try: | ||||
|         fundgoal = FundraisingGoal.objects.get(fundraiser_code_name=settings.SITE_FUNDGOAL) | ||||
|     except FundraisingGoal.DoesNotExist: | ||||
|         fundgoal = None | ||||
|     return {'sitefundgoal': fundgoal} | ||||
| 
 | ||||
| 
 | ||||
| def host_url(request): | ||||
|     return {'host_url': request.build_absolute_uri('/').rstrip('/')} | ||||
|  | @ -1,18 +0,0 @@ | |||
| from .fundgoal.models import FundraisingGoal | ||||
| 
 | ||||
| SITE_FUNDGOAL = 'cy2023-end-year-match' | ||||
| 
 | ||||
| def fundgoal_lookup(fundraiser_sought): | ||||
|     try: | ||||
|         return FundraisingGoal.objects.get(fundraiser_code_name=fundraiser_sought) | ||||
|     except FundraisingGoal.DoesNotExist: | ||||
|         # we have no object!  do something | ||||
|         return None | ||||
| 
 | ||||
| def sitefundraiser(request): | ||||
|     return { | ||||
|         'sitefundgoal': fundgoal_lookup(SITE_FUNDGOAL), | ||||
|     } | ||||
| 
 | ||||
| def host_url(request): | ||||
|     return {'host_url': request.build_absolute_uri('/').rstrip('/')} | ||||
|  | @ -111,8 +111,8 @@ TEMPLATES = [ | |||
|                 'django.template.context_processors.request', | ||||
|                 'django.contrib.auth.context_processors.auth', | ||||
|                 'django.contrib.messages.context_processors.messages', | ||||
|                 'conservancy.local_context_processors.host_url', | ||||
|                 'conservancy.local_context_processors.sitefundraiser', | ||||
|                 'conservancy.context_processors.host_url', | ||||
|                 'conservancy.context_processors.sitefundraiser', | ||||
|             ] | ||||
|         } | ||||
|     } | ||||
|  | @ -143,3 +143,5 @@ USETHESOURCE = { | |||
|     'SENDER': 'compliance@sfconservancy.org', | ||||
|     'LIST_RECIPIENT': 'ccs-review@lists.sfconservancy.org', | ||||
| } | ||||
| 
 | ||||
| SITE_FUNDGOAL = 'cy2023-end-year-match' | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ from django.shortcuts import render | |||
| from django.template import RequestContext, Template | ||||
| 
 | ||||
| from .blog.models import Entry | ||||
| from .local_context_processors import fundgoal_lookup | ||||
| from .news.models import PressRelease | ||||
| from .supporters.models import Supporter | ||||
| 
 | ||||
|  | @ -62,10 +61,6 @@ def content(request, *args, **kwargs): | |||
|     if not is_template: | ||||
|         return FileResponse(open(full_path, 'rb')) | ||||
|     else: | ||||
|         try: | ||||
|             kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought']) | ||||
|         except KeyError: | ||||
|             pass | ||||
|         # These template are intentionally not in the template loader path, so | ||||
|         # we open them directly, rather than using the template loader. | ||||
|         with open(full_path, encoding='utf-8') as t: | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue