-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'TP1-168-strange-horizontal-panning-on-opportunity-pages…
…-on' of github-mf:MozillaFoundation/foundation.mozilla.org into TP1-168-strange-horizontal-panning-on-opportunity-pages-on
- Loading branch information
Showing
116 changed files
with
1,019 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
network-api/networkapi/donate/factory/customblocks/__init__.py
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
network-api/networkapi/donate/factory/customblocks/notice_block.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
network-api/networkapi/donate/factory/snippets/help_page_notice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import factory | ||
from factory import Faker, LazyAttribute | ||
from wagtail.rich_text import RichText | ||
from wagtail_factories import ImageFactory | ||
|
||
from networkapi.donate.snippets.help_page_notice import HelpPageNotice | ||
|
||
notice_text_contents = Faker("paragraph", nb_sentences=3, variable_nb_sentences=False) | ||
|
||
|
||
class HelpPageNoticeFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = HelpPageNotice | ||
exclude = ("notice_text",) | ||
|
||
name = Faker("sentence", nb_words=3) | ||
text = LazyAttribute(lambda o: RichText(f"<p>{o.notice_text}</p>")) | ||
notice_image = factory.SubFactory(ImageFactory) | ||
notice_image_alt_text = Faker("sentence", nb_words=4) | ||
|
||
# Lazy Values | ||
notice_text = notice_text_contents |
68 changes: 68 additions & 0 deletions
68
network-api/networkapi/donate/migrations/0011_update_donatehelppage_notice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Generated by Django 4.2.11 on 2024-05-22 22:22 | ||
|
||
import uuid | ||
|
||
import django.db.models.deletion | ||
import wagtail.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("donate", "0010_make_link_to_required_in_link_block"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="donatehelppage", | ||
name="notice", | ||
), | ||
migrations.CreateModel( | ||
name="HelpPageNotice", | ||
fields=[ | ||
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("translation_key", models.UUIDField(default=uuid.uuid4, editable=False)), | ||
("name", models.CharField(help_text="What will this notice be called in the CMS?", max_length=50)), | ||
("text", wagtail.fields.RichTextField()), | ||
( | ||
"notice_image_alt_text", | ||
models.CharField(blank=True, help_text="Image description (for screen readers).", max_length=50), | ||
), | ||
( | ||
"locale", | ||
models.ForeignKey( | ||
editable=False, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="+", | ||
to="wagtailcore.locale", | ||
), | ||
), | ||
( | ||
"notice_image", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="wagtailimages.image", | ||
verbose_name="Notice Image", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
"unique_together": {("translation_key", "locale")}, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="donatehelppage", | ||
name="notice", | ||
field=models.ForeignKey( | ||
blank=True, | ||
help_text="Optional notice that will render at the top of the page.", | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="donate.helppagenotice", | ||
), | ||
), | ||
] |
31 changes: 0 additions & 31 deletions
31
network-api/networkapi/donate/pagemodels/customblocks/notice_block.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
53 changes: 53 additions & 0 deletions
53
network-api/networkapi/donate/snippets/help_page_notice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.db import models | ||
from wagtail.admin.panels import FieldPanel | ||
from wagtail.fields import RichTextField | ||
from wagtail.models import TranslatableMixin | ||
from wagtail_localize.fields import SynchronizedField, TranslatableField | ||
|
||
from networkapi.wagtailpages.pagemodels.customblocks.base_rich_text_options import ( | ||
base_rich_text_options, | ||
) | ||
|
||
|
||
class HelpPageNotice(TranslatableMixin, models.Model): | ||
name = models.CharField(max_length=50, help_text="What will this notice be called in the CMS?") | ||
|
||
text = RichTextField( | ||
features=base_rich_text_options, | ||
blank=False, | ||
) | ||
notice_image = models.ForeignKey( | ||
"wagtailimages.Image", | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
verbose_name="Notice Image", | ||
) | ||
notice_image_alt_text = models.CharField( | ||
max_length=50, blank=True, help_text="Image description (for screen readers)." | ||
) | ||
|
||
panels = [ | ||
FieldPanel("name"), | ||
FieldPanel("text"), | ||
FieldPanel("notice_image"), | ||
FieldPanel("notice_image_alt_text"), | ||
] | ||
|
||
translatable_fields = [ | ||
SynchronizedField("name"), | ||
TranslatableField("text"), | ||
SynchronizedField("notice_image"), | ||
TranslatableField("notice_image_alt_text"), | ||
] | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def clean(self): | ||
super().clean() | ||
if self.notice_image and not self.notice_image_alt_text: | ||
raise ValidationError({"notice_image_alt_text": "Image must include alt text."}) | ||
if self.notice_image_alt_text and not self.notice_image: | ||
raise ValidationError({"notice_image": "Alt text must have an associated image."}) |
Oops, something went wrong.