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

CMS : ajouter historique aux fiches actions #4436

Merged
merged 1 commit into from
Sep 13, 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
28 changes: 28 additions & 0 deletions data/migrations/0153_wasteaction_latest_revision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.8 on 2024-09-12 08:51

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


class Migration(migrations.Migration):

dependencies = [
("data", "0152_wasteaction"),
("wagtailcore", "0093_uploadedfile"),
]

operations = [
migrations.AddField(
model_name="wasteaction",
name="latest_revision",
field=models.ForeignKey(
blank=True,
editable=False,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailcore.revision",
verbose_name="latest revision",
),
),
]
11 changes: 10 additions & 1 deletion data/models/wasteaction.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.db import models
from data.fields import ChoiceArrayField
from ckeditor.fields import RichTextField
from wagtail.models import RevisionMixin
from django.contrib.contenttypes.fields import GenericRelation


class WasteAction(models.Model):
class WasteAction(RevisionMixin, models.Model):
class Meta:
verbose_name = "Action anti-gaspi"
verbose_name_plural = "Actions anti-gaspi"
Expand Down Expand Up @@ -38,6 +40,13 @@ class WasteOrigin(models.TextChoices):
"wagtailimages.Image", on_delete=models.SET_NULL, related_name="+", null=True, blank=True, verbose_name="Image"
)

# not using revisions directly in case we want to add custom logic in the property in the future
_revisions = GenericRelation("wagtailcore.Revision", related_query_name="wasteaction")

@property
def revisions(self):
return self._revisions

def __str__(self):
return f'Action anti-gaspi "{self.title}"'

Expand Down
Loading