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

Fixed the preview of pages in non-live languages #205

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/wagtailtrans/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
from wagtailtrans.models import TranslatablePage


class DraftAwareModelChoiceField(forms.ModelChoiceField):
def label_from_instance(self, page):
return page.get_admin_display_title()


class TranslationForm(forms.ModelForm):
copy_from_canonical = forms.BooleanField(required=False)
parent_page = forms.ModelChoiceField(queryset=TranslatablePage.objects.none())
parent_page = DraftAwareModelChoiceField(queryset=TranslatablePage.objects.none())

class Meta:
model = TranslatablePage
Expand Down
2 changes: 1 addition & 1 deletion src/wagtailtrans/templatetags/wagtailtrans_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_translations(page, homepage_fallback=True, include_self=True):
available_translations = {}
available_languages = get_languages_for_site(site)
if hasattr(page, 'language'):
if not include_self:
if not include_self and page.language in available_languages:
available_languages.remove(page.language)

page_translations = page.get_translations(only_live=True, include_self=include_self)
Expand Down