Ticket #14402: 14402.diff
File 14402.diff, 7.5 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/options.py
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
a b 172 172 173 173 if db_field.name in self.raw_id_fields: 174 174 kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, using=db) 175 kwargs['help_text'] = ''176 175 elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)): 177 176 kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical)) 178 177 -
django/contrib/admin/templates/admin/includes/fieldset.html
diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html
a b 18 18 {{ field.field }} 19 19 {% endif %} 20 20 {% endif %} 21 {% if field.field. field.help_text %}22 <p class="help">{{ field.field. field.help_text|safe }}</p>21 {% if field.field.help_text %} 22 <p class="help">{{ field.field.help_text|safe }}</p> 23 23 {% endif %} 24 24 </div> 25 25 {% endfor %} -
django/db/models/fields/related.py
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
a b 8 8 from django.db.models.query import QuerySet 9 9 from django.db.models.query_utils import QueryWrapper 10 10 from django.utils.encoding import smart_unicode 11 from django.utils.translation import ugettext_lazy as _, string_concat,ungettext, ugettext11 from django.utils.translation import ugettext_lazy as _, ungettext, ugettext 12 12 from django.utils.functional import curry 13 13 from django.core import exceptions 14 14 from django import forms … … 1000 1000 1001 1001 Field.__init__(self, **kwargs) 1002 1002 1003 msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')1004 self.help_text = string_concat(self.help_text, ' ', msg)1005 1006 1003 def get_choices_default(self): 1007 1004 return Field.get_choices(self, include_blank=False) 1008 1005 -
django/forms/models.py
diff --git a/django/forms/models.py b/django/forms/models.py
a b 7 7 from django.utils.encoding import smart_unicode, force_unicode 8 8 from django.utils.datastructures import SortedDict 9 9 from django.utils.text import get_text_list, capfirst 10 from django.utils.translation import ugettext_lazy as _, ugettext 10 from django.utils.translation import ugettext_lazy as _, ugettext, string_concat 11 11 12 12 from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, \ 13 13 FieldError … … 1027 1027 def __init__(self, queryset, cache_choices=False, required=True, 1028 1028 widget=None, label=None, initial=None, 1029 1029 help_text=None, *args, **kwargs): 1030 msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.') 1031 if help_text is None: 1032 help_text = msg 1033 else: 1034 help_text = string_concat(help_text, ' ', msg) 1030 1035 super(ModelMultipleChoiceField, self).__init__(queryset, None, 1031 1036 cache_choices, required, widget, label, initial, help_text, 1032 1037 *args, **kwargs) -
tests/regressiontests/admin_widgets/models.py
diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
a b 4 4 from django.core.files.storage import default_storage 5 5 from django.contrib.auth.models import User 6 6 7 class MyFileField(models.FileField): 8 pass 7 class MyFileField(models.FileField): 8 pass 9 9 10 10 class Member(models.Model): 11 11 name = models.CharField(max_length=100) … … 31 31 def __unicode__(self): 32 32 return self.name 33 33 34 class Director(models.Model): 35 name = models.CharField(max_length=40) 36 37 def __unicode__(self): 38 return self.name 39 40 class Genre(models.Model): 41 name = models.CharField(max_length=40) 42 43 def __unicode__(self): 44 return self.name 45 46 class Orchestra(models.Model): 47 name = models.CharField(max_length=100) 48 members = models.ManyToManyField(Member, help_text='This is the orchestra members help_text.') 49 director = models.ForeignKey(Director) 50 genres = models.ManyToManyField(Genre, help_text='This is the orchestra genres help_text.') 51 52 def __unicode__(self): 53 return self.name 54 34 55 class HiddenInventoryManager(models.Manager): 35 56 def get_query_set(self): 36 57 return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False) -
tests/regressiontests/admin_widgets/tests.py
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
a b 163 163 164 164 self.assertContains(response, 165 165 'Select a valid choice. That choice is not one of the available choices.') 166 167 class Ticket14402(DjangoTestCase): 168 fixtures = ["admin-widgets-users.xml"] 169 admin_root = '/widget_admin' 170 171 def setUp(self): 172 self.client.login(username="super", password="secret") 173 174 def tearDown(self): 175 self.client.logout() 176 177 def test_m2m_has_helptext(self): 178 """Non raw_id m2m model field help_text shouldn't be affected by the fix for this ticket.""" 179 response = self.client.get('%s/admin_widgets/orchestra/add/' % self.admin_root) 180 self.assert_("This is the orchestra genres help_text." in response.content) 181 182 def test_inline_m2m_has_helptext(self): 183 """Non raw_id m2m model field help_text shouldn't be affected by the fix for this ticket (inline case).""" 184 response = self.client.get('%s/admin_widgets/director/add/' % self.admin_root) 185 self.assert_("This is the orchestra genres help_text." in response.content) 186 187 def test_raw_id_m2m_has_helptext(self): 188 """raw_id m2m model field help_text shouldn't be ignored when displaying its admin widget.""" 189 response = self.client.get('%s/admin_widgets/orchestra/add/' % self.admin_root) 190 self.assert_("This is the orchestra members help_text." in response.content) 191 192 def test_raw_id_inline_m2m_has_helptext(self): 193 """raw_id m2m model field help_text shouldn't be ignored when displaying the admin widget (inline case).""" 194 response = self.client.get('%s/admin_widgets/director/add/' % self.admin_root) 195 self.assert_("This is the orchestra members help_text." in response.content) -
tests/regressiontests/admin_widgets/widgetadmin.py
diff --git a/tests/regressiontests/admin_widgets/widgetadmin.py b/tests/regressiontests/admin_widgets/widgetadmin.py
a b 22 22 class EventAdmin(admin.ModelAdmin): 23 23 raw_id_fields = ['band'] 24 24 25 class OrchestraAdmin(admin.ModelAdmin): 26 raw_id_fields = ['members'] 27 28 class OrchestraInline(admin.StackedInline): 29 model = models.Orchestra 30 raw_id_fields = ['members'] 31 32 class DirectorAdmin(admin.ModelAdmin): 33 inlines = [OrchestraInline] 34 25 35 site = WidgetAdmin(name='widget-admin') 26 36 27 37 site.register(models.User) 28 38 site.register(models.Car, CarAdmin) 29 39 site.register(models.CarTire, CarTireAdmin) 30 40 site.register(models.Event, EventAdmin) 41 site.register(models.Orchestra, OrchestraAdmin) 42 site.register(models.Director, DirectorAdmin)