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

Campaign page translation fix #6855

Merged
merged 1 commit into from
Jun 10, 2021
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,25 @@
# Generated by Django 3.1.11 on 2021-06-10 16:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0014_translation_mixin_migration'),
]

operations = [
migrations.AlterUniqueTogether(
name='cta',
unique_together=set(),
),
migrations.RemoveField(
model_name='cta',
name='locale',
),
migrations.RemoveField(
model_name='cta',
name='translation_key',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.1.11 on 2021-06-10 16:55

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('wagtailpages', '0015_remove_localization_from_cta_model'),
]

operations = [
migrations.AddField(
model_name='petition',
name='locale',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to catch the error this will throw if someone tries to delete it while a campaign makes uses of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question, I have no idea. @TheoChevalier thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out: it does nothing. I tried deleting an in-use petition, and it just...worked O_o

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d say it’s good to have, but not blocking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, let's get this in.

),
migrations.AddField(
model_name='petition',
name='translation_key',
field=models.UUIDField(editable=False, null=True),
),
migrations.AddField(
model_name='signup',
name='locale',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
),
migrations.AddField(
model_name='signup',
name='translation_key',
field=models.UUIDField(editable=False, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.1.11 on 2021-06-10 16:55

from django.db import migrations

from wagtail.core.models import BootstrapTranslatableModel

class Migration(migrations.Migration):

dependencies = [
('wagtailpages', '0016_add_localization_to_subclasses'),
]

operations = [
BootstrapTranslatableModel('wagtailpages.Petition'),
BootstrapTranslatableModel('wagtailpages.Signup'),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 3.1.11 on 2021-06-10 18:23

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('wagtailpages', '0017_bootstrap_subclassed_cta_models'),
]

operations = [
migrations.AlterField(
model_name='petition',
name='locale',
field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
preserve_default=False,
),
migrations.AlterField(
model_name='petition',
name='translation_key',
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
migrations.AlterField(
model_name='signup',
name='locale',
field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale'),
preserve_default=False,
),
migrations.AlterField(
model_name='signup',
name='translation_key',
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
migrations.AlterUniqueTogether(
name='petition',
unique_together={('translation_key', 'locale')},
),
migrations.AlterUniqueTogether(
name='signup',
unique_together={('translation_key', 'locale')},
),
]
14 changes: 7 additions & 7 deletions network-api/networkapi/wagtailpages/pagemodels/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import models

from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, StreamFieldPanel
from wagtail.core.models import TranslatableMixin, Page
from wagtail.core.models import TranslatableMixin, TranslatableMixin, Page
from wagtail.core.fields import RichTextField
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.snippets.models import register_snippet
Expand All @@ -23,7 +23,7 @@
)


class CTA(TranslatableMixin, models.Model):
class CTA(models.Model):
name = models.CharField(
default='',
max_length=100,
Expand All @@ -50,12 +50,12 @@ class CTA(TranslatableMixin, models.Model):
def __str__(self):
return self.name

class Meta(TranslatableMixin.Meta):
class Meta:
verbose_name_plural = 'CTA'


@register_snippet
class Signup(CTA):
class Signup(TranslatableMixin, CTA):
campaign_id = models.CharField(
max_length=20,
help_text='Which campaign identifier should this petition be tied to?',
Expand All @@ -68,7 +68,7 @@ class Signup(CTA):
default=False,
)

class Meta:
class Meta(TranslatableMixin.Meta):
verbose_name = 'signup snippet'


Expand All @@ -93,7 +93,7 @@ class Meta:


@register_snippet
class Petition(CTA):
class Petition(TranslatableMixin, CTA):
campaign_id = models.CharField(
max_length=20,
help_text='Which campaign identifier should this petition be tied to?',
Expand Down Expand Up @@ -177,7 +177,7 @@ class Petition(CTA):
default='Thank you for signing too!',
)

class Meta:
class Meta(TranslatableMixin.Meta):
verbose_name = 'petition snippet'


Expand Down