def localize_fieldname(self, name, model=None, lang=None):
     """Localizes translatable field name"""
     model = model or self.model
     trans_opts = translator.get_options_for_model(model)
     if name in trans_opts.fields:
         return localize_fieldname(name, lang)
     return name
Пример #2
0
 def test_add(self):
     response = self.client.post(
         urlresolvers.reverse("geo_location_detail", kwargs={"pk": settings.LOCATION_ROOT}),
         {localize_fieldname("name"): "Ukraine", "name_ascii": "Ukraine", "iso_alpha2": "UK", "iso_alpha3": "UKR"},
     )
     self.assertEqual(response.status_code, 200)
     self.assertNotContains(response, "Ukraine")
 def localize_fieldname(self, name, model=None, lang=None):
     """Localizes translatable field name"""
     model = model or self.model
     trans_opts = translator.get_options_for_model(model)
     if name in trans_opts.fields:
         return localize_fieldname(name, lang)
     return name
Пример #4
0
 def test_add(self):
     response = self.client.post(
         urlresolvers.reverse(
             'geo_location_detail',
             kwargs={'pk': settings.LOCATION_ROOT, }
         ), {localize_fieldname('name'): 'Ukraine',
             'name_ascii': 'Ukraine',
             'iso_alpha2': 'UK',
             'iso_alpha3': 'UKR',
             'parent': settings.LOCATION_ROOT,
         }
     )
     self.assertEqual(response.status_code, 302)
     """
Пример #5
0
 def test_root(self):
     response = self.client.get(
         urlresolvers.reverse(
             'geo_location_detail',
             kwargs={'pk': settings.LOCATION_ROOT, }
         )
     )
     self.assertEqual(response.status_code, 200)
     self.assertContains(
         response,
         Location.objects.get(pk=settings.LOCATION_ROOT).name
     )
     self.assertContains(
         response,
         CountryForm().fields[localize_fieldname('name')].label
     )
Пример #6
0
 def test_root(self):
     response = self.client.get(urlresolvers.reverse("geo_location_detail", kwargs={"pk": settings.LOCATION_ROOT}))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, Location.objects.get(pk=settings.LOCATION_ROOT).name)
     self.assertContains(response, CountryForm().fields[localize_fieldname("name")].label)