def test_hvad_tabs(self): ex = MultilingualExample1( char_1='one', char_2='two', ) ex.save() self._testuser() self.client.login(username='******', password='******') response = self.client.get('/de/admin/placeholderapp/multilingualexample1/%d/' % ex.pk) self.assertContains(response, '<input type="hidden" class="language_button selected" name="de" />')
def test_multi_edit(self): user = self.get_staff() page = create_page('Test', 'col_two.html', 'en', published=True) title = create_title("fr", "test", page) exm = MultilingualExample1() exm.translate("en") exm.char_1 = 'one' exm.char_2 = 'two' exm.save() exm.translate("fr") exm.char_1 = "un" exm.char_2 = "deux" exm.save() request = self.get_page_request(page, user, edit=True) response = detail_view_multi(request, exm.pk) self.assertContains( response, '<h1><span id="cms_placeholder-model-placeholderapp-%s-%s" class="cms_placeholder-generic">one</span></h1>' % (exm.pk, 'char_1')) self.assertContains( response, "/admin/placeholderapp/multilingualexample1/edit-field/%s/en/" % exm.pk) self.assertTrue( re.search(self.edit_fields_rx % "char_1", response.content.decode('utf8'))) self.assertTrue( re.search(self.edit_fields_rx % "char_1%2Cchar_2", response.content.decode('utf8'))) with SettingsOverride(LANGUAGE_CODE="fr"): request = self.get_page_request(title.page, user, edit=True, lang_code="fr") response = detail_view_multi(request, exm.pk) self.assertContains( response, '<h1><span id="cms_placeholder-model-placeholderapp-%s-%s" class="cms_placeholder-generic">un</span></h1>' % (exm.pk, 'char_1')) self.assertContains( response, "/admin/placeholderapp/multilingualexample1/edit-field/%s/fr/" % exm.pk) self.assertTrue( re.search(self.edit_fields_rx % "char_1%2Cchar_2", response.content.decode('utf8')))
def test_edit_field_multilingual(self): from django.contrib.admin import site exadmin = site._registry[MultilingualExample1] user = self.get_superuser() page = create_page('Test', 'col_two.html', 'en', published=True) title = create_title("fr", "test", page) exm = MultilingualExample1() exm.translate("en") exm.char_1 = 'one' exm.char_2 = 'two' exm.save() exm.translate("fr") exm.char_1 = "un" exm.char_2 = "deux" exm.save() request = self.get_page_request(page, user, edit=True) request.GET['edit_fields'] = 'char_2' response = exadmin.edit_field(request, exm.pk, "en") self.assertContains(response, 'id="id_char_2"') self.assertContains(response, 'value="two"') response = exadmin.edit_field(request, exm.pk, "fr") self.assertContains(response, 'id="id_char_2"') self.assertContains(response, 'value="deux"') with SettingsOverride(LANGUAGE_CODE="fr"): request = self.get_page_request(title.page, user, edit=True, lang_code="fr") request.GET['edit_fields'] = 'char_2' response = exadmin.edit_field(request, exm.pk, "fr") self.assertContains(response, 'id="id_char_2"') self.assertContains(response, 'value="deux"')