
    =
j:                    f    d dl mZ d dlZd dlZd dlmZmZ d Zd Z G d dej                        Z	y)    )annotationsN)
migrationsmodelsc                R   t        | xs d      j                         j                         }|syt        j                  d|      }dj                  d |D              }t        j                  dd|t        j                        }t        j                  dd|      j                         S )N NFKDc              3  L   K   | ]  }t        j                  |      r|  y w)N)unicodedata	combining).0chars     </backend/istat/migrations/0005_municipality_normalization.py	<genexpr>z/_normalize_municipality_name.<locals>.<genexpr>   s     LDD0E0Ed0K4Ds   $$z[\W_]+ )flagsz\s+)	strstriplowerr
   	normalizejoinresubUNICODE)valuetexts     r   _normalize_municipality_namer   	   s    u{!!#))+D  .D77LDLLD66)S$bjj9D66&#t$**,,    c                P   | j                  dd      }|j                  j                         j                         D ]i  }t	        |j
                        |_        |j                  r-|j                  j                         j                         |_        |j                  ddg       k y )NistatIstatMunicipalitynormalized_nameprovince)update_fields)	get_modelobjectsalliteratorr   namer!   r"   r   uppersave)appsschema_editorr    municipalitys       r   populate_normalized_namesr.      s    w0CD)11557@@B'CLDUDU'V$  $0$9$9$?$?$A$G$G$IL!):J(GH	 Cr   c                     e Zd ZdgZ ej
                  dd ej                  ddd             ej
                  dd ej                  d	             ej                  e
ej                  j                         ej                  d ej                  d
gd             ej                  d ej                  d
dgd             ej                  d ej                  dgd            gZy)	Migration)r   30004_istatcredential_istatauditlog_istatsynchistoryistatmunicipalityr!   T   )blankdb_index
max_length)
model_namer(   field	is_active)defaultr"   istat_muni_province_idx)fieldsr(   )r7   indexistat_muni_prov_name_idxistat_muni_active_idxN)__name__
__module____qualname__dependenciesr   AddFieldr   	CharFieldBooleanField	RunPythonr.   noopAddIndexIndex
operations r   r   r0   r0      s   HL
 	
*""&""M	

 	
*%&%%d3	

 	
6
8L8L8Q8QR
*&,,zl9RS	
 	
*&,,"$56/	
 	
*&,,{m:QR	
/Jr   r0   )

__future__r   r   r
   	django.dbr   r   r   r.   r0   rL   r   r   <module>rO      s.    " 	  (-I 
$$  r   