Remove use of python3-future

This commit is contained in:
Ben Sturmfels 2023-09-07 22:59:23 +10:00
parent 6c83c6289f
commit 60010999d2
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
8 changed files with 37 additions and 26 deletions

View file

@ -1,13 +1,18 @@
Software Freedom Conservancy website
====================================
Contributing Contributing
============ ------------
The canonical location for this repository is [on Conservancys The canonical location for this repository is [on Conservancys
Kallithea instance](http://k.sfconservancy.org/website). Copies of Kallithea instance](https://k.sfconservancy.org/website). Copies of
this repository elsewhere, such as Github, are for backup purposes this repository elsewhere, such as Github, are for backup purposes
only.. only..
License License
======= -------
The software included herein, such as the Python source files, are generally The software included herein, such as the Python source files, are generally
licensed [AGPLv3](AGPLv3)-or-later. The Javascript is a hodgepodge of licensed [AGPLv3](AGPLv3)-or-later. The Javascript is a hodgepodge of
@ -17,22 +22,37 @@ the notices at the top of each Javascript file for licensing details.
The content and text (such as the HTML files) is currently The content and text (such as the HTML files) is currently
[CC-BY-SA-3.0](CC-By-SA-3.0). [CC-BY-SA-3.0](CC-By-SA-3.0).
Server Configuration
====================
conservancy's webserver runs on a machine called Server configuration
dogwood.sfconservancy.org, which is a standard Debian installation. --------------------
conservancy's webserver runs on a machine called aspen.sfconservancy.org, which
is a standard Debian installation.
The following packages are installed to make Django and Apache work on a The following packages are installed to make Django and Apache work on a
squeeze install: squeeze install:
$ aptitude install python-django apache2 sqlite3 python2.5-sqlite libapache2-mod-python $ aptitude install python-django apache2 sqlite3 python3-sqlite libapache2-mod-wsgi-py3
Django setup
Django Setup ------------
============
0. Make sure the Python module 'djangopw', with the global variable 0. Make sure the Python module 'djangopw', with the global variable
'djangoadmin_password' is somewhere importable in the default 'djangoadmin_password' is somewhere importable in the default
PYTHON_PATH. PYTHON_PATH.
Local development
---------
python3 -m pip install -r requirements.txt
cd www
python manage.py runserver
Deploying
---------
Changes pushed to the https://k.sfconservancy.org/website repository are
automatically deployed to the production website by the `conservancy-www-update`
SystemD timer. See `systemd/conservancy-www-update.timer` for details.

View file

@ -2,6 +2,5 @@ beautifulsoup4==4.9.3
Django==1.11.29 Django==1.11.29
soupsieve==1.9.6 soupsieve==1.9.6
html5lib==0.999999999 html5lib==0.999999999
future
django_countries==5.5 # Supports both Python 2 and 3. django_countries==5.5 # Supports both Python 2 and 3.

View file

@ -1,14 +1,13 @@
from past.builtins import basestring
from builtins import object from builtins import object
import hashlib import hashlib
from django.conf import settings from django.conf import settings
from django.template import RequestContext
# This is backwards compatibilty support for a custom function we wrote # This is backwards compatibilty support for a custom function we wrote
# ourselves that is no longer necessary in modern Django. # ourselves that is no longer necessary in modern Django.
from django.shortcuts import render as render_template_with_context from django.shortcuts import render as render_template_with_context
class ParameterValidator(object): class ParameterValidator(object):
def __init__(self, given_hash_or_params, params_hash_key=None): def __init__(self, given_hash_or_params, params_hash_key=None):
if params_hash_key is None: if params_hash_key is None:
@ -17,7 +16,7 @@ class ParameterValidator(object):
self.given_hash = given_hash_or_params.get(params_hash_key) self.given_hash = given_hash_or_params.get(params_hash_key)
seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '').encode('utf-8') seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '').encode('utf-8')
self.hasher = hashlib.sha256(seed) self.hasher = hashlib.sha256(seed)
if isinstance(self.given_hash, basestring): if isinstance(self.given_hash, str):
self.hash_type = type(self.given_hash) self.hash_type = type(self.given_hash)
else: else:
self.hash_type = type(self.hasher.hexdigest()) self.hash_type = type(self.hasher.hexdigest())

View file

@ -1,5 +1,3 @@
from future import standard_library
standard_library.install_aliases()
from builtins import object from builtins import object
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings

View file

@ -1,10 +1,10 @@
from __future__ import division from __future__ import division
from past.utils import old_div
from builtins import object from builtins import object
import random import random
from django.db import models from django.db import models
class FundraisingGoal(models.Model): class FundraisingGoal(models.Model):
"""Conservancy fundraiser Goal""" """Conservancy fundraiser Goal"""
@ -19,7 +19,7 @@ class FundraisingGoal(models.Model):
return self.fundraiser_code_name return self.fundraiser_code_name
def percentage_there(self): def percentage_there(self):
return (old_div(self.fundraiser_so_far_amount, self.fundraiser_goal_amount) ) * 100 return self.fundraiser_so_far_amount / self.fundraiser_goal_amount * 100
class Meta(object): class Meta(object):
ordering = ('fundraiser_code_name',) ordering = ('fundraiser_code_name',)

View file

@ -1,5 +1,3 @@
from future import standard_library
standard_library.install_aliases()
from builtins import object from builtins import object
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings

View file

@ -1,5 +1,3 @@
from future import standard_library
standard_library.install_aliases()
from builtins import zip from builtins import zip
import urllib.parse import urllib.parse

View file

@ -1,5 +1,4 @@
from builtins import object from builtins import object
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
@ -29,7 +28,7 @@ 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')]