Ticket #15938: unlocalize_maxLength2.diff
File unlocalize_maxLength2.diff, 4.1 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/templates/admin/prepopulated_fields_js.html
1 {% load l10n %} 1 2 <script type="text/javascript"> 2 3 (function($) { 3 4 var field = null; … … 7 8 id: '#{{ field.field.auto_id }}', 8 9 dependency_ids: [], 9 10 dependency_list: [], 10 maxLength: {{ field.field.field.max_length|default_if_none:"50" }}11 maxLength: {{ field.field.field.max_length|default_if_none:"50"|unlocalize }} 11 12 }; 12 13 13 14 {% for dependency in field.dependencies %} -
tests/regressiontests/admin_views/admin.py
22 22 Gadget, Villain, SuperVillain, Plot, PlotDetails, CyclicOne, CyclicTwo, 23 23 WorkHour, Reservation, FoodDelivery, RowLevelChangePermissionModel, Paper, 24 24 CoverLetter, Story, OtherStory, Book, Promo, ChapterXtra1, Pizza, Topping, 25 Album, Question, Answer, ComplexSortedPerson )25 Album, Question, Answer, ComplexSortedPerson, PrePopulatedPostLargeSlug) 26 26 27 27 28 28 def callable_year(dt_value): … … 469 469 list_filter = ('employee',) 470 470 471 471 472 class PrePopulatedPostLargeSlugAdmin(admin.ModelAdmin): 473 prepopulated_fields = { 474 'slug' : ('title',) 475 } 476 472 477 site = admin.AdminSite(name="admin") 473 478 site.register(Article, ArticleAdmin) 474 479 site.register(CustomArticle, CustomArticleAdmin) … … 538 543 from django.contrib.auth.admin import UserAdmin, GroupAdmin 539 544 site.register(User, UserAdmin) 540 545 site.register(Group, GroupAdmin) 546 site.register(PrePopulatedPostLargeSlug, PrePopulatedPostLargeSlugAdmin) -
tests/regressiontests/admin_views/tests.py
28 28 from django.utils.encoding import iri_to_uri 29 29 from django.utils.html import escape 30 30 from django.utils.http import urlencode 31 from django.test.utils import override_settings 31 32 32 33 # local test models 33 34 from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount, … … 2756 2757 self.assertNotContains(response, "id: '#id_slug'") 2757 2758 self.assertNotContains(response, "field['dependency_ids'].push('#id_title');") 2758 2759 self.assertNotContains(response, "id: '#id_prepopulatedsubpost_set-0-subslug',") 2760 2761 @override_settings(USE_THOUSAND_SEPARATOR = True, USE_L10N = True) 2762 def test_prepopulated_maxlength_localized(self): 2763 """ 2764 Regression test for #15938: if USE_THOUSAND_SEPARATOR is set, make sure 2765 that maxLength (in the javascript) is rendered without separators. 2766 """ 2767 response = self.client.get('/test_admin/admin/admin_views/prepopulatedpostlargeslug/add/') 2768 self.assertContains(response, "maxLength: 1000") # instead of 1,000 2759 2769 2760 2770 class ReadonlyTest(TestCase): 2761 2771 urls = "regressiontests.admin_views.urls" -
tests/regressiontests/admin_views/models.py
538 538 age = models.PositiveIntegerField() 539 539 is_employee = models.NullBooleanField() 540 540 541 class PrePopulatedPostLargeSlug(models.Model): 542 """ 543 Regression test for #15938: a large max_length for the slugfield must not 544 be localized in prepopulated_fields_js.html or it might end up breaking 545 the javascript (ie, using THOUSAND_SEPARATOR ends up with maxLength=1,000) 546 """ 547 title = models.CharField(max_length=100) 548 published = models.BooleanField() 549 slug = models.SlugField(max_length=1000) 550 551 No newline at end of file