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

Make footnotes orderable #74

Merged
merged 1 commit into from
Oct 18, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.15 on 2024-09-17 17:28

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("wagtail_footnotes", "0006_alter_footnote_locale"),
]

operations = [
migrations.AlterModelOptions(
name="footnote",
options={"ordering": ["sort_order"]},
),
migrations.AddField(
model_name="footnote",
name="sort_order",
field=models.IntegerField(blank=True, editable=False, null=True),
),
]
7 changes: 3 additions & 4 deletions wagtail_footnotes/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField
from wagtail.models import TranslatableMixin
from wagtail.models import Orderable, TranslatableMixin

from wagtail_footnotes.fields import CustomUUIDField
from wagtail_footnotes.widgets import ReadonlyUUIDInput


class Footnote(TranslatableMixin, models.Model):
class Footnote(TranslatableMixin, Orderable):
"""
Footnote has a UUID field which is set using JavaScript on object creation
so that it is available immediately for hardcoding a reference to the
Expand All @@ -32,7 +31,7 @@ class Footnote(TranslatableMixin, models.Model):

panels = [FieldPanel("text"), FieldPanel("uuid", widget=ReadonlyUUIDInput)]

class Meta(TranslatableMixin.Meta):
class Meta(TranslatableMixin.Meta, Orderable.Meta):
unique_together = [("page", "uuid"), ("translation_key", "locale")]

def __str__(self):
Expand Down
Loading