From 49ab756211d7f026ecc198fd0d1a08d8534e050f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 23 May 2024 09:17:00 +0200 Subject: [PATCH] attempt to django 4.2 --- .gitignore | 1 + requirementsdj4.2.txt | 220 +++++++++++++++++++++++++++++++++++ rowers/urls.py | 23 ++-- rowers/views/paymentviews.py | 4 +- rowers/views/statements.py | 2 +- rowsandall_app/settings.py | 12 +- 6 files changed, 245 insertions(+), 17 deletions(-) create mode 100644 requirementsdj4.2.txt diff --git a/.gitignore b/.gitignore index 7f7af7f0..031d78ef 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,5 @@ config.yaml /py2/ /py38/ /py39/ +/py39b/ /django2/ diff --git a/requirementsdj4.2.txt b/requirementsdj4.2.txt new file mode 100644 index 00000000..d2fcab82 --- /dev/null +++ b/requirementsdj4.2.txt @@ -0,0 +1,220 @@ +aiohttp==3.8.4 +aiosignal==1.3.1 +alabaster==0.7.13 +amqp==5.1.1 +arrow==1.2.3 +asgiref==3.7.2 +asttokens==2.2.1 +async-timeout==4.0.2 +attrs==23.1.0 +Babel==2.12.1 +backcall==0.2.0 +beautifulsoup4==4.12.2 +billiard==3.6.4.0 +bleach==6.0.0 +bokeh==3.1.1 +boto3==1.26.159 +botocore==1.29.159 +braintree==4.21.0 +celery==5.2.1 +certifi==2023.5.7 +cffi==1.15.1 +charset-normalizer==3.1.0 +click==8.1.3 +click-didyoumean==0.3.0 +click-plugins==1.1.1 +click-repl==0.2.0 +cloudpickle==2.2.1 +colorcet==3.0.1 +contourpy==1.0.7 +coreapi==2.3.3 +coreschema==0.0.4 +coverage==7.2.7 +cramjam==2.6.2 +cryptography==41.0.1 +cycler==0.11.0 +Cython==0.29.35 +dask==2023.5.1 +decorator==5.1.1 +Django==3.2.12 +django-analytical==2.5.0 +django-async-messages==0.3.1 +django-classy-tags==4.0.0 +django-cookie-law==2.0.1 +django-cors-headers==3.10.1 +django-countries==7.5.1 +django-datetime-widget2==0.9.5 +django-debug-toolbar==2.0 +django-leaflet==0.28.2 +django-oauth-toolkit==1.2.0 +django-oauth2-provider==0.2.6.1 +django-recaptcha==4.0.0 +django-rest-framework==0.1.0 +django-rest-swagger==2.2.0 +django-rq==2.5.1 +django-ses==2.0.0 +django-shell-plus==1.1.7 +django-social-share==1.3.2 +django-taggit==4.0.0 +django-tz-detect==0.2.9 +djangorestframework==3.14.0 +docopt==0.6.2 +docutils==0.20.1 +elementpath==4.3.0 +exceptiongroup==1.1.1 +execnet==2.1.1 +executing==1.2.0 +factory-boy==2.11.1 +Faker==18.10.0 +fastparquet==2023.4.0 +fitparse==1.2.0 +fonttools==4.39.4 +frozenlist==1.3.3 +fsspec==2023.5.0 +future==0.18.3 +geocoder==1.38.1 +geoip2==4.7.0 +greenlet==2.0.2 +grpcio==1.26.0 +gunicorn==21.2.0 +h3==3.7.6 +holoviews==1.16.0 +httplib2==0.22.0 +humanize==4.6.0 +icalendar==5.0.7 +idna==3.4 +imagesize==1.4.1 +importlib-metadata==6.6.0 +importlib-resources==5.12.0 +iniconfig==2.0.0 +ipython==8.14.0 +iso8601==1.1.0 +isodate==0.6.1 +itypes==1.2.0 +jaraco.classes==3.2.3 +jedi==0.18.2 +jeepney==0.8.0 +Jinja2==3.0.3 +jmespath==1.0.1 +jsmin==3.0.1 +keyring==23.13.1 +kiwisolver==1.4.4 +kombu==5.2.4 +linkify-it-py==2.0.2 +locket==1.0.0 +lxml==4.9.2 +Markdown==3.4.3 +markdown-it-py==2.2.0 +MarkupSafe==2.1.2 +matplotlib==3.7.1 +matplotlib-inline==0.1.6 +maxminddb==2.3.0 +mdit-py-plugins==0.3.5 +mdurl==0.1.2 +mock==5.0.2 +more-itertools==9.1.0 +mpld3==0.5.9 +multidict==6.0.4 +nose==1.3.7 +nose-parameterized==0.6.0 +numpy==1.24.3 +oauth2==1.9.0.post1 +oauth2_provider==0.0 +oauthlib==3.2.2 +openapi-codec==1.3.2 +packaging==23.1 +pandas==2.0.2 +panel==1.0.4 +param==1.13.0 +parso==0.8.3 +partd==1.4.0 +pathspec==0.11.1 +pendulum==2.1.2 +pexpect==4.8.0 +pickleshare==0.7.5 +Pillow==9.5.0 +Pint==0.22 +pkginfo==1.9.6 +pluggy==1.4.0 +polars==0.20.18 +prompt-toolkit==3.0.38 +protobuf==4.25.3 +ptyprocess==0.7.0 +pure-eval==0.2.2 +pyarrow==12.0.0 +pycairo==1.23.0 +pycparser==2.21 +pyct==0.5.0 +pydantic==1.10.8 +Pygments==2.15.1 +pyparsing==3.0.9 +pytest==8.1.1 +pytest-django==4.8.0 +pytest-runner==6.0.0 +pytest-xdist==3.5.0 +python-dateutil==2.8.2 +python-twitter==3.5 +pytz==2023.3 +pytzdata==2020.1 +pyviz-comms==2.3.0 +PyYAML==6.0 +ratelim==0.1.6 +readme-renderer==37.3 +redis==4.5.5 +requests==2.31.0 +requests-oauthlib==1.2.0 +requests-toolbelt==1.0.0 +rfc3986==2.0.0 +rich==13.4.1 +rowingdata==3.6.8 +rowingphysics==0.5.2 +rq==1.15.0 +rules==3.3 +ruptures==1.1.7 +s3transfer==0.6.1 +scipy==1.10.1 +SecretStorage==3.3.3 +shortuuid==1.0.11 +simplejson==3.19.1 +six==1.16.0 +snowballstemmer==2.2.0 +soupsieve==2.4.1 +Sphinx==7.0.1 +sphinxcontrib-applehelp==1.0.4 +sphinxcontrib-devhelp==1.0.2 +sphinxcontrib-htmlhelp==2.0.1 +sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-qthelp==1.0.3 +sphinxcontrib-serializinghtml==1.1.5 +SQLAlchemy==2.0.15 +sqlparse==0.4.4 +stack-data==0.6.2 +stravalib==1.3.0 +timezonefinder==6.2.0 +tk==0.1.0 +tomli==2.0.1 +toolz==0.12.0 +tornado==6.3.2 +tqdm==4.65.0 +traitlets==5.9.0 +trueskill==0.4.5 +twine==4.0.2 +types-python-dateutil==2.9.0.20240316 +typing_extensions==4.6.3 +tzdata==2023.3 +uc-micro-py==1.0.2 +uritemplate==4.1.1 +urllib3==1.26.16 +uWSGI==2.0.24 +VerbalExpressions==0.0.2 +vine==5.0.0 +wcwidth==0.2.6 +webencodings==0.5.1 +Werkzeug==2.3.4 +xmlschema==3.0.2 +xmltodict==0.13.0 +xyzservices==2023.5.0 +yamjam==0.1.7 +yamllint==1.32.0 +yarl==1.9.2 +zipp==3.15.0 diff --git a/rowers/urls.py b/rowers/urls.py index a17520b9..cb040753 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -1,6 +1,6 @@ -from oauth2_provider.views import base +#from oauth2_provider.views import base from django.conf import settings -from django.conf.urls import url, include, handler404, handler500 +from django.conf.urls import include, handler404, handler500 from django.urls import path, re_path from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required, permission_required @@ -42,14 +42,14 @@ from rowers.forms import ForceCurveMultipleCompareForm from rowers.models import ForceCurveAnalysis from rowers.interactiveplots import forcecurve_multi_interactive_chart, instroke_multi_interactive_chart -from oauth2_provider.views import ( - AuthorizedTokensListView, - AuthorizedTokenDeleteView, -) +#from oauth2_provider.views import ( +# AuthorizedTokensListView, +# AuthorizedTokenDeleteView, +#) -from oauth2_provider.views.base import ( - RevokeTokenView -) +#from oauth2_provider.views.base import ( +# RevokeTokenView +#) class PlannedSessionViewSet(viewsets.ModelViewSet): @@ -237,8 +237,9 @@ handler500 = views.error500_view urlpatterns = [ - re_path(r'^o/authorize/$', base.AuthorizationView.as_view(), name="authorize"), - re_path(r'^o/token/$', base.TokenView.as_view(), name="token"), + re_path(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')), +# re_path(r'^o/authorize/$', base.AuthorizationView.as_view(), name="authorize"), +# re_path(r'^o/token/$', base.TokenView.as_view(), name="token"), re_path(r'^', include(router.urls)), re_path(r'^api-docs/$', views.schema_view, name='schema_view'), re_path(r'^api-auth/', include('rest_framework.urls', diff --git a/rowers/views/paymentviews.py b/rowers/views/paymentviews.py index c3fcf5ac..db8ea50e 100644 --- a/rowers/views/paymentviews.py +++ b/rowers/views/paymentviews.py @@ -1,4 +1,4 @@ -from django.utils.encoding import force_bytes, force_text +from django.utils.encoding import force_bytes, force_str from rowers.tokens import account_activation_token from django.contrib.sites.shortcuts import get_current_site from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode @@ -782,7 +782,7 @@ def downgrade_completed_view(request): def useractivate(request, uidb64, token): # pragma: no cover try: - uid = force_text(urlsafe_base64_decode(uidb64)) + uid = force_str(urlsafe_base64_decode(uidb64)) user = User.objects.get(id=uid) except(TypeError, ValueError, OverflowError, User.DoesNotExist): user = None diff --git a/rowers/views/statements.py b/rowers/views/statements.py index fd7c2d99..4e9f852b 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -298,7 +298,7 @@ import stravalib from stravalib.exc import ActivityUploadFailed, TimeoutExceeded from rowers.weather import get_wind_data, get_airport_code, get_metar_data -from oauth2_provider.models import Application, Grant, AccessToken +# from oauth2_provider.models import Application, Grant, AccessToken import django_rq queue = django_rq.get_queue('default') diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 757c540e..40572359 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -71,7 +71,9 @@ INSTALLED_APPS = [ 'rest_framework', 'datetimewidget', 'rest_framework_swagger', - 'oauth2_provider', + # 'oauth2_provider', + 'provider', + 'provider.oauth2', 'corsheaders', 'analytical', 'cookielaw', @@ -86,10 +88,12 @@ INSTALLED_APPS = [ ] AUTHENTICATION_BACKENDS = ( - 'oauth2_provider.backends.OAuth2Backend', + #'oauth2_provider.backends.OAuth2Backend', # Uncomment following if you want to access the admin 'rules.permissions.ObjectPermissionBackend', 'django.contrib.auth.backends.ModelBackend', + 'django.contrib.auth.backends.ModelBackend', + 'django.contrib.auth.backends.RemoteUserBackend', ) MIDDLEWARE = [ @@ -105,7 +109,9 @@ MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'oauth2_provider.middleware.OAuth2TokenMiddleware', + # 'oauth2_provider.middleware.OAuth2TokenMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'provider.oauth2.middleware.Oauth2UserMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'tz_detect.middleware.TimezoneMiddleware',