Exemple #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)
Exemple #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)
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()
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()
Exemple #5
0
 def save(self, *args, **kwargs):
     self.search_name = utils.clear_text(self.name).lower()
     super(City, self).save(*args, **kwargs)
Exemple #6
0
 def get_city(self, name):
     clean_name = utils.clear_text(name).lower()
     return self.filter(search_name=clean_name)
Exemple #7
0
 def save(self, *args, **kwargs):
     self.search_name = utils.clear_text(self.name).lower()
     super(City, self).save(*args, **kwargs)