From 98fcf8e35d4a7e480441f6dad5f6d33a32ded87d Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Thu, 7 Sep 2023 22:59:23 +1000 Subject: [PATCH] Remove use of python3-future --- README.md | 42 ++++++++++++++----- requirements.txt | 1 - www/conservancy/__init__.py | 5 +-- www/conservancy/apps/blog/models.py | 2 - www/conservancy/apps/fundgoal/models.py | 6 +-- www/conservancy/apps/news/models.py | 2 - .../apps/news/templatetags/fill_url.py | 2 - www/conservancy/middleware.py | 3 +- 8 files changed, 37 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 6c5f5627..85a1b581 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,18 @@ +Software Freedom Conservancy website +==================================== + + Contributing -============ +------------ The canonical location for this repository is [on Conservancy’s -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 only.. + License -======= +------- The software included herein, such as the Python source files, are generally 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 [CC-BY-SA-3.0](CC-By-SA-3.0). -Server Configuration -==================== -conservancy's webserver runs on a machine called -dogwood.sfconservancy.org, which is a standard Debian installation. +Server configuration +-------------------- + +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 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 'djangoadmin_password' is somewhere importable in the default 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. diff --git a/requirements.txt b/requirements.txt index 4a8dd746..e91a7bab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,5 @@ beautifulsoup4==4.9.3 Django==1.11.29 soupsieve==1.9.6 html5lib==0.999999999 -future django_countries==5.5 # Supports both Python 2 and 3. diff --git a/www/conservancy/__init__.py b/www/conservancy/__init__.py index dba7ab71..1a64ad37 100644 --- a/www/conservancy/__init__.py +++ b/www/conservancy/__init__.py @@ -1,14 +1,13 @@ -from past.builtins import basestring from builtins import object import hashlib from django.conf import settings -from django.template import RequestContext # This is backwards compatibilty support for a custom function we wrote # ourselves that is no longer necessary in modern Django. from django.shortcuts import render as render_template_with_context + class ParameterValidator(object): def __init__(self, given_hash_or_params, params_hash_key=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) seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '').encode('utf-8') self.hasher = hashlib.sha256(seed) - if isinstance(self.given_hash, basestring): + if isinstance(self.given_hash, str): self.hash_type = type(self.given_hash) else: self.hash_type = type(self.hasher.hexdigest()) diff --git a/www/conservancy/apps/blog/models.py b/www/conservancy/apps/blog/models.py index d43777fb..17d109f1 100644 --- a/www/conservancy/apps/blog/models.py +++ b/www/conservancy/apps/blog/models.py @@ -1,5 +1,3 @@ -from future import standard_library -standard_library.install_aliases() from builtins import object from django.db import models from django.conf import settings diff --git a/www/conservancy/apps/fundgoal/models.py b/www/conservancy/apps/fundgoal/models.py index 8946f374..94b92771 100644 --- a/www/conservancy/apps/fundgoal/models.py +++ b/www/conservancy/apps/fundgoal/models.py @@ -1,10 +1,10 @@ from __future__ import division -from past.utils import old_div from builtins import object import random from django.db import models + class FundraisingGoal(models.Model): """Conservancy fundraiser Goal""" @@ -19,8 +19,8 @@ class FundraisingGoal(models.Model): return self.fundraiser_code_name 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): ordering = ('fundraiser_code_name',) diff --git a/www/conservancy/apps/news/models.py b/www/conservancy/apps/news/models.py index cd1d76b3..c516a86e 100644 --- a/www/conservancy/apps/news/models.py +++ b/www/conservancy/apps/news/models.py @@ -1,5 +1,3 @@ -from future import standard_library -standard_library.install_aliases() from builtins import object from django.db import models from django.conf import settings diff --git a/www/conservancy/apps/news/templatetags/fill_url.py b/www/conservancy/apps/news/templatetags/fill_url.py index e36fbee5..e35605ee 100644 --- a/www/conservancy/apps/news/templatetags/fill_url.py +++ b/www/conservancy/apps/news/templatetags/fill_url.py @@ -1,5 +1,3 @@ -from future import standard_library -standard_library.install_aliases() from builtins import zip import urllib.parse diff --git a/www/conservancy/middleware.py b/www/conservancy/middleware.py index 7abbac7b..cafa5bc8 100644 --- a/www/conservancy/middleware.py +++ b/www/conservancy/middleware.py @@ -1,5 +1,4 @@ from builtins import object -from future.utils import raise_ from django import http from django.conf import settings 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]): 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')]