Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion aldryn_forms/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class Field(FormElement):

def serialize_value(self, instance, value, is_confirmation=False):
if isinstance(value, query.QuerySet):
value = u', '.join(map(text_type, value))
value = ', '.join(map(text_type, value))
elif value is None:
value = '-'
return text_type(value)
Expand Down
12 changes: 7 additions & 5 deletions aldryn_forms/contrib/email_notifications/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from django.contrib import admin
from django.core.mail import get_connection

from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _

from cms.plugin_pool import plugin_pool
Expand Down Expand Up @@ -104,14 +106,14 @@ def text_variables(self, obj):

for category, choices in choices_by_category:
# <li>field_1</li><li>field_2</li>
fields_li = u''.join((u'<li>{0} | {1}</li>'.format(*var) for var in choices))
fields_li = ''.join(('<li>{0} | {1}</li>'.format(*var) for var in choices))

if fields_li:
li_item = u'<li>{0}</li><ul>{1}</ul>'.format(category, fields_li)
li_item = '<li>{0}</li><ul>{1}</ul>'.format(category, fields_li)
li_items.append(li_item)
unordered_list = u'<ul>{0}</ul>'.format(u''.join(li_items))
help_text = u'<p class="help">{0}</p>'.format(self.text_variables_help_text)
return unordered_list + u'\n' + help_text
unordered_list = '<ul>{0}</ul>'.format(''.join(li_items))
help_text = '<p class="help">{0}</p>'.format(self.text_variables_help_text)
return format_html(unordered_list + '\n' + help_text)
text_variables.allow_tags = True
text_variables.short_description = _('available text variables')

Expand Down
2 changes: 1 addition & 1 deletion aldryn_forms/contrib/email_notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Meta:
def __str__(self):
to_name = self.get_recipient_name()
to_email = self.get_recipient_email()
return u'{0} ({1})'.format(to_name, to_email)
return '{0} ({1})'.format(to_name, to_email)

def clean(self):
recipient_email = self.get_recipient_email()
Expand Down
18 changes: 9 additions & 9 deletions aldryn_forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def clean(self):
min_value = self.cleaned_data.get('min_value')
max_value = self.cleaned_data.get('max_value')
if min_value and max_value and min_value > max_value:
self.append_to_errors('min_value', _(u'Min value can not be greater than max value.'))
self.append_to_errors('min_value', _('Min value can not be greater than max value.'))
return self.cleaned_data


Expand All @@ -228,11 +228,11 @@ class TextFieldForm(MinMaxValueForm):
def __init__(self, *args, **kwargs):
super(TextFieldForm, self).__init__(*args, **kwargs)

self.fields['min_value'].label = _(u'Min length')
self.fields['min_value'].help_text = _(u'Required number of characters to type.')
self.fields['min_value'].label = _('Min length')
self.fields['min_value'].help_text = _('Required number of characters to type.')

self.fields['max_value'].label = _(u'Max length')
self.fields['max_value'].help_text = _(u'Maximum number of characters to type.')
self.fields['max_value'].label = _('Max length')
self.fields['max_value'].help_text = _('Maximum number of characters to type.')
self.fields['max_value'].required = False

class Meta:
Expand Down Expand Up @@ -309,11 +309,11 @@ class MultipleSelectFieldForm(MinMaxValueForm):
def __init__(self, *args, **kwargs):
super(MultipleSelectFieldForm, self).__init__(*args, **kwargs)

self.fields['min_value'].label = _(u'Min choices')
self.fields['min_value'].help_text = _(u'Required amount of elements to chose.')
self.fields['min_value'].label = _('Min choices')
self.fields['min_value'].help_text = _('Required amount of elements to chose.')

self.fields['max_value'].label = _(u'Max choices')
self.fields['max_value'].help_text = _(u'Maximum amount of elements to chose.')
self.fields['max_value'].label = _('Max choices')
self.fields['max_value'].help_text = _('Maximum amount of elements to chose.')

class Meta:
# 'required' and 'required_message' depend on min_value field validator
Expand Down
10 changes: 5 additions & 5 deletions aldryn_forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def field_id(self):
field_label = self.label.strip()

if field_label:
field_as_string = u'{}-{}'.format(field_label, self.field_type)
field_as_string = '{}-{}'.format(field_label, self.field_type)
else:
field_as_string = self.name
field_id = u'{}:{}'.format(field_as_string, self.field_occurrence)
field_id = '{}:{}'.format(field_as_string, self.field_occurrence)
return field_id

@property
Expand Down Expand Up @@ -261,10 +261,10 @@ def get_form_fields(self):
if field_plugin.name:
field_name = field_plugin.name
else:
field_name = u'{0}_{1}'.format(field_type, field_type_occurrence)
field_name = '{0}_{1}'.format(field_type, field_type_occurrence)

if field_label:
field_id = u'{0}_{1}'.format(field_type, field_label)
field_id = '{0}_{1}'.format(field_type, field_label)
else:
field_id = field_name

Expand Down Expand Up @@ -591,7 +591,7 @@ def _form_data_hook(self, data, occurrences):

if field_label:
field_type = data['name'].rpartition('_')[0]
field_id = u'{}_{}'.format(field_type, field_label)
field_id = '{}_{}'.format(field_type, field_label)
else:
field_id = data['name']

Expand Down
2 changes: 1 addition & 1 deletion aldryn_forms/sizefield/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FileSizeField(models.BigIntegerField):
default_error_messages = {
'invalid': _(u'Incorrect file size format.'),
'invalid': _('Incorrect file size format.'),
}

def formfield(self, **kwargs):
Expand Down