B
    CDb‡  ã               @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é    )Údefaultdict)ÚGeneralActionDeletec                   s   e Zd Z‡ fdd„Z‡  ZS )ÚGroupDeletec                s²   ddl m} ttƒ}|ƒ }i }|jjd d dd¡}x|D ]\}}||  |¡ q:W xF| jD ]<}|jpj|j	}	||	 }
t
|
ƒdkr‚q\d d |
¡|¡||	< q\W tt| ƒj|d d S )	Nr   )Úget_user_model)ÚgroupsZ
groups__idZusernamezDDelete Failed: There is related user(s) {} still using the group {}.z, )Úremove_denied)Zdjango.contrib.authr   r   ÚlistZobjectsZexcludeZvalues_listÚappendÚidZpkÚlenÚformatÚjoinÚsuperr   Úaction)Úselfr   Zgroup_2_ownerZ	UserModelr   Z	all_usersÚgÚuÚobjZobj_idZrelated_user)Ú	__class__© ú:G:\easytimepro\master/mysite/base\actions\group_actions.pyr      s    zGroupDelete.action)Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__r   r   )r   r   r      s   r   N)Úcollectionsr   Zmysite.admin.actionr   r   r   r   r   r   Ú<module>   s   