Replace deprecated PlaceholderField
This commit is contained in:
parent
398eef9120
commit
374f6f762e
3 changed files with 27 additions and 8 deletions
|
|
@ -1,5 +1,4 @@
|
|||
from adminsortable2.admin import SortableAdminMixin
|
||||
from cms.admin.placeholderadmin import PlaceholderAdminMixin
|
||||
from django.contrib import admin, auth
|
||||
from django.contrib.auth.models import Group
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
|
|
@ -330,9 +329,7 @@ class GovernmentPlanUpdateAdmin(admin.ModelAdmin):
|
|||
return super().has_change_permission(request, obj=obj)
|
||||
|
||||
|
||||
class GovernmentPlanSectionAdmin(
|
||||
SortableAdminMixin, PlaceholderAdminMixin, admin.ModelAdmin
|
||||
):
|
||||
class GovernmentPlanSectionAdmin(SortableAdminMixin, admin.ModelAdmin):
|
||||
save_on_top = True
|
||||
prepopulated_fields = {"slug": ("title",)}
|
||||
search_fields = ("title",)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
# Generated by Django 5.2.1 on 2025-05-24 05:52
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("froide_govplan", "0013_government_active"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="governmentplansection",
|
||||
name="content_placeholder",
|
||||
),
|
||||
]
|
||||
|
|
@ -9,6 +9,7 @@ from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
|
|||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from filer.fields.image import FilerImageField
|
||||
from froide.follow.models import Follower
|
||||
|
|
@ -22,11 +23,12 @@ from . import conf
|
|||
from .utils import make_request_url
|
||||
|
||||
try:
|
||||
from cms.models.fields import PlaceholderField
|
||||
from cms.models.fields import PlaceholderRelationField
|
||||
from cms.utils.placeholder import get_placeholder_from_slot
|
||||
from cms.models.pluginmodel import CMSPlugin
|
||||
except ImportError:
|
||||
CMSPlugin = None
|
||||
PlaceholderField = None
|
||||
PlaceholderRelationField = None
|
||||
|
||||
|
||||
if conf.GOVPLAN_ENABLE_FOIREQUEST:
|
||||
|
|
@ -453,8 +455,8 @@ class GovernmentPlanSection(models.Model):
|
|||
order = models.PositiveIntegerField(default=0)
|
||||
featured = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
if PlaceholderField:
|
||||
content_placeholder = PlaceholderField("content")
|
||||
if PlaceholderRelationField:
|
||||
placeholders = PlaceholderRelationField()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Government plan section")
|
||||
|
|
@ -476,6 +478,10 @@ class GovernmentPlanSection(models.Model):
|
|||
def get_absolute_domain_url(self):
|
||||
return settings.SITE_URL + self.get_absolute_url()
|
||||
|
||||
@cached_property
|
||||
def content_placeholder(self):
|
||||
return get_placeholder_from_slot(self.placeholders, "content")
|
||||
|
||||
def get_plans(self, queryset=None):
|
||||
if queryset is None:
|
||||
queryset = GovernmentPlan.objects.filter(public=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue