Bug 611504 - [Edit page] Some optional fields in /edit page "required"
This commit is contained in:
Родитель
d4200979c4
Коммит
33f0fd11f4
|
@ -107,8 +107,8 @@ class AddonFormDetails(AddonFormBase):
|
|||
|
||||
|
||||
class AddonFormSupport(AddonFormBase):
|
||||
support_url = TransField.adapt(forms.URLField)
|
||||
support_email = TransField.adapt(forms.EmailField)
|
||||
support_url = TransField.adapt(forms.URLField, {'required': False})
|
||||
support_email = TransField.adapt(forms.EmailField, {'required': False})
|
||||
|
||||
class Meta:
|
||||
model = Addon
|
||||
|
@ -144,7 +144,7 @@ class AddonFormTechnical(AddonFormBase):
|
|||
|
||||
class AddonForm(happyforms.ModelForm):
|
||||
name = forms.CharField(widget=TranslationTextInput,)
|
||||
homepage = forms.CharField(widget=TranslationTextInput,)
|
||||
homepage = forms.CharField(widget=TranslationTextInput, required=False)
|
||||
eula = forms.CharField(widget=TranslationTextInput,)
|
||||
description = forms.CharField(widget=TranslationTextInput,)
|
||||
developer_comments = forms.CharField(widget=TranslationTextInput,)
|
||||
|
|
|
@ -1208,6 +1208,18 @@ class TestEdit(test_utils.TestCase):
|
|||
for k in data:
|
||||
eq_(unicode(getattr(addon, k)), data[k])
|
||||
|
||||
def test_edit_basic_homepage_optional(self):
|
||||
data = dict(description='New description with <em>html</em>!',
|
||||
default_locale='es-ES',
|
||||
homepage='')
|
||||
|
||||
r = self.client.post(self.get_url('details', True), data)
|
||||
eq_(r.status_code, 200)
|
||||
addon = self.get_addon()
|
||||
|
||||
for k in data:
|
||||
eq_(unicode(getattr(addon, k)), data[k])
|
||||
|
||||
def test_edit_details_locale(self):
|
||||
addon = self.get_addon()
|
||||
addon.update(default_locale='en-US')
|
||||
|
@ -1250,6 +1262,28 @@ class TestEdit(test_utils.TestCase):
|
|||
|
||||
eq_(result, val)
|
||||
|
||||
def test_edit_support_optional_url(self):
|
||||
data = dict(support_email='sjobs@apple.com',
|
||||
support_url='')
|
||||
|
||||
r = self.client.post(self.get_url('support', True), data)
|
||||
eq_(r.status_code, 200)
|
||||
addon = self.get_addon()
|
||||
|
||||
for k in data:
|
||||
eq_(unicode(getattr(addon, k)), data[k])
|
||||
|
||||
def test_edit_support_optional_email(self):
|
||||
data = dict(support_email='',
|
||||
support_url='http://apple.com/')
|
||||
|
||||
r = self.client.post(self.get_url('support', True), data)
|
||||
eq_(r.status_code, 200)
|
||||
addon = self.get_addon()
|
||||
|
||||
for k in data:
|
||||
eq_(unicode(getattr(addon, k)), data[k])
|
||||
|
||||
def test_log(self):
|
||||
data = {'developer_comments': 'This is a test'}
|
||||
o = ActivityLog.objects
|
||||
|
|
|
@ -231,9 +231,9 @@ class TransField(_TransField, forms.CharField):
|
|||
"""
|
||||
|
||||
@staticmethod
|
||||
def adapt(cls):
|
||||
def adapt(cls, opts={}):
|
||||
"""Get a new TransField that subclasses cls instead of CharField."""
|
||||
return type('Trans%s' % cls.__name__, (_TransField, cls), {})
|
||||
return type('Trans%s' % cls.__name__, (_TransField, cls), opts)
|
||||
|
||||
|
||||
# Subclass list so that isinstance(list) in Django works.
|
||||
|
|
Загрузка…
Ссылка в новой задаче