Skip to content

Commit c1fcbe7

Browse files
Upgrade to Django4
1 parent f5666e8 commit c1fcbe7

File tree

137 files changed

+842
-836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+842
-836
lines changed

TODO.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[] Check if Solr usermame/password passing is working
2+
[] Check if email sending is working
3+
[] Adjust buttons layout

docker/docker-compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
# build:
3838
# context: ../
3939
# dockerfile: ./docker/Dockerfile
40-
container_name: sapl
40+
# container_name: sapl
4141
labels:
4242
NAME: "sapl"
4343
restart: always
@@ -53,7 +53,9 @@ services:
5353
EMAIL_HOST_PASSWORD: senhasmtp
5454
USE_SOLR: 'True'
5555
SOLR_COLLECTION: sapl
56-
SOLR_URL: http://solr:solr@saplsolr:8983
56+
SOLR_URL: http://saplsolr:8983
57+
SOLR_USER: solr
58+
SOLR_PASSWORD: solr
5759
IS_ZK_EMBEDDED: 'True'
5860
ENABLE_SAPN: 'False'
5961
TZ: America/Sao_Paulo

drfautoapi/drfautoapi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from django.db.models.fields.files import FileField
1616
from django.db.models.fields.related import ManyToManyField
1717
from django.template.defaultfilters import capfirst
18-
from django.utils.translation import ugettext_lazy as _
18+
from django.utils.translation import gettext_lazy as _
1919
from django.urls import reverse
2020
from django_filters.constants import ALL_FIELDS, EMPTY_VALUES
2121
from django_filters.fields import ModelMultipleChoiceField
@@ -259,9 +259,11 @@ def import_modules(cls, modules):
259259
def router(cls, router_class = DefaultRouter):
260260
router = router_class()
261261
for app, built_sets in cls._built_sets.items():
262+
app_label = getattr(app, "label", app.name.split(".")[-1])
262263
for model, viewset in built_sets.items():
263264
router.register(
264-
f'{app.label}/{model._meta.model_name}', viewset)
265+
f'{app.label}/{model._meta.model_name}', viewset,
266+
basename=f"{app_label}-{model._meta.model_name}")
265267
return router
266268

267269
@classmethod

requirements/dev-requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
autopep8==2.3.2
44
beautifulsoup4==4.13.5
5-
django-debug-toolbar==3.2.4
5+
django-debug-toolbar==4.4.0
66
ipdb==0.13.13
77
fancycompleter==0.11.1
88
pdbpp==0.11.7
99
pip-review==1.3.0
1010
pipdeptree==2.28.0
11+
# Keep this matched to your IDE build (see note below)
1112
pydevd-pycharm~=203.7148.7
13+

requirements/requirements.txt

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
django==2.2.28
2-
django-haystack==3.1.1
3-
django-filter==2.4.0
4-
djangorestframework==3.12.4
5-
django-braces==1.14.0
6-
django-crispy-forms==1.7.2
7-
django-contrib-postgres==0.0.1
8-
django-extra-views==0.12.0
9-
django-model-utils==3.1.2
10-
django-extensions==2.1.4
11-
django-image-cropping==1.2
12-
django-waffle==3.0.0
13-
django-webpack-loader==1.6.0
14-
drf-spectacular==0.18.2
1+
# Core
2+
Django==4.2.24
3+
4+
# Search / API / Forms
5+
django-haystack==3.3.0
6+
django-filter==24.3
7+
djangorestframework==3.15.2
8+
drf-spectacular==0.28.0
9+
django-crispy-forms==2.4
10+
crispy-bootstrap4==2024.1
11+
12+
# DB / utils
13+
dj-database-url==3.1.2
14+
django-braces==1.17.0
15+
django-extra-views==0.16.0
16+
django-model-utils==4.3.1
17+
django-extensions==3.2.3
1518
django-ratelimit==3.0.1
16-
easy-thumbnails==2.8.5
19+
easy-thumbnails==2.9.0
20+
21+
# Images / files / PDF
22+
django-image-cropping==1.7.0
23+
Pillow==10.3.0
24+
trml2pdf==0.6
25+
weasyprint==66.0
26+
PyPDF4==1.27.0
27+
rlPyCairo==0.4.0
28+
29+
# Frontend integration
30+
django-webpack-loader==1.6.0 # (works; keep unless you’re moving to webpack5 forks)
31+
32+
# Feature flags / misc
33+
django-waffle==4.1.0
34+
whitenoise==6.9.0
35+
36+
# Monitoring
37+
django-prometheus==2.4.1
38+
39+
# Other deps from your list (unchanged unless you want to bump)
1740
python-decouple==3.1
18-
dj-database-url==0.5.0
1941
psycopg2-binary==2.9.9
2042
pyyaml==6.0.1
21-
pytz==2019.3
43+
# pytz is no longer required by Django; keep only if YOU use it directly:
44+
# pytz==2024.1
2245
python-magic==0.4.15
2346
unipath==1.1
24-
Pillow==10.3.0
25-
reportlab==3.6.13
26-
WeasyPrint==66
27-
trml2pdf==0.6
28-
gunicorn==23.0.0
47+
gunicorn==22.0.0
2948
more-itertools==8.2.0
3049
pysolr==3.6.0
31-
PyPDF4==1.27.0
32-
#pyoai==2.5.1
33-
git+https://github.com/infrae/pyoai@5ff2f15e869869e70d8139e4c37b7832854d7049
3450
Unidecode==1.1.1
35-
whitenoise==5.1.0
36-
kazoo==2.8.0
37-
django-prometheus==2.2.0
38-
3951
asn1crypto==1.5.1
4052
XlsxWriter==3.2.0
4153

42-
setuptools==80.9.0
43-
54+
# Custom / VCS deps you already use
55+
git+https://github.com/infrae/pyoai@5ff2f15e869869e70d8139e4c37b7832854d7049
4456
git+https://github.com/interlegis/django-admin-bootstrapped
57+
58+
# REMOVE this old backport package completely (Django ships postgres contrib):
59+
# django-contrib-postgres==0.0.1

requirements/test-requirements.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
-r requirements.txt
2-
coverage==7.6.1
3-
django-webtest==1.9.8
4-
flake8==7.1.1
5-
isort==5.13.2
6-
model-bakery==1.5.0
7-
pycodestyle==2.12.1
8-
pytest==8.3.3
9-
pytest-cov==5.0.0
10-
WebTest==3.0.6
2+
3+
# --- test/dev tools for Django 3.2 (Python 3.9) ---
4+
coverage==7.10.5
5+
django-webtest==1.9.12 # 1.9.13+ drops Django 3.x
6+
flake8==7.3.0
7+
isort==6.0.1
8+
model-bakery==1.17.0 # 1.18+ requires Django >=4.2
9+
pycodestyle==2.14.0 # replacement for deprecated "pep8"
10+
pytest==8.4.1
11+
pytest-cov==6.0.0
12+
pytest-django==4.8.0 # 4.9.0+ drops Django 3.2
13+
webtest==3.0.6
14+

sapl/api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'sapl.api.apps.AppConfig'

sapl/api/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django import apps
2-
from django.utils.translation import ugettext_lazy as _
2+
from django.utils.translation import gettext_lazy as _
33

44

55
class AppConfig(apps.AppConfig):

sapl/api/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.db.models import Q
44
from django.utils import timezone
5-
from django.utils.translation import ugettext_lazy as _
5+
from django.utils.translation import gettext_lazy as _
66
from django_filters.filters import CharFilter, DateFilter, ModelChoiceFilter
77
from django_filters.filterset import FilterSet
88
from rest_framework import serializers

sapl/api/urls.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from django.conf.urls import include, url
1+
2+
from django.urls import include, path, re_path
23
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView, \
34
SpectacularRedocView
45
from rest_framework.authtoken.views import obtain_auth_token
56

67
from sapl.api.deprecated import SessaoPlenariaViewSet
7-
from sapl.api.views import recria_token, SaplApiViewSetConstrutor
8+
from sapl.api.views import recria_token,\
9+
SaplApiViewSetConstrutor
810

911
from .apps import AppConfig
10-
from .views_health import HealthzView, ReadyzView
12+
1113

1214
app_name = AppConfig.name
1315

@@ -23,19 +25,19 @@
2325
urlpatterns_router = router.urls
2426

2527
urlpatterns_api_doc = [
26-
url('^schema/swagger-ui/',
28+
re_path('^schema/swagger-ui/',
2729
SpectacularSwaggerView.as_view(url_name='sapl.api:schema_api'),
2830
name='swagger_ui_schema_api'),
29-
url('^schema/redoc/',
31+
re_path('^schema/redoc/',
3032
SpectacularRedocView.as_view(url_name='sapl.api:schema_api'),
3133
name='redoc_schema_api'),
32-
url('^schema/', SpectacularAPIView.as_view(), name='schema_api'),
34+
re_path('^schema/', SpectacularAPIView.as_view(), name='schema_api'),
3335
]
3436

3537
urlpatterns = [
36-
url(r'^api/', include(urlpatterns_api_doc)),
37-
url(r'^api/', include(urlpatterns_router)),
38+
path('api/', include(urlpatterns_api_doc)),
39+
path('api/', include(urlpatterns_router)),
3840

39-
url(r'^api/auth/token$', obtain_auth_token),
40-
url(r'^api/recriar-token/(?P<pk>\d*)$', recria_token, name="recria_token"),
41+
path('api/auth/token', obtain_auth_token),
42+
re_path(r'^api/recriar-token/(?P<pk>\d*)$', recria_token, name="recria_token"),
4143
]

0 commit comments

Comments
 (0)