mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Merge branch 'remove-hold-down-control-messages' of git://github.com/rouge8/django-rest-framework into rouge8-remove-hold-down-control-messages
This commit is contained in:
commit
676ab4971c
|
@ -100,6 +100,19 @@ def humanize_strptime(format_string):
|
|||
return format_string
|
||||
|
||||
|
||||
def strip_multiple_choice_msg(help_text):
|
||||
"""
|
||||
Remove the 'Hold down "control" ...' message that is enforced in select
|
||||
multiple fields.
|
||||
|
||||
See https://code.djangoproject.com/ticket/9321
|
||||
"""
|
||||
multiple_choice_msg = _(' Hold down "Control", or "Command" on a Mac, to select more than one.')
|
||||
multiple_choice_msg = unicode(multiple_choice_msg)
|
||||
|
||||
return help_text.replace(multiple_choice_msg, '')
|
||||
|
||||
|
||||
class Field(object):
|
||||
read_only = True
|
||||
creation_counter = 0
|
||||
|
@ -122,7 +135,7 @@ class Field(object):
|
|||
self.label = smart_text(label)
|
||||
|
||||
if help_text is not None:
|
||||
self.help_text = smart_text(help_text)
|
||||
self.help_text = strip_multiple_choice_msg(smart_text(help_text))
|
||||
|
||||
def initialize(self, parent, field_name):
|
||||
"""
|
||||
|
|
|
@ -52,7 +52,7 @@ class CallableDefaultValueModel(RESTFrameworkModel):
|
|||
|
||||
|
||||
class ManyToManyModel(RESTFrameworkModel):
|
||||
rel = models.ManyToManyField(Anchor)
|
||||
rel = models.ManyToManyField(Anchor, help_text='Some help text.')
|
||||
|
||||
|
||||
class ReadOnlyManyToManyModel(RESTFrameworkModel):
|
||||
|
|
|
@ -1376,6 +1376,18 @@ class FieldLabelTest(TestCase):
|
|||
self.assertEqual('Label', relations.HyperlinkedRelatedField(view_name='fake', label='Label', help_text='Help', many=True).label)
|
||||
|
||||
|
||||
# Test for issue #961
|
||||
|
||||
class ManyFieldHelpTextTest(TestCase):
|
||||
def test_help_text_no_hold_down_control_msg(self):
|
||||
"""
|
||||
Validate that help_text doesn't contain the 'Hold down "Control" ...'
|
||||
message that Django appends to choice fields.
|
||||
"""
|
||||
rel_field = fields.Field(help_text=ManyToManyModel._meta.get_field('rel').help_text)
|
||||
self.assertEqual('Some help text.', unicode(rel_field.help_text))
|
||||
|
||||
|
||||
class AttributeMappingOnAutogeneratedFieldsTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user