Skip to content

Commit

Permalink
Rendre le champ poids des pages CMS éditable (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienheureux authored Jan 15, 2025
1 parent d0216d3 commit 1fa1701
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
6 changes: 1 addition & 5 deletions qfdmd/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,4 @@ class SynonymeAdmin(

@admin.register(CMSPage)
class CMSPageAdmin(admin.ModelAdmin):
@property
def readonly_fields(self):
fields = [field.name for field in self.model._meta.get_fields()]
fields.remove("id")
return fields
readonly_fields = ["body", "search_description", "seo_title", "title", "slug"]
21 changes: 21 additions & 0 deletions qfdmd/migrations/0032_alter_cmspage_poids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.1.4 on 2025-01-15 11:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("qfdmd", "0031_merge_20250114_1728"),
]

operations = [
migrations.AlterField(
model_name="cmspage",
name="poids",
field=models.IntegerField(
default=0,
help_text="Ce champ détermine la position d'un élément dans la liste affichée.<br>Les éléments avec un poids plus élevé apparaissent plus bas dans la liste.<br>Les éléments avec un poids plus faible apparaissent plus haut.",
),
),
]
10 changes: 9 additions & 1 deletion qfdmd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,15 @@ class CMSPage(models.Model):
seo_title = models.CharField(default="")
title = models.CharField(default="")
slug = models.CharField(default="")
poids = models.IntegerField(default=0)
poids = models.IntegerField(
default=0,
help_text=(
"Ce champ détermine la position d'un élément dans la liste affichée.<br>"
"Les éléments avec un poids plus élevé apparaissent plus bas dans "
"la liste.<br>"
"Les éléments avec un poids plus faible apparaissent plus haut."
),
)

def __str__(self):
return self.title
Expand Down

0 comments on commit 1fa1701

Please sign in to comment.