User can remove/change own collection's description (bug 694373)

This commit is contained in:
Vaidik Kapoor 2012-01-08 02:53:58 +05:30 коммит произвёл Chris Van
Родитель 3d4cc7b58f
Коммит ab0cf61e90
2 изменённых файлов: 27 добавлений и 5 удалений

Просмотреть файл

@ -145,9 +145,6 @@ class CollectionForm(ModelForm):
def clean_description(self):
description = self.cleaned_data['description']
if description.strip() == '':
description = None
return description
def clean_slug(self):
@ -188,6 +185,7 @@ class CollectionForm(ModelForm):
if icon:
c.icontype = 'image/png'
c.save()
if icon:

Просмотреть файл

@ -291,7 +291,8 @@ class TestCRUD(amo.tests.TestCase):
assert self.client.login(username='regular@mozilla.com',
password='password')
def create_collection(self):
def create_collection(self, **kw):
self.data.update(kw)
r = self.client.post(self.add_url, self.data, follow=True)
eq_(r.status_code, 200)
return r
@ -370,7 +371,7 @@ class TestCRUD(amo.tests.TestCase):
'/en-US/firefox/collections/admin/%s/' % self.slug)
c = Collection.objects.get(slug=self.slug)
eq_(unicode(c.name), self.data['name'])
eq_(c.description, None)
eq_(c.description, '')
eq_(c.addons.all()[0].id, 3615)
def test_duplicate_slug(self):
@ -444,6 +445,29 @@ class TestCRUD(amo.tests.TestCase):
c = Collection.objects.get(slug='halp')
eq_(unicode(c.name), 'HALP')
def test_edit_description(self):
self.create_collection()
url = reverse('collections.edit', args=['admin', self.slug])
self.data['description'] = 'abc'
edit_url = Collection.objects.get(slug=self.slug).edit_url()
r = self.client.post(url, self.data)
self.assertRedirects(r, edit_url, 302)
eq_(unicode(Collection.objects.get(slug=self.slug).description),
'abc')
def test_edit_no_description(self):
self.create_collection(description='abc')
eq_(Collection.objects.get(slug=self.slug).description, 'abc')
url = reverse('collections.edit', args=['admin', self.slug])
self.data['description'] = ''
edit_url = Collection.objects.get(slug=self.slug).edit_url()
r = self.client.post(url, self.data)
self.assertRedirects(r, edit_url, 302)
eq_(unicode(Collection.objects.get(slug=self.slug).description),
'')
def test_edit_spaces(self):
"""Let's put lots of spaces and see if they show up."""
self.create_collection()