3
(h%                 @   s   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZmZ d
d Zede_dS )z-
Built-in, globally-available admin actions.
    )messages)helpers)get_deleted_objectsmodel_ngettext)PermissionDenied)router)TemplateResponse)
force_text)ugettextugettext_lazyc             C   sj  | j j}|j}| j|sttj| j }t|||j| j	|\}}}}	|j
jdr|	 r|r^t|j }
|
rx"|D ]}t|}| j||| qpW |j  | j|td|
t| j|
d tj dS t|dkrt|j}n
t|j}|s|	rtdd|i }ntd}t| j	j||||gt|j |||	|tj| jd	}| j	j|_ t!|| j"pdd
||j#f d| dg|S )a\  
    Default action which deletes the selected objects.

    This action first displays a confirmation page which shows all the
    deleteable objects, or, if the user has no permission one of the related
    childs (foreignkeys), a "permission denied" message.

    Next, it deletes all selected objects and redirects back to the change list.
    postz)Successfully deleted %(count)d %(items)s.)countitemsN   zCannot delete %(name)snamezAre you sure?)
titleobjects_namedeletable_objectsmodel_countquerysetZperms_lacking	protectedoptsZaction_checkbox_namemediaz-admin/%s/%s/delete_selected_confirmation.htmlz*admin/%s/delete_selected_confirmation.htmlz'admin/delete_selected_confirmation.html)$modelZ_meta	app_labelZhas_delete_permissionr   r   Zdb_for_writer   userZ
admin_sitePOSTgetr   r	   Zlog_deletiondeleteZmessage_user_r   r   r   SUCCESSlenZverbose_nameZverbose_name_pluraldictZeach_contextr   r   ZACTION_CHECKBOX_NAMEr   r   Zcurrent_appr   Z%delete_selected_confirmation_templateZ
model_name)Z
modeladminrequestr   r   r   Zusingr   r   Zperms_neededr   nobjZobj_displayr   r   context r'   @/tmp/pip-install-q3hcpn_q/Django/django/contrib/admin/actions.pydelete_selected   sX    







r)   z'Delete selected %(verbose_name_plural)sN)__doc__Zdjango.contribr   Zdjango.contrib.adminr   Zdjango.contrib.admin.utilsr   r   Zdjango.core.exceptionsr   Z	django.dbr   Zdjango.template.responser   Zdjango.utils.encodingr	   Zdjango.utils.translationr
   r   r   r)   Zshort_descriptionr'   r'   r'   r(   <module>   s   J