Changeset - 05bee8b3c3b9
[Not reviewed]
0 5 0
Ben Sturmfels (bsturmfels) - 2 years ago 2021-11-26 02:00:20
ben@sturm.com.au
Apply `futurize --stage1` (safe) Python 2/3 compatibility changes.
5 files changed with 10 insertions and 7 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/blog/views.py
Show inline comments
...
 
@@ -6,6 +6,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
from conservancy.apps.staff.models import Person
 
from django.shortcuts import get_object_or_404, render
 
from datetime import datetime
 
from functools import reduce
 

	
 
def OR_filter(field_name, objs):
 
    from django.db.models import Q
www/conservancy/apps/events/views.py
Show inline comments
...
 
@@ -19,7 +19,7 @@ def event_detail(request, year, slug, queryset, **kwargs):
 
    try:
 
        event = queryset.get(date__year=year, slug__exact=slug)
 
    except ObjectDoesNotExist:
 
        raise Http404, "Event does not exist"
 
        raise Http404("Event does not exist")
 
    return render(request, 'events/event_detail.html', {'event': event})
 

	
 
def custom_index(request, queryset, *args, **kwargs):
...
 
@@ -27,7 +27,7 @@ def custom_index(request, queryset, *args, **kwargs):
 
    """
 

	
 
    future_events = None
 
    if not request.GET.has_key("page"):
 
    if "page" not in request.GET:
 
        future_events = Event.future.all().order_by("date")
 

	
 
    date_list = queryset.dates(kwargs['date_field'], 'year')
www/conservancy/feeds.py
Show inline comments
...
 
@@ -8,6 +8,7 @@ from datetime import datetime
 

	
 
import itertools
 
import operator
 
from functools import reduce
 

	
 
class ConservancyFeedBase(Feed):
 
    def copyright_holder(self): return "Software Freedom Conservancy"
...
 
@@ -171,7 +172,7 @@ class BlogFeed(ConservancyFeedBase):
 
            firstTime = True
 
            done = {}
 
            for tag in tags:
 
                if done.has_key(tag): continue
 
                if tag in done: continue
 
                if firstTime:
 
                    answer += " ("
 
                    firstTime = False
...
 
@@ -198,7 +199,7 @@ class BlogFeed(ConservancyFeedBase):
 
        elif len(tags) > 1:
 
            firstTime = True
 
            for tag in tags:
 
                if done.has_key(tag): continue
 
                if tag in done: continue
 
                if firstTime:
 
                    answer += " tagged with "
 
                    firstTime = False
www/conservancy/middleware.py
Show inline comments
 
from future.utils import raise_
 
from django import http
 
from django.conf import settings
 
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]):
 
            new_url[1] = new_url[1] + '/'
 
            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
 
        if new_url[1].endswith('/index.html'):
 
            new_url[1] = new_url[1][:new_url[1].rfind('index.html')]
 
        # Consult redirect table (if exists)
 
        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]]
 
        if new_url != old_url:
 
            # Force canonical hostname
www/modpythoncustom.py
Show inline comments
...
 
@@ -42,7 +42,7 @@ del handler
 

	
 
class ModPythonRequest(ModPythonRequest):
 
    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):
 
    request_class = ModPythonRequest
0 comments (0 inline, 0 general)