Apply futurize --stage1 (safe) Python 2/3 compatibility changes.
				
					
				
			This commit is contained in:
		
							parent
							
								
									69725698ae
								
							
						
					
					
						commit
						05bee8b3c3
					
				
					 5 changed files with 10 additions and 7 deletions
				
			
		|  | @ -6,6 +6,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | ||||||
| from conservancy.apps.staff.models import Person | from conservancy.apps.staff.models import Person | ||||||
| from django.shortcuts import get_object_or_404, render | from django.shortcuts import get_object_or_404, render | ||||||
| from datetime import datetime | from datetime import datetime | ||||||
|  | from functools import reduce | ||||||
| 
 | 
 | ||||||
| def OR_filter(field_name, objs): | def OR_filter(field_name, objs): | ||||||
|     from django.db.models import Q |     from django.db.models import Q | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ def event_detail(request, year, slug, queryset, **kwargs): | ||||||
|     try: |     try: | ||||||
|         event = queryset.get(date__year=year, slug__exact=slug) |         event = queryset.get(date__year=year, slug__exact=slug) | ||||||
|     except ObjectDoesNotExist: |     except ObjectDoesNotExist: | ||||||
|         raise Http404, "Event does not exist" |         raise Http404("Event does not exist") | ||||||
|     return render(request, 'events/event_detail.html', {'event': event}) |     return render(request, 'events/event_detail.html', {'event': event}) | ||||||
| 
 | 
 | ||||||
| def custom_index(request, queryset, *args, **kwargs): | def custom_index(request, queryset, *args, **kwargs): | ||||||
|  | @ -27,7 +27,7 @@ def custom_index(request, queryset, *args, **kwargs): | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     future_events = None |     future_events = None | ||||||
|     if not request.GET.has_key("page"): |     if "page" not in request.GET: | ||||||
|         future_events = Event.future.all().order_by("date") |         future_events = Event.future.all().order_by("date") | ||||||
| 
 | 
 | ||||||
|     date_list = queryset.dates(kwargs['date_field'], 'year') |     date_list = queryset.dates(kwargs['date_field'], 'year') | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ from datetime import datetime | ||||||
| 
 | 
 | ||||||
| import itertools | import itertools | ||||||
| import operator | import operator | ||||||
|  | from functools import reduce | ||||||
| 
 | 
 | ||||||
| class ConservancyFeedBase(Feed): | class ConservancyFeedBase(Feed): | ||||||
|     def copyright_holder(self): return "Software Freedom Conservancy" |     def copyright_holder(self): return "Software Freedom Conservancy" | ||||||
|  | @ -171,7 +172,7 @@ class BlogFeed(ConservancyFeedBase): | ||||||
|             firstTime = True |             firstTime = True | ||||||
|             done = {} |             done = {} | ||||||
|             for tag in tags: |             for tag in tags: | ||||||
|                 if done.has_key(tag): continue |                 if tag in done: continue | ||||||
|                 if firstTime: |                 if firstTime: | ||||||
|                     answer += " (" |                     answer += " (" | ||||||
|                     firstTime = False |                     firstTime = False | ||||||
|  | @ -198,7 +199,7 @@ class BlogFeed(ConservancyFeedBase): | ||||||
|         elif len(tags) > 1: |         elif len(tags) > 1: | ||||||
|             firstTime = True |             firstTime = True | ||||||
|             for tag in tags: |             for tag in tags: | ||||||
|                 if done.has_key(tag): continue |                 if tag in done: continue | ||||||
|                 if firstTime: |                 if firstTime: | ||||||
|                     answer += " tagged with " |                     answer += " tagged with " | ||||||
|                     firstTime = False |                     firstTime = False | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | from future.utils import raise_ | ||||||
| from django import http | from django import http | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.utils.cache import patch_response_headers | from django.utils.cache import patch_response_headers | ||||||
|  | @ -27,13 +28,13 @@ class ForceCanonicalHostnameMiddleware(object): | ||||||
|         if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]): |         if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]): | ||||||
|             new_url[1] = new_url[1] + '/' |             new_url[1] = new_url[1] + '/' | ||||||
|             if settings.DEBUG and request.method == 'POST': |             if settings.DEBUG and request.method == 'POST': | ||||||
|                 raise RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1]) |                 raise_(RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1])) | ||||||
|         # Strip trailing index.html |         # Strip trailing index.html | ||||||
|         if new_url[1].endswith('/index.html'): |         if new_url[1].endswith('/index.html'): | ||||||
|             new_url[1] = new_url[1][:new_url[1].rfind('index.html')] |             new_url[1] = new_url[1][:new_url[1].rfind('index.html')] | ||||||
|         # Consult redirect table (if exists) |         # Consult redirect table (if exists) | ||||||
|         if hasattr(settings, "REDIRECT_TABLE"): |         if hasattr(settings, "REDIRECT_TABLE"): | ||||||
|             if settings.REDIRECT_TABLE.has_key(new_url[1]): |             if new_url[1] in settings.REDIRECT_TABLE: | ||||||
|                 new_url[1] = settings.REDIRECT_TABLE[new_url[1]] |                 new_url[1] = settings.REDIRECT_TABLE[new_url[1]] | ||||||
|         if new_url != old_url: |         if new_url != old_url: | ||||||
|             # Force canonical hostname |             # Force canonical hostname | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ del handler | ||||||
| 
 | 
 | ||||||
| class ModPythonRequest(ModPythonRequest): | class ModPythonRequest(ModPythonRequest): | ||||||
|     def is_secure(self): |     def is_secure(self): | ||||||
|         return self._req.get_options().has_key('HTTPS') and self._req.get_options()['HTTPS'] == 'on' |         return 'HTTPS' in self._req.get_options() and self._req.get_options()['HTTPS'] == 'on' | ||||||
| 
 | 
 | ||||||
| class ModPythonHandler(BaseHandler): | class ModPythonHandler(BaseHandler): | ||||||
|     request_class = ModPythonRequest |     request_class = ModPythonRequest | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue