Internationalise missing models and model fields

This commit is contained in:
Tiago Henriques 2015-04-17 21:49:44 +02:00
parent 0e926e8399
commit 18e11746c2
18 changed files with 445 additions and 36 deletions

View file

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('tests', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='customimagewithadminformfields',
name='created_at',
field=models.DateTimeField(auto_now_add=True, verbose_name='Created at'),
),
migrations.AlterField(
model_name='customimagewithadminformfields',
name='height',
field=models.IntegerField(verbose_name='Height', editable=False),
),
migrations.AlterField(
model_name='customimagewithadminformfields',
name='uploaded_by_user',
field=models.ForeignKey(blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Uploaded by user'),
),
migrations.AlterField(
model_name='customimagewithadminformfields',
name='width',
field=models.IntegerField(verbose_name='Width', editable=False),
),
migrations.AlterField(
model_name='customimagewithoutadminformfields',
name='created_at',
field=models.DateTimeField(auto_now_add=True, verbose_name='Created at'),
),
migrations.AlterField(
model_name='customimagewithoutadminformfields',
name='height',
field=models.IntegerField(verbose_name='Height', editable=False),
),
migrations.AlterField(
model_name='customimagewithoutadminformfields',
name='uploaded_by_user',
field=models.ForeignKey(blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Uploaded by user'),
),
migrations.AlterField(
model_name='customimagewithoutadminformfields',
name='width',
field=models.IntegerField(verbose_name='Width', editable=False),
),
migrations.AlterField(
model_name='formfield',
name='choices',
field=models.CharField(help_text='Comma separated list of choices. Only applicable in checkboxes, radio and dropdown.', max_length=512, verbose_name='Choices', blank=True),
),
migrations.AlterField(
model_name='formfield',
name='default_value',
field=models.CharField(help_text='Default value. Comma separated values supported for checkboxes.', max_length=255, verbose_name='Default value', blank=True),
),
migrations.AlterField(
model_name='formfield',
name='field_type',
field=models.CharField(max_length=16, verbose_name='Field type', choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time')]),
),
migrations.AlterField(
model_name='formfield',
name='help_text',
field=models.CharField(max_length=255, verbose_name='Help text', blank=True),
),
migrations.AlterField(
model_name='formfield',
name='label',
field=models.CharField(help_text='The label of the form field', max_length=255, verbose_name='Label'),
),
migrations.AlterField(
model_name='formfield',
name='required',
field=models.BooleanField(default=True, verbose_name='Required'),
),
migrations.AlterField(
model_name='formpage',
name='from_address',
field=models.CharField(max_length=255, verbose_name='From address', blank=True),
),
migrations.AlterField(
model_name='formpage',
name='subject',
field=models.CharField(max_length=255, verbose_name='Subject', blank=True),
),
migrations.AlterField(
model_name='formpage',
name='to_address',
field=models.CharField(help_text='Optional - form submissions will be emailed to this address', max_length=255, verbose_name='To address', blank=True),
),
]

View file

@ -420,7 +420,7 @@ class TestPageChooserPanel(TestCase):
'barbecue',
'wagtailcore.site'
).bind_to_model(PageChooserModel).target_content_type()
self.assertEqual(result.name, 'site')
self.assertEqual(result.name, 'Site')
def test_target_content_type_malformed_type(self):
result = PageChooserPanel(

View file

@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0014_add_verbose_name'),
]
operations = [
migrations.AlterModelOptions(
name='grouppagepermission',
options={'verbose_name': 'Group Page Permission'},
),
migrations.AlterModelOptions(
name='pagerevision',
options={'verbose_name': 'Page Revision'},
),
migrations.AlterModelOptions(
name='pageviewrestriction',
options={'verbose_name': 'Page View Restriction'},
),
migrations.AlterModelOptions(
name='site',
options={'verbose_name': 'Site'},
),
migrations.AlterField(
model_name='page',
name='content_type',
field=models.ForeignKey(related_name='pages', verbose_name='Content type', to='contenttypes.ContentType'),
),
migrations.AlterField(
model_name='page',
name='expired',
field=models.BooleanField(default=False, verbose_name='Expired', editable=False),
),
migrations.AlterField(
model_name='page',
name='first_published_at',
field=models.DateTimeField(verbose_name='First published at', null=True, editable=False),
),
migrations.AlterField(
model_name='page',
name='has_unpublished_changes',
field=models.BooleanField(default=False, verbose_name='Has unpublished changes', editable=False),
),
migrations.AlterField(
model_name='page',
name='latest_revision_created_at',
field=models.DateTimeField(verbose_name='Latest revision created at', null=True, editable=False),
),
migrations.AlterField(
model_name='page',
name='live',
field=models.BooleanField(default=True, verbose_name='Live', editable=False),
),
migrations.AlterField(
model_name='page',
name='locked',
field=models.BooleanField(default=False, verbose_name='Locked', editable=False),
),
migrations.AlterField(
model_name='page',
name='owner',
field=models.ForeignKey(related_name='owned_pages', on_delete=django.db.models.deletion.SET_NULL, blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Owner'),
),
migrations.AlterField(
model_name='page',
name='url_path',
field=models.CharField(verbose_name='URL path', max_length=255, editable=False, blank=True),
),
migrations.AlterField(
model_name='pagerevision',
name='approved_go_live_at',
field=models.DateTimeField(null=True, verbose_name='Approved go live at', blank=True),
),
migrations.AlterField(
model_name='pagerevision',
name='content_json',
field=models.TextField(verbose_name='Content JSON'),
),
migrations.AlterField(
model_name='pagerevision',
name='created_at',
field=models.DateTimeField(verbose_name='Created at'),
),
migrations.AlterField(
model_name='pagerevision',
name='page',
field=models.ForeignKey(related_name='revisions', verbose_name='Page', to='wagtailcore.Page'),
),
migrations.AlterField(
model_name='pagerevision',
name='submitted_for_moderation',
field=models.BooleanField(default=False, verbose_name='Submitted for moderation'),
),
migrations.AlterField(
model_name='pagerevision',
name='user',
field=models.ForeignKey(verbose_name='User', blank=True, to=settings.AUTH_USER_MODEL, null=True),
),
]

View file

@ -57,6 +57,7 @@ class Site(models.Model):
class Meta:
unique_together = ('hostname', 'port')
verbose_name = _('Site')
def natural_key(self):
return (self.hostname, self.port)
@ -136,7 +137,6 @@ class Site(models.Model):
return result
# Clear the wagtail_site_root_paths from the cache whenever Site records are updated
@receiver(post_save, sender=Site)
def clear_site_root_paths_on_save(sender, instance, **kwargs):
@ -267,11 +267,11 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
slug = models.SlugField(verbose_name=_('Slug'), max_length=255, help_text=_("The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/"))
# TODO: enforce uniqueness on slug field per parent (will have to be done at the Django
# level rather than db, since there is no explicit parent relation in the db)
content_type = models.ForeignKey('contenttypes.ContentType', related_name='pages')
live = models.BooleanField(default=True, editable=False)
has_unpublished_changes = models.BooleanField(default=False, editable=False)
url_path = models.CharField(max_length=255, blank=True, editable=False)
owner = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, editable=False, on_delete=models.SET_NULL, related_name='owned_pages')
content_type = models.ForeignKey('contenttypes.ContentType', verbose_name=_('Content type'), related_name='pages')
live = models.BooleanField(verbose_name=_('Live'), default=True, editable=False)
has_unpublished_changes = models.BooleanField(verbose_name=_('Has unpublished changes'), default=False, editable=False)
url_path = models.CharField(verbose_name=_('URL path'), max_length=255, blank=True, editable=False)
owner = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Owner'), null=True, blank=True, editable=False, on_delete=models.SET_NULL, related_name='owned_pages')
seo_title = models.CharField(verbose_name=_("Page title"), max_length=255, blank=True, help_text=_("Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window."))
show_in_menus = models.BooleanField(verbose_name=_('Show in menus'), default=False, help_text=_("Whether a link to this page will appear in automatically generated menus"))
@ -279,12 +279,12 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
go_live_at = models.DateTimeField(verbose_name=_("Go live date/time"), help_text=_("Please add a date-time in the form YYYY-MM-DD hh:mm."), blank=True, null=True)
expire_at = models.DateTimeField(verbose_name=_("Expiry date/time"), help_text=_("Please add a date-time in the form YYYY-MM-DD hh:mm."), blank=True, null=True)
expired = models.BooleanField(default=False, editable=False)
expired = models.BooleanField(verbose_name=_('Expired'), default=False, editable=False)
locked = models.BooleanField(default=False, editable=False)
locked = models.BooleanField(verbose_name=_('Locked'), default=False, editable=False)
first_published_at = models.DateTimeField(null=True, editable=False)
latest_revision_created_at = models.DateTimeField(null=True, editable=False)
first_published_at = models.DateTimeField(verbose_name=_('First published at'), null=True, editable=False)
latest_revision_created_at = models.DateTimeField(verbose_name=_('Latest revision created at'), null=True, editable=False)
search_fields = (
index.SearchField('title', partial_match=True, boost=2),
@ -1058,12 +1058,12 @@ class SubmittedRevisionsManager(models.Manager):
@python_2_unicode_compatible
class PageRevision(models.Model):
page = models.ForeignKey('Page', related_name='revisions')
submitted_for_moderation = models.BooleanField(default=False)
created_at = models.DateTimeField()
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True)
content_json = models.TextField()
approved_go_live_at = models.DateTimeField(null=True, blank=True)
page = models.ForeignKey('Page', verbose_name=_('Page'), related_name='revisions')
submitted_for_moderation = models.BooleanField(verbose_name=_('Submitted for moderation'), default=False)
created_at = models.DateTimeField(verbose_name=_('Created at'))
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('User'), null=True, blank=True)
content_json = models.TextField(verbose_name=_('Content JSON'))
approved_go_live_at = models.DateTimeField(verbose_name=_('Approved go live at'), null=True, blank=True)
objects = models.Manager()
submitted_revisions = SubmittedRevisionsManager()
@ -1161,6 +1161,9 @@ class PageRevision(models.Model):
def __str__(self):
return '"' + six.text_type(self.page) + '" at ' + six.text_type(self.created_at)
class Meta:
verbose_name = _('Page Revision')
PAGE_PERMISSION_TYPE_CHOICES = [
('add', _('Add/edit pages you own')),
@ -1177,6 +1180,7 @@ class GroupPagePermission(models.Model):
class Meta:
unique_together = ('group', 'page', 'permission_type')
verbose_name = _('Group Page Permission')
class UserPagePermissionsProxy(object):
@ -1400,3 +1404,6 @@ class PagePermissionTester(object):
class PageViewRestriction(models.Model):
page = models.ForeignKey('Page', verbose_name=_('Page'), related_name='view_restrictions')
password = models.CharField(verbose_name=_('Password'), max_length=255)
class Meta:
verbose_name = _('Page View Restriction')

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('wagtaildocs', '0002_initial_data'),
]
operations = [
migrations.AlterModelOptions(
name='document',
options={'verbose_name': 'Document'},
),
migrations.AlterField(
model_name='document',
name='created_at',
field=models.DateTimeField(auto_now_add=True, verbose_name='Created at'),
),
migrations.AlterField(
model_name='document',
name='uploaded_by_user',
field=models.ForeignKey(blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Uploaded by user'),
),
]

View file

@ -22,8 +22,8 @@ from wagtail.wagtailsearch import index
class Document(models.Model, TagSearchable):
title = models.CharField(max_length=255, verbose_name=_('Title'))
file = models.FileField(upload_to='documents', verbose_name=_('File'))
created_at = models.DateTimeField(auto_now_add=True)
uploaded_by_user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, editable=False)
created_at = models.DateTimeField(verbose_name=_('Created at'), auto_now_add=True)
uploaded_by_user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Uploaded by user'), null=True, blank=True, editable=False)
tags = TaggableManager(help_text=None, blank=True, verbose_name=_('Tags'))
@ -68,6 +68,9 @@ class Document(models.Model, TagSearchable):
else:
return False
class Meta:
verbose_name = _('Document')
# Receive the pre_delete signal and delete the file associated with the model instance.
@receiver(pre_delete, sender=Document)

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailembeds', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='embed',
options={'verbose_name': 'Embed'},
),
]

View file

@ -2,6 +2,7 @@ from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
EMBED_TYPES = (
@ -28,6 +29,7 @@ class Embed(models.Model):
class Meta:
unique_together = ('url', 'max_width')
verbose_name = _('Embed')
def __str__(self):
return self.url

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailforms', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='formsubmission',
options={'verbose_name': 'Form Submission'},
),
migrations.AlterField(
model_name='formsubmission',
name='submit_time',
field=models.DateTimeField(auto_now_add=True, verbose_name='Submit time'),
),
]

View file

@ -46,7 +46,7 @@ class FormSubmission(models.Model):
form_data = models.TextField()
page = models.ForeignKey(Page)
submit_time = models.DateTimeField(auto_now_add=True)
submit_time = models.DateTimeField(verbose_name=_('Submit time'), auto_now_add=True)
def get_data(self):
return json.loads(self.form_data)
@ -54,27 +54,30 @@ class FormSubmission(models.Model):
def __str__(self):
return self.form_data
class Meta:
verbose_name = _('Form Submission')
class AbstractFormField(Orderable):
"""Database Fields required for building a Django Form field."""
label = models.CharField(
label = models.CharField(verbose_name=_('Label'),
max_length=255,
help_text=_('The label of the form field')
)
field_type = models.CharField(max_length=16, choices=FORM_FIELD_CHOICES)
required = models.BooleanField(default=True)
choices = models.CharField(
field_type = models.CharField(verbose_name=_('Field type'), max_length=16, choices=FORM_FIELD_CHOICES)
required = models.BooleanField(verbose_name=_('Required'), default=True)
choices = models.CharField(verbose_name=_('Choices'),
max_length=512,
blank=True,
help_text=_('Comma separated list of choices. Only applicable in checkboxes, radio and dropdown.')
)
default_value = models.CharField(
default_value = models.CharField(verbose_name=_('Default value'),
max_length=255,
blank=True,
help_text=_('Default value. Comma separated values supported for checkboxes.')
)
help_text = models.CharField(max_length=255, blank=True)
help_text = models.CharField(verbose_name=_('Help text'), max_length=255, blank=True)
@property
def clean_name(self):
@ -185,9 +188,9 @@ class AbstractEmailForm(AbstractForm):
"""A Form Page that sends email. Pages implementing a form to be send to an email should inherit from it"""
is_abstract = True # Don't display me in "Add"
to_address = models.CharField(max_length=255, blank=True, help_text=_("Optional - form submissions will be emailed to this address"))
from_address = models.CharField(max_length=255, blank=True)
subject = models.CharField(max_length=255, blank=True)
to_address = models.CharField(verbose_name=_('To address'), max_length=255, blank=True, help_text=_("Optional - form submissions will be emailed to this address"))
from_address = models.CharField(verbose_name=_('From address'), max_length=255, blank=True)
subject = models.CharField(verbose_name=_('Subject'), max_length=255, blank=True)
def process_form_submission(self, form):
super(AbstractEmailForm, self).process_form_submission(form)

View file

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0005_make_filter_spec_unique'),
]
operations = [
migrations.AlterField(
model_name='image',
name='created_at',
field=models.DateTimeField(auto_now_add=True, verbose_name='Created at'),
),
migrations.AlterField(
model_name='image',
name='height',
field=models.IntegerField(verbose_name='Height', editable=False),
),
migrations.AlterField(
model_name='image',
name='uploaded_by_user',
field=models.ForeignKey(blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Uploaded by user'),
),
migrations.AlterField(
model_name='image',
name='width',
field=models.IntegerField(verbose_name='Width', editable=False),
),
]

View file

@ -59,10 +59,10 @@ def get_upload_to(instance, filename):
class AbstractImage(models.Model, TagSearchable):
title = models.CharField(max_length=255, verbose_name=_('Title'))
file = models.ImageField(verbose_name=_('File'), upload_to=get_upload_to, width_field='width', height_field='height')
width = models.IntegerField(editable=False)
height = models.IntegerField(editable=False)
created_at = models.DateTimeField(auto_now_add=True)
uploaded_by_user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, editable=False)
width = models.IntegerField(verbose_name=_('Width'), editable=False)
height = models.IntegerField(verbose_name=_('Height'), editable=False)
created_at = models.DateTimeField(verbose_name=_('Created at'), auto_now_add=True)
uploaded_by_user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Uploaded by user'), null=True, blank=True, editable=False)
tags = TaggableManager(help_text=None, blank=True, verbose_name=_('Tags'))

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailredirects', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='redirect',
options={'verbose_name': 'Redirect'},
),
migrations.AlterField(
model_name='redirect',
name='site',
field=models.ForeignKey(related_name='redirects', blank=True, editable=False, to='wagtailcore.Site', null=True, verbose_name='Site'),
),
]

View file

@ -10,7 +10,7 @@ from six.moves.urllib.parse import urlparse
class Redirect(models.Model):
old_path = models.CharField(verbose_name=_("Redirect from"), max_length=255, unique=True, db_index=True)
site = models.ForeignKey('wagtailcore.Site', null=True, blank=True, related_name='redirects', db_index=True, editable=False)
site = models.ForeignKey('wagtailcore.Site', verbose_name=_('Site'), null=True, blank=True, related_name='redirects', db_index=True, editable=False)
is_permanent = models.BooleanField(verbose_name=_("Permanent"), default=True, help_text=_("Recommended. Permanent redirects ensure search engines forget the old page (the 'Redirect from') and index the new page instead."))
redirect_page = models.ForeignKey('wagtailcore.Page', verbose_name=_("Redirect to a page"), null=True, blank=True)
redirect_link = models.URLField(verbose_name=_("Redirect to any URL"), blank=True)
@ -67,6 +67,9 @@ class Redirect(models.Model):
# Normalise old path
self.old_path = Redirect.normalise_path(self.old_path)
class Meta:
verbose_name = _('Redirect')
Redirect.content_panels = [
MultiFieldPanel([
FieldPanel('old_path'),

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailsearch', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='editorspick',
options={'ordering': ('sort_order',), 'verbose_name': "Editor's Pick"},
),
migrations.AlterModelOptions(
name='querydailyhits',
options={'verbose_name': 'Query Daily Hits'},
),
migrations.AlterField(
model_name='editorspick',
name='description',
field=models.TextField(verbose_name='Description', blank=True),
),
migrations.AlterField(
model_name='editorspick',
name='page',
field=models.ForeignKey(verbose_name='Page', to='wagtailcore.Page'),
),
]

View file

@ -5,6 +5,7 @@ import datetime
from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailsearch.utils import normalise_query_string, MAX_QUERY_STRING_LENGTH
@ -69,16 +70,18 @@ class QueryDailyHits(models.Model):
unique_together = (
('query', 'date'),
)
verbose_name = _('Query Daily Hits')
class EditorsPick(models.Model):
query = models.ForeignKey(Query, db_index=True, related_name='editors_picks')
page = models.ForeignKey('wagtailcore.Page')
page = models.ForeignKey('wagtailcore.Page', verbose_name=_('Page'))
sort_order = models.IntegerField(null=True, blank=True, editable=False)
description = models.TextField(blank=True)
description = models.TextField(verbose_name=_('Description'), blank=True)
def __repr__(self):
return 'EditorsPick(query="' + self.query.query_string + '", page="' + self.page.title + '")'
class Meta:
ordering = ('sort_order', )
verbose_name = _("Editor's Pick")

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailusers', '0002_add_verbose_name_on_userprofile'),
]
operations = [
migrations.AlterModelOptions(
name='userprofile',
options={'verbose_name': 'User Profile'},
),
]

View file

@ -34,3 +34,6 @@ class UserProfile(models.Model):
def __str__(self):
return self.user.get_username()
class Meta:
verbose_name = _('User Profile')