From 60010999d25f871b70a8fbee4337edae2ebec32b 2023-09-07 12:59:23 From: Ben Sturmfels Date: 2023-09-07 12:59:23 Subject: [PATCH] Remove use of python3-future --- diff --git a/README.md b/README.md index 6c5f56276a60e6474ff1320015f473cab838fe6c..85a1b581dcdd9cfef9fe70acb28ebd40d6bb4f9b 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 4a8dd7468b2757cab3d6287d1333d14c77dfa28f..e91a7bab0951129dfd27a421510c9fe6264cdfa3 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 dba7ab716b934932260d77d0feb544b890c43668..1a64ad37c44a5aa12e40cde924561e2a11276270 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 d43777fb6c7eea3831eaa6aa1b664ab469e6b39a..17d109f168b86c83ee7493a1dd625eabbca7634b 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 8946f37497d87689027e968a6bd44708198539c5..94b92771dff4ff497fe937f5d049b13b29ae12a3 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 cd1d76b32cab98d5f9b2a84f8bc70a6a9f0714ad..c516a86e6c941aaaa60f2bc5f907596648866b29 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 e36fbee54f3726f30907195a442ab525c3ec90d1..e35605ee55e1c567df4fb8cb9581033d68ddb571 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 7abbac7b632766237c9ed2c6166248a8fca9c853..cafa5bc8086faa8d574ae330bfc1b06fc61d665f 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')]