
    Vh,                     t    d dl Z d dlmZ d dlmZmZmZ d dlmZ dZ	d
dZ
d Z G d d	ej                        Zy)    N)color_style)IntegrityError
migrationstransaction)Qz
    A problem arose migrating proxy model permissions for {old} to {new}.

      Permission(s) for {new} already existed.
      Codenames Q: {query}

    Ensure to audit ALL permissions for {old} and {new}.
c                 P   t               }| j                  dd      }| j                  dd      }|j                  j                  }| j	                         D ]  }|j
                  }|j                  s|j                  D 	cg c]  }	|	d|j                   }
}	t        |
      }|j                  D ]  \  }}|t        ||      z  } |j                  j                  |      }|j                  |d	      }|j                  |d
	      }|r|n|}|r|n|}	 t        j                  |      5  |j                  j!                  |      j#                  ||      j%                  |       ddd         yc c}	w # 1 sw Y   xY w# t&        $ r dj)                  |j*                  |j,                        }dj)                  |j*                  |j,                        }t.        j0                  j3                  |j5                  t4        j)                  |||                   Y w xY w)zk
    Update the content_type of proxy model permissions to use the ContentType
    of the proxy model.
    auth
PermissioncontenttypesContentType_)codename__in)codenamenameT)for_concrete_modelF)using)content_typeNz{}_{})oldnewquery)r   	get_model
connectionalias
get_models_metaproxydefault_permissions
model_namer   permissionsobjects
db_managerget_for_modelr   atomicr   filterupdater   format	app_labelmodelsysstdoutwriteWARNING)appsschema_editorreversestyler
   r   r   Modeloptsaction#proxy_default_permissions_codenamespermissions_queryr   r   content_type_managerconcrete_content_typeproxy_content_typeold_content_typenew_content_typer   r   s                        l/home/dcms/DCMS/lib/python3.12/site-packages/django/contrib/auth/migrations/0011_update_proxy_permissions.pyupdate_proxy_model_permissionsr<      s   
 ME5J..?K$$**E" {{zz>B>V>V/
4:vt//
+ /
 +NO".. 	ANHdH4!@@	A*22==eD 4 B Bd !C !
 2??e @ 
 29->S4;0AS	##%0 8""((/66%!1 7  &&6&7	8)/
 8 8
  	..!1!;!;=M=S=STC..!1!;!;=M=S=STCJJgnn#EVnWX	s1    E7F.=E<+F<F	FBH%$H%c                      t        | |d       y)zn
    Update the content_type of proxy model permissions to use the ContentType
    of the concrete model.
    T)r/   N)r<   )r-   r.   s     r;   revert_proxy_model_permissionsr>   ;   s    
 #4E    c                   <    e Zd ZddgZ ej
                  ee      gZy)	Migration)r	    0010_alter_group_name_max_length)r   0002_remove_content_type_nameN)	__name__
__module____qualname__dependenciesr   	RunPythonr<   r>   
operations r?   r;   rA   rA   C   s.    49L
 	
*,J	
Jr?   rA   )F)r)   django.core.management.colorr   	django.dbr   r   r   django.db.modelsr   r,   r<   r>   rA   rJ   r?   r;   <module>rN      s9    
 4 = = 'TF	
$$ 	r?   