Skip to content

Commit

Permalink
rebase fixes
Browse files Browse the repository at this point in the history
fix the language picker by making sure 'next' is the right URL (#6780)

allow authenticated users to hit the wagtail localize endpoints (#6778)

* allow authenticated users to hit the wagtail localize endpoints

Updated migrations (#6795)

Enable pontoon integration for wagtail-localize (#6794)

* add wagtail_localize_git

* heroku ssh generation script

rebase fixes

Update settings.py

Update settings.py

Better 500 logging (#6836)

* allow forced logging of stack traces to console for 500 errors

* Update urls.py

* Update urls.py

blog fixes for the localize branch (#6840)

* blog fixes for the localize branch

* import

* oh flake8, you joker

Show locale in admin title (until a proper solution is released in Wagtail Core) (#6843)

rebase fixes

Redirect /pt to /pt-BR (#6854)

only create the locale, rather than cloning all pages, when creating a synced locale (#6853)

Campaign page translation fix (#6855)

Permanent pt-BR redirect (#6856)

Added localized URLs for every page through the FoundationMetadataPageMixin (#6849)

* Added localized URLs for every page through the FoundationMetadataPageMixin

* Cache sitemap

* Localized sitemaps

Make tests pass (#6872)

* Flake8

* Sitemap.xml test fix

Localization synching and creating management commands (#6866)

* Localization synching and creating management commands

* Don't lower strings; requires exact string matching now

Allow banner pages to be further localized (#6876)

Marked fields are sync or translatable (#6875)

* Marked fields are sync or translatable

* Oop

* Flake8

* Add petition synchronized fields

Co-authored-by: Théo Chevalier <theo.chevalier11@gmail.com>

Fix makemessages command for Django >= 3.1 (#6907)

Use localized wagtail-footnotes (#6913)

Localize missing fields for YT pages (#6923)

Translate article page titles (#6924)

Translate What You Can Do title (#6925)

address all acceptance criteria (#6930)

rebase fixes

update all homepage fragments to pull from localized content (#7067)

* update all homepage fragments to pull from localized content

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/news_you_can_use.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/spotlight_posts.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Fix all the localized properties (#7068)

* update all homepage fragments to pull from localized content

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/news_you_can_use.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/spotlight_posts.html

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

* rest of the localized updates... I think

* forgot to save a file

Co-authored-by: Kalob Taulien <4743971+KalobTaulien@users.noreply.github.com>

Translatable PNI fields (#7075)

Translate 3 more PNI fields (#7081)

Localized limks in Related products section (#7125)

Localize PNI categories & products (#7124)

Translate Host controls field (#7123)

regenerating requirements.txt

.

migration renames

migration fixes

Override translatable fields for PNI home (#7146)

Localize title field on Default pages (#7147)

Bump wagtail-localize to 1.0rc3 (#7176)

Category snippet localization (#7183)

* category-snippet-localization

* well then

* Update network-api/networkapi/wagtailpages/templatetags/localization.py

* update based on Karl's advice

* some WIP removals

* show correct categories on product pages, and relocalize urls to point to use the correct locale

* let's not cache-clear

Restore product filtering per language (#7208)

Fix category fallthrough (#7212)

* make missing categories fall through to the EN version

* small docs update

* ???

* oops

* data-name should stay English

Moved consts inside of functions to prevent runtime/migration conflicts (#7215)

* Moved consts inside of functions to prevent runtime/migration conflicts

* That's better
  • Loading branch information
Pomax committed Aug 11, 2021
1 parent 5a6dc6d commit 252c63d
Show file tree
Hide file tree
Showing 88 changed files with 2,522 additions and 260 deletions.
23 changes: 23 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copy SSH private key to file, if set
# This is used for talking to GitHub over an SSH connection
if [ $WAGTAIL_LOCALIZE_PRIVATE_KEY ]; then
echo "Generating SSH config"
SSH_DIR=/app/.ssh

mkdir -p $SSH_DIR
chmod 700 $SSH_DIR

echo $WAGTAIL_LOCALIZE_PRIVATE_KEY | base64 --decode > $SSH_DIR/id_rsa

chmod 400 $SSH_DIR/id_rsa

cat << EOF > $SSH_DIR/config
StrictHostKeyChecking no
EOF

chmod 600 $SSH_DIR/config

echo "Done!"
fi
23 changes: 12 additions & 11 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
#
# pip-compile dev-requirements.in
#
certifi==2021.5.30
certifi==2020.4.5.1
# via
# -c requirements.txt
# requests
# urllib3
cffi==1.14.6
cffi==1.14.0
# via
# -c requirements.txt
# cryptography
charset-normalizer==2.0.3
chardet==3.0.4
# via
# -c requirements.txt
# requests
coverage==5.1
# via coveralls
coveralls==3.0.1
# via -r dev-requirements.in
cryptography==3.4.7
cryptography==3.2
# via
# -c requirements.txt
# pyopenssl
Expand All @@ -30,12 +30,12 @@ docopt==0.6.2
# via coveralls
flake8==3.8.4
# via -r dev-requirements.in
idna==3.2
idna==2.9
# via
# -c requirements.txt
# requests
# urllib3
importlib-metadata==4.6.1
importlib-metadata==3.10.1
# via
# -c requirements.txt
# flake8
Expand All @@ -55,23 +55,24 @@ pyopenssl==20.0.1
# via
# -c requirements.txt
# urllib3
requests==2.26.0
requests==2.25.1
# via
# -c requirements.txt
# coveralls
six==1.16.0
six==1.14.0
# via
# -c requirements.txt
# cryptography
# pyopenssl
typing-extensions==3.10.0.0
typing-extensions==3.7.4.3
# via
# -c requirements.txt
# importlib-metadata
urllib3[secure]==1.26.6
urllib3[secure]==1.25.9
# via
# -c requirements.txt
# requests
zipp==3.5.0
zipp==3.4.1
# via
# -c requirements.txt
# importlib-metadata
12 changes: 10 additions & 2 deletions network-api/networkapi/campaign/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from networkapi.wagtailpages.models import Petition, Signup


def process_lang_code(lang):
# Salesforce expects "pt" instead of "pt-BR".
# See https://github.com/mozilla/foundation.mozilla.org/issues/5993
if lang == 'pt-BR':
return 'pt'
return lang


class SQSProxy:
"""
We use a proxy class to make sure that code that
Expand Down Expand Up @@ -128,7 +136,7 @@ def signup_submission(request, signup):
"format": "html",
"source_url": source,
"newsletters": signup.newsletter,
"lang": rq.get('lang', 'en'),
"lang": process_lang_code(rq.get('lang', 'en')),
"country": rq.get('country', ''),
# Empty string instead of None due to Basket issues
"first_name": rq.get('givenNames', ''),
Expand Down Expand Up @@ -178,7 +186,7 @@ def petition_submission(request, petition):
"email": request.data['email'],
"email_subscription": request.data['newsletterSignup'],
"source_url": request.data['source'],
"lang": request.data['lang'],
"lang": process_lang_code(request.data['lang']),
}

if petition:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.11 on 2021-05-31 17:35

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('highlights', '0004_remove_highlight_image'),
]

operations = [
migrations.AddField(
model_name='highlight',
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='highlight',
name='translation_key',
field=models.UUIDField(editable=False, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 3.1.11 on 2021-05-31 17:18

from django.db import migrations
from wagtail.core.models import BootstrapTranslatableModel


class Migration(migrations.Migration):

dependencies = [
('highlights', '0005_auto_20210531_1735'),
]

operations = [
BootstrapTranslatableModel('highlights.Highlight'),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.1.11 on 2021-05-31 18:02

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('highlights', '0006_bootstrap_migration'),
]

operations = [
migrations.AlterField(
model_name='highlight',
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='highlight',
name='translation_key',
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
migrations.AlterUniqueTogether(
name='highlight',
unique_together={('translation_key', 'locale')},
),
]
14 changes: 12 additions & 2 deletions network-api/networkapi/highlights/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
from adminsortable.models import SortableMixin
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField
from wagtail.core.models import TranslatableMixin
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.snippets.models import register_snippet

from wagtail_localize.fields import TranslatableField

from networkapi.utility.images import get_image_upload_path


Expand All @@ -33,7 +36,7 @@ def published(self):


@register_snippet
class Highlight(SortableMixin):
class Highlight(TranslatableMixin, SortableMixin):
"""
An data type to highlight things like pulse
projects, custom pages, etc
Expand Down Expand Up @@ -97,9 +100,16 @@ class Highlight(SortableMixin):
FieldPanel("expires"),
]

translatable_fields = [
TranslatableField('title'),
TranslatableField('description'),
TranslatableField('link_label'),
TranslatableField('footer'),
]

objects = HighlightQuerySet.as_manager()

class Meta:
class Meta(TranslatableMixin.Meta):
verbose_name_plural = 'highlights'
ordering = ('order',)

Expand Down
13 changes: 13 additions & 0 deletions network-api/networkapi/management/commands/create_locales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from wagtail.core.models import Locale


class Command(BaseCommand):
help = 'Look for and create locales if they do not exist. This can be run multiple times if needed.'

def handle(self, *args, **options):
for language_code, name in settings.WAGTAIL_CONTENT_LANGUAGES:
locale, created = Locale.objects.get_or_create(language_code=language_code)
if created:
print(f"Create new locale: {name}")
38 changes: 38 additions & 0 deletions network-api/networkapi/management/commands/sync_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from wagtail.core.models import Locale
from wagtail_localize.models import LocaleSynchronization


class Command(BaseCommand):
help = 'Sync pages with original English pages'

def handle(self, *args, **options):
print("Select a language code to sync with English. ie: de")

for language_code, name in settings.WAGTAIL_CONTENT_LANGUAGES:
if language_code != 'en':
print(f"{language_code} ({name})")

language_code = input("Language code: ")

# Confirm the language code is in the WAGTAIL_CONTENT_LANGUAGES
language_codes_dict = dict(settings.WAGTAIL_CONTENT_LANGUAGES)
if language_code not in language_codes_dict:
print("Invalid language code")
return

print("Getting both locales...")
english_locale, _ = Locale.objects.get_or_create(language_code='en')
locale, _ = Locale.objects.get_or_create(language_code=language_code)

print("Getting LocaleSynchronization object")
sync, created = LocaleSynchronization.objects.get_or_create(
locale=locale,
sync_from=english_locale,
)
if created:
print("\tNew LocaleSynchronization object created")

print(f"Syncing {locale} from {english_locale}")
sync.sync_trees()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
('mozfest', '0011_auto_20210519_1654'),
('mozfest', '0013_auto_20210721_1921'),
]

operations = [
Expand Down
26 changes: 25 additions & 1 deletion network-api/networkapi/mozfest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail_localize.fields import SynchronizedField, TranslatableField


from networkapi.wagtailpages.utils import (
set_main_site_nav_information,
Expand Down Expand Up @@ -167,10 +169,32 @@ class MozfestHomepage(MozfestPrimaryPage):
else:
content_panels = all_panels

# Because we inherit from PrimaryPage, but the "use_wide_templatae" property does nothing
# Because we inherit from PrimaryPage, but the "use_wide_template" property does nothing
# we should hide it and make sure we use the right template
settings_panels = Page.settings_panels

translatable_fields = [
# Promote tab fields
SynchronizedField('slug'),
TranslatableField('seo_title'),
SynchronizedField('show_in_menus'),
TranslatableField('search_description'),
SynchronizedField('search_image'),
# Content tab fields
TranslatableField('title'),
TranslatableField('cta_button_label'),
SynchronizedField('cta_button_destination'),
TranslatableField('banner_heading'),
TranslatableField('banner_guide_text'),
SynchronizedField('banner_video_url'),
TranslatableField('title'),
TranslatableField('search_description'),
TranslatableField('search_image'),
TranslatableField('signup'),
TranslatableField('body'),
TranslatableField('footnotes'),
]

def get_context(self, request):
context = super().get_context(request)
context['banner_video_type'] = self.specific.banner_video_type
Expand Down
25 changes: 25 additions & 0 deletions network-api/networkapi/news/migrations/0005_auto_20210531_1735.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.11 on 2021-05-31 17:35

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('news', '0004_remove_news_featured'),
]

operations = [
migrations.AddField(
model_name='news',
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='news',
name='translation_key',
field=models.UUIDField(editable=False, null=True),
),
]
15 changes: 15 additions & 0 deletions network-api/networkapi/news/migrations/0006_bootstrap_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 3.1.11 on 2021-05-31 17:37

from django.db import migrations
from wagtail.core.models import BootstrapTranslatableModel


class Migration(migrations.Migration):

dependencies = [
('news', '0005_auto_20210531_1735'),
]

operations = [
BootstrapTranslatableModel('news.News')
]
Loading

0 comments on commit 252c63d

Please sign in to comment.