From 162b059f489d3b70db911d7ac60737d73aea5e49 Mon Sep 17 00:00:00 2001 From: Vaidik Kapoor Date: Fri, 6 Jan 2012 17:23:41 +0530 Subject: [PATCH] Ensure clean disply of blurb on homepage. Monthly pick admin form limits blurb to 200 chars. Blurb gets vertically truncated when more than 4 lines. (bug 715577) --- apps/zadmin/forms.py | 4 +++- apps/zadmin/tests/test_views.py | 8 ++++++++ media/css/impala/promos.less | 3 +++ media/js/impala/homepage.js | 1 + media/js/zamboni/discovery_pane.js | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/zadmin/forms.py b/apps/zadmin/forms.py index 507c5e9045..a5b41e0da3 100644 --- a/apps/zadmin/forms.py +++ b/apps/zadmin/forms.py @@ -189,12 +189,14 @@ class OAuthConsumerForm(happyforms.ModelForm): class MonthlyPickForm(happyforms.ModelForm): image = forms.CharField(required=False) + blurb = forms.CharField(max_length=200, + widget=forms.Textarea(attrs={'cols': 20, + 'rows': 2})) class Meta: model = MonthlyPick widgets = { 'addon': forms.TextInput(), - 'blurb': forms.Textarea(attrs={'cols': 20, 'rows': 2}) } diff --git a/apps/zadmin/tests/test_views.py b/apps/zadmin/tests/test_views.py index 478ba14871..cadf82ffc9 100644 --- a/apps/zadmin/tests/test_views.py +++ b/apps/zadmin/tests/test_views.py @@ -1121,6 +1121,14 @@ class TestMonthlyPick(amo.tests.TestCase): eq_(MonthlyPick.objects.count(), 2) eq_(MonthlyPick.objects.all()[1].locale, '') + def test_insert_long_blurb(self): + dupe = initial(self.f) + dupe.update(id='', blurb='x' * 201, locale='en-US') + data = formset(initial(self.f), dupe, initial_count=1) + r = self.client.post(self.url, data) + eq_(r.context['form'].errors[1]['blurb'][0], + 'Ensure this value has at most 200 characters (it has 201).') + def test_success_update(self): d = initial(self.f) d.update(locale='fr') diff --git a/media/css/impala/promos.less b/media/css/impala/promos.less index 7a4fb6294f..e9a86445b9 100644 --- a/media/css/impala/promos.less +++ b/media/css/impala/promos.less @@ -178,6 +178,9 @@ max-height: 120px; } } + .blurb > p { + height: 68px; + } } .html-rtl #monthly .thumb { diff --git a/media/js/impala/homepage.js b/media/js/impala/homepage.js index 239f815a1e..d69427d077 100644 --- a/media/js/impala/homepage.js +++ b/media/js/impala/homepage.js @@ -31,6 +31,7 @@ function initPromos($context) { }); $('.addons h3', $promos).truncate({dir: 'h'}); $('.addons .desc', $promos).truncate({dir: 'v'}); + $('#monthly .blurb > p').truncate({dir: 'v'}); $('.install', $promos).installButton(); }); $('.toplist .name').truncate({showTitle: true}); diff --git a/media/js/zamboni/discovery_pane.js b/media/js/zamboni/discovery_pane.js index b77944f60b..838e12b337 100644 --- a/media/js/zamboni/discovery_pane.js +++ b/media/js/zamboni/discovery_pane.js @@ -61,6 +61,7 @@ function initTrunc() { // Trim the add-on title and description text to fit. $('.htruncate').truncate({dir: 'h'}); $('.vtruncate').truncate({dir: 'v'}); + $('#monthly .blurb > p').truncate({dir: 'v'}); $(window).resize(debounce(function() { $('.htruncate').truncate({dir: 'h'}); $('.vtruncate').truncate({dir: 'v'});