Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7637] django upgrade to 4.2 #2552

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion adhocracy-plus/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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
9 changes: 8 additions & 1 deletion adhocracy-plus/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

DEBUG = False

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}

try:
from .local import *
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 @@ -89,30 +89,30 @@
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"),
path(
"ckeditor5/image_upload/",
user_is_project_admin(ckeditor5_views.upload_file),
name="ck_editor_5_upload_file",
),
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 @@ -212,6 +212,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"
6 changes: 4 additions & 2 deletions apps/activities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ class Activity(module_models.Item):
def get_absolute_url(self):
return self.project.get_absolute_url()

def save(self, *args, **kwargs):
def save(self, update_fields=None, *args, **kwargs):
self.description = html_transforms.clean_html_field(
self.description, "collapsible-image-editor"
)
super().save(*args, **kwargs)
if update_fields:
update_fields = {"description"}.union(update_fields)
super().save(update_fields=update_fields, *args, **kwargs)
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.0 on 2024-02-07 14:42

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("a4modules", "0008_alter_module_blueprint_type"),
("a4labels", "0003_labelalias"),
("a4_candy_budgeting", "0003_alter_proposal_description"),
]

operations = [
migrations.AlterField(
model_name="proposal",
name="item_ptr",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
related_name="%(app_label)s_%(class)s",
serialize=False,
to="a4modules.item",
),
),
migrations.AlterField(
model_name="proposal",
name="labels",
field=models.ManyToManyField(
related_name="%(app_label)s_%(class)s_label",
to="a4labels.Label",
verbose_name="Labels",
),
),
]
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"
23 changes: 23 additions & 0 deletions apps/cms/images/migrations/0004_alter_customrendition_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2 on 2024-04-09 15:17

from django.db import migrations
import wagtail.images.models


class Migration(migrations.Migration):
dependencies = [
("a4_candy_cms_images", "0003_auto_20240208_1216"),
]

operations = [
migrations.AlterField(
model_name="customrendition",
name="file",
field=wagtail.images.models.WagtailImageField(
height_field="height",
storage=wagtail.images.models.get_rendition_storage,
upload_to=wagtail.images.models.get_rendition_upload_to,
width_field="width",
),
),
]
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
4 changes: 2 additions & 2 deletions apps/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ModuleDeleteView(mixins.DashboardBaseMixin, generic.DeleteView):
model = module_models.Module
success_message = _("The module has been deleted")

def delete(self, request, *args, **kwargs):
def form_valid(self, request, *args, **kwargs):
if not self.get_object().is_draft:
messages.error(
self.request,
Expand All @@ -214,7 +214,7 @@ def delete(self, request, *args, **kwargs):
failure_url = self.get_failure_url()
return HttpResponseRedirect(failure_url)
messages.success(self.request, self.success_message)
return super().delete(request, *args, **kwargs)
return super().form_valid(request, *args, **kwargs)

def get_permission_object(self):
return self.get_object().project
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"
10 changes: 6 additions & 4 deletions apps/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def next(self):
class Paragraph(base.TimeStampedModel):
name = models.CharField(max_length=120, blank=True)
text = CKEditor5Field(
config_name="image-editor", validators=[ImageAltTextValidator()]
)
config_name="image-editor", validators=[ImageAltTextValidator()]
)

weight = models.PositiveIntegerField()
chapter = models.ForeignKey(
Expand All @@ -78,9 +78,11 @@ class Meta:
def __str__(self):
return "{}_paragraph_{}".format(str(self.chapter), self.weight)

def save(self, *args, **kwargs):
def save(self, update_fields=None, *args, **kwargs):
self.text = transforms.clean_html_field(self.text, "image-editor")
super().save(*args, **kwargs)
if update_fields:
update_fields = {"text"}.union(update_fields)
super().save(update_fields=update_fields, *args, **kwargs)

def get_absolute_url(self):
return reverse(
Expand Down
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.0 on 2024-02-07 14:42

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("a4modules", "0008_alter_module_blueprint_type"),
("a4labels", "0003_labelalias"),
("a4_candy_ideas", "0003_alter_idea_description"),
]

operations = [
migrations.AlterField(
model_name="idea",
name="item_ptr",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
related_name="%(app_label)s_%(class)s",
serialize=False,
to="a4modules.item",
),
),
migrations.AlterField(
model_name="idea",
name="labels",
field=models.ManyToManyField(
related_name="%(app_label)s_%(class)s_label",
to="a4labels.Label",
verbose_name="Labels",
),
),
]
6 changes: 4 additions & 2 deletions apps/ideas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ class Meta:
def __str__(self):
return self.name

def save(self, *args, **kwargs):
def save(self, update_fields=None, *args, **kwargs):
self.description = transforms.clean_html_field(self.description)
super().save(*args, **kwargs)
if update_fields:
update_fields = {"description"}.union(update_fields)
super().save(update_fields=update_fields, *args, **kwargs)


class Idea(AbstractIdea):
Expand Down
4 changes: 2 additions & 2 deletions apps/ideas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ def get_success_url(self):
},
)

def delete(self, request, *args, **kwargs):
def form_valid(self, request, *args, **kwargs):
messages.success(self.request, self.success_message)
return super(AbstractIdeaDeleteView, self).delete(request, *args, **kwargs)
return super(AbstractIdeaDeleteView, self).form_valid(request, *args, **kwargs)


class IdeaDeleteView(AbstractIdeaDeleteView):
Expand Down
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"
6 changes: 4 additions & 2 deletions apps/interactiveevents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class ExtraFieldsInteractiveEvent(module_models.Item):
blank=True,
)

def save(self, *args, **kwargs):
def save(self, update_fields=None, *args, **kwargs):
self.live_stream = transforms.clean_html_field(self.live_stream, "video-editor")
super().save(*args, **kwargs)
if update_fields:
update_fields = {"live_stream"}.union(update_fields)
super().save(update_fields=update_fields, *args, **kwargs)
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.0 on 2024-02-07 14:42

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("a4modules", "0008_alter_module_blueprint_type"),
("a4labels", "0003_labelalias"),
("a4_candy_mapideas", "0003_alter_mapidea_description"),
]

operations = [
migrations.AlterField(
model_name="mapidea",
name="item_ptr",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
related_name="%(app_label)s_%(class)s",
serialize=False,
to="a4modules.item",
),
),
migrations.AlterField(
model_name="mapidea",
name="labels",
field=models.ManyToManyField(
related_name="%(app_label)s_%(class)s_label",
to="a4labels.Label",
verbose_name="Labels",
),
),
]
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"
6 changes: 4 additions & 2 deletions apps/moderatorfeedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class ModeratorFeedback(UserGeneratedContentModel):
verbose_name=_("Official feedback"),
)

def save(self, *args, **kwargs):
def save(self, update_fields=None, *args, **kwargs):
self.feedback_text = transforms.clean_html_field(self.feedback_text)
super().save(*args, **kwargs)
if update_fields:
update_fields = {"feedback_text"}.union(update_fields)
super().save(update_fields=update_fields, *args, **kwargs)


class Moderateable(models.Model):
Expand Down
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"
Loading
Loading