Skip to content

Commit

Permalink
Fix project variable
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Mar 13, 2018
1 parent 497ee67 commit c6b5763
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Meta(object):

def clean_language(self):
language = self.cleaned_data['language']
project = self.data['project']
project = self.instance
if project:
if project.translations.filter(language=language).exists():
msg = 'There is a translation for the "{lang}" language.'
Expand Down
24 changes: 14 additions & 10 deletions readthedocs/rtd_tests/tests/test_project_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,27 @@ def test_cant_change_language_to_translation_lang(self):
self.project_a_es.save()

# Parent project tries to change lang
form = ProjectExtraForm({
'project': self.project_a_es,
'documentation_type': 'sphinx',
'language': 'en',
})
form = ProjectExtraForm(
{
'documentation_type': 'sphinx',
'language': 'en',
},
instance=self.project_a_es
)
self.assertFalse(form.is_valid())
self.assertIn(
'There is a translation for the',
''.join(form.errors['language'])
)

# Translation tries to change lang
form = ProjectExtraForm({
'project': self.project_b_en,
'documentation_type': 'sphinx',
'language': 'es',
})
form = ProjectExtraForm(
{
'documentation_type': 'sphinx',
'language': 'es',
},
instance=self.project_b_en
)
self.assertFalse(form.is_valid())
self.assertIn(
'The translation can not have the same language',
Expand Down

0 comments on commit c6b5763

Please sign in to comment.