Exemplo n.º 1
0
    def test_clear_text(self):
        """Should remove combining marks from text"""
        sp = utils.clear_text('São Paulo')
        rand = utils.clear_text('ç~ã`é´â^ô')

        self.assertEqual('Sao Paulo', sp)
        self.assertEqual('caeao', rand)
Exemplo n.º 2
0
    def test_clear_text(self):
        """Should remove combining marks from text"""
        sp = utils.clear_text("São Paulo")
        rand = utils.clear_text("ç~ã`é´â^ô")

        self.assertEqual("Sao Paulo", sp)
        self.assertEqual("caeao", rand)
Exemplo n.º 3
0
def migrate_cities(apps, scheme_editor):
    """Updates the city based on the new model"""
    Pet = apps.get_model('meupet', 'Pet')
    City = apps.get_model('cities', 'City')

    for pet in Pet.objects.all():
        if pet.city:
            city = City.objects.filter(search_name=utils.clear_text(pet.city.city).lower()).first()
            if city:
                pet.new_city = city
                pet.save()
Exemplo n.º 4
0
def migrate_cities(apps, scheme_editor):
    """Updates the city based on the new model"""
    Pet = apps.get_model('meupet', 'Pet')
    City = apps.get_model('cities', 'City')

    for pet in Pet.objects.all():
        if pet.city:
            city = City.objects.filter(
                search_name=utils.clear_text(pet.city.city).lower()).first()
            if city:
                pet.new_city = city
                pet.save()
Exemplo n.º 5
0
 def save(self, *args, **kwargs):
     self.search_name = utils.clear_text(self.name).lower()
     super(City, self).save(*args, **kwargs)
Exemplo n.º 6
0
 def get_city(self, name):
     clean_name = utils.clear_text(name).lower()
     return self.filter(search_name=clean_name)
Exemplo n.º 7
0
 def save(self, *args, **kwargs):
     self.search_name = utils.clear_text(self.name).lower()
     super(City, self).save(*args, **kwargs)