From c6b5763868d4cd0de4de58ec3ed7ae24561e3244 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 13 Mar 2018 16:57:56 -0500 Subject: [PATCH] Fix project variable --- readthedocs/projects/forms.py | 2 +- .../rtd_tests/tests/test_project_forms.py | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index 8e78c88e909..696e6d8fbe7 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -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.' diff --git a/readthedocs/rtd_tests/tests/test_project_forms.py b/readthedocs/rtd_tests/tests/test_project_forms.py index 9fdd8a00129..10f0ac82102 100644 --- a/readthedocs/rtd_tests/tests/test_project_forms.py +++ b/readthedocs/rtd_tests/tests/test_project_forms.py @@ -202,11 +202,13 @@ 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', @@ -214,11 +216,13 @@ def test_cant_change_language_to_translation_lang(self): ) # 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',