Skip to content

Commit

Permalink
deps: django upgrade to 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ra committed Feb 6, 2024
1 parent 4bfd476 commit 35eb721
Show file tree
Hide file tree
Showing 42 changed files with 40 additions and 66 deletions.
1 change: 0 additions & 1 deletion adhocracy-plus/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand Down
2 changes: 1 addition & 1 deletion adhocracy-plus/config/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if os.getenv("DATABASE") == "postgresql":
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": "django.db.backends.postgresql",
"NAME": "django",
"USER": "django",
"PASSWORD": "",
Expand Down
2 changes: 1 addition & 1 deletion adhocracy-plus/config/settings/travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": "django.db.backends.postgresql",
"USER": "postgres",
"NAME": "django",
"TEST": {"NAME": "django_test"},
Expand Down
36 changes: 18 additions & 18 deletions adhocracy-plus/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@
urlpatterns = [
# General platform urls
re_path(r"^django-admin/", admin.site.urls),
re_path(r"^admin/", include("wagtail.admin.urls")),
re_path(r"^documents/", include(wagtaildocs_urls)),
re_path(r"^accounts/", include("allauth.urls")),
re_path(r"^account/", include("apps.account.urls")),
re_path(r"^profile/", include("apps.users.urls")),
re_path(r"^userdashboard/", include("apps.userdashboard.urls")),
re_path(r"^i18n/", include(i18n)),
path("admin/", include("wagtail.admin.urls")),
path("documents/", include(wagtaildocs_urls)),
path("accounts/", include("allauth.urls")),
path("account/", include("apps.account.urls")),
path("profile/", include("apps.users.urls")),
path("userdashboard/", include("apps.userdashboard.urls")),
path("i18n/", include(i18n)),
# API urls
re_path(r"^api/", include(ct_router.urls)),
re_path(r"^api/", include(module_router.urls)),
re_path(r"^api/", include(orga_router.urls)),
re_path(r"^api/", include(likes_router.urls)),
re_path(r"^api/", include(comment_router.urls)),
re_path(r"^api/", include(moderation_router.urls)),
re_path(r"^api/", include(router.urls)),
path("api/", include(ct_router.urls)),
path("api/", include(module_router.urls)),
path("api/", include(orga_router.urls)),
path("api/", include(likes_router.urls)),
path("api/", include(comment_router.urls)),
path("api/", include(moderation_router.urls)),
path("api/", include(router.urls)),
re_path(r"^api/login", obtain_auth_token, name="api-login"),
re_path(r"^api/account/", AccountViewSet.as_view(), name="api-account"),
re_path(
Expand All @@ -115,8 +115,8 @@
never_cache(user_is_project_admin(ck_views.browse)),
name="ckeditor_browse",
),
re_path(r"^components/$", contrib_views.ComponentLibraryView.as_view()),
re_path(r"^jsi18n/$", JavaScriptCatalog.as_view(), name="javascript-catalog"),
path("components/", contrib_views.ComponentLibraryView.as_view()),
path("jsi18n/", JavaScriptCatalog.as_view(), name="javascript-catalog"),
re_path(
r"^(?P<organisation_slug>[-\w_]+)/",
include(
Expand Down Expand Up @@ -216,6 +216,6 @@

# generic patterns at the very end
urlpatterns += [
re_path(r"", include("apps.organisations.urls")),
re_path(r"", include("wagtail.urls")),
path("", include("apps.organisations.urls")),
path("", include("wagtail.urls")),
]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% else %}
<nav class="d-inline-block d-sm-none" aria-label="{% trans 'Dashboard' %}">
<a href="{% url 'userdashboard-overview' %}"
class="tab {% ifequal view.menu_item 'overview' %}active{% endifequal %}">
class="tab {% if view.menu_item == 'overview' %}active{% endif %}">

{% trans 'Overview' %}
</a>
Expand Down
1 change: 0 additions & 1 deletion apps/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.account.apps.Config"
1 change: 0 additions & 1 deletion apps/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.actions.apps.Config"
1 change: 0 additions & 1 deletion apps/activities/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.activities.apps.Config"
1 change: 0 additions & 1 deletion apps/budgeting/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.budgeting.apps.Config"
1 change: 0 additions & 1 deletion apps/captcha/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.captcha.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/contacts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.contacts.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/images/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.images.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/news/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.news.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/pages/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.pages.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.settings.apps.Config"
1 change: 0 additions & 1 deletion apps/cms/use_cases/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.cms.use_cases.apps.Config"
1 change: 0 additions & 1 deletion apps/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.contrib.apps.Config"
2 changes: 0 additions & 2 deletions apps/dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from adhocracy4.dashboard import ProjectDashboard
from adhocracy4.dashboard import components

default_app_config = "apps.dashboard.apps.Config"


class TypedProjectDashboard(ProjectDashboard):
def get_project_components(self):
Expand Down
1 change: 0 additions & 1 deletion apps/debate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.debate.apps.Config"
1 change: 0 additions & 1 deletion apps/documents/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.documents.apps.Config"
1 change: 0 additions & 1 deletion apps/exports/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.exports.apps.Config"
1 change: 0 additions & 1 deletion apps/ideas/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.ideas.apps.Config"
1 change: 0 additions & 1 deletion apps/interactiveevents/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.interactiveevents.apps.Config"
1 change: 0 additions & 1 deletion apps/mapideas/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.mapideas.apps.Config"
1 change: 0 additions & 1 deletion apps/maps/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.maps.apps.Config"
1 change: 0 additions & 1 deletion apps/moderatorfeedback/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.moderatorfeedback.apps.Config"
1 change: 0 additions & 1 deletion apps/moderatorremark/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.moderatorremark.apps.Config"
1 change: 0 additions & 1 deletion apps/newsletters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.newsletters.apps.Config"
1 change: 0 additions & 1 deletion apps/notifications/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.notifications.apps.Config"
1 change: 0 additions & 1 deletion apps/offlineevents/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.offlineevents.apps.Config"
1 change: 0 additions & 1 deletion apps/organisations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.organisations.apps.Config"
1 change: 0 additions & 1 deletion apps/polls/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.polls.apps.Config"
1 change: 0 additions & 1 deletion apps/projects/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.projects.apps.Config"
8 changes: 2 additions & 6 deletions apps/projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
from adhocracy4.projects.admin import ProjectAdminForm


@admin.action(description=_("archive"))
def set_is_archived_true(modeladmin, request, queryset):
queryset.update(is_archived=True)


set_is_archived_true.short_description = _("archive")


@admin.action(description=_("dearchive"))
def set_is_archived_false(modeladmin, request, queryset):
queryset.update(is_archived=False)


set_is_archived_false.short_description = _("dearchive")


class ProjectAdmin(admin.ModelAdmin):
form = ProjectAdminForm
list_display = ("__str__", "organisation", "is_draft", "is_archived", "created")
Expand Down
1 change: 0 additions & 1 deletion apps/topicprio/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "apps.topicprio.apps.Config"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="container">
<nav class="d-none d-sm-inline-block" aria-label="{% trans 'My dashboard' %}">
<a href="{% url 'userdashboard-overview' %}"
class="tab {% ifequal view.menu_item 'overview' %}active{% endifequal %}">
class="tab {% if view.menu_item == 'overview' %}active{% endif %}">

{% trans 'Overview' %}
</a>
Expand Down
2 changes: 0 additions & 2 deletions apps/users/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.contrib.auth.signals import user_logged_in
from django.utils.translation import gettext_lazy as _

default_app_config = "apps.users.apps.Config"

USERNAME_REGEX = r"^[\w]+[ \w.@+-]*$"
USERNAME_INVALID_MESSAGE = _(
"Enter a valid username. This value may contain "
Expand Down
10 changes: 10 additions & 0 deletions changelog/7637.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Upgraded

- Django from 3.2.20 to 4.0
- remove app label from `__init__.py` inside app directories
- replace `re_path` with `path` for included urls.
- remove `USE_L10N` in settings as it is now True by default
- replace `postgresql_psycopg2` with `postgresql` in DATABASE settings
- set admin fields description as decorators in ProjectAdminForm
- update a4 hash pointing to commit with django upgrade 4.0
- replace deprecated `ifequal` with `if .. == ..` expression
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "5.15.4",
"@maplibre/maplibre-gl-leaflet": "0.0.19",
"adhocracy4": "git+https://github.com/liqd/adhocracy4#7378cb6f161a79e5dd9b1d685b62502614fcd35f",
"adhocracy4": "git+https://github.com/liqd/adhocracy4#4bb259f6b7138d69343017a27cfbc4cd93424414",
"autoprefixer": "10.4.14",
"bootstrap": "5.2.3",
"css-loader": "6.8.1",
Expand Down
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A4
git+https://github.com/liqd/adhocracy4.git@7378cb6f161a79e5dd9b1d685b62502614fcd35f#egg=adhocracy4
git+https://github.com/liqd/adhocracy4.git@4bb259f6b7138d69343017a27cfbc4cd93424414#egg=adhocracy4

# Additional requirements
brotli==1.0.9
Expand All @@ -15,7 +15,7 @@ urllib3==2.0.3
redis==5.0.0

# Inherited a4-core requirements
Django==3.2.19
Django== 4.0
django-allauth==0.54.0
git+https://github.com/liqd/django-autoslug.git@liqd2212#egg=django-autoslug
django-ckeditor==6.5.1
Expand Down
3 changes: 2 additions & 1 deletion tests/projects/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timezone

import pytest
from dateutil.parser import parse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from freezegun import freeze_time

Expand Down
2 changes: 1 addition & 1 deletion tests/userdashboard/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import timedelta
from datetime import timezone

import pytest
from django.urls import reverse
from django.utils import timezone
from freezegun import freeze_time

from apps.contrib import dates
Expand Down

0 comments on commit 35eb721

Please sign in to comment.