<s> """<STR_LIT>""" <EOL> from django . core . exceptions import PermissionDenied <EOL> from django . contrib import messages <EOL> from django . contrib . admin import helpers <EOL> from django . contrib . admin . util import get_deleted_objects , model_ngettext <EOL> from django . db import router <EOL> from django . template . response import TemplateResponse <EOL> from django . utils . encoding import force_text <EOL> from django . utils . translation import ugettext_lazy , ugettext as _ <EOL> def delete_selected ( modeladmin , request , queryset ) : <EOL> """<STR_LIT>""" <EOL> opts = modeladmin . model . _meta <EOL> app_label = opts . app_label <EOL> if not modeladmin . has_delete_permission ( request ) : <EOL> raise PermissionDenied <EOL> using = router . db_for_write ( modeladmin . model ) <EOL> deletable_objects , perms_needed , protected = get_deleted_objects ( <EOL> queryset , opts , request . user , modeladmin . admin_site , using ) <EOL> if request . POST . get ( '<STR_LIT>' ) : <EOL> if perms_needed : <EOL> raise PermissionDenied <EOL> n = queryset . count ( ) <EOL> if n : <EOL> for obj in queryset : <EOL> obj_display = force_text ( obj ) <EOL> modeladmin . log_deletion ( request , obj , obj_display ) <EOL> queryset . delete ( ) <EOL> modeladmin . message_user ( request , _ ( "<STR_LIT>" ) % { <EOL> "<STR_LIT:count>" : n , "<STR_LIT>" : model_ngettext ( modeladmin . opts , n ) <EOL> } , messages . SUCCESS ) <EOL> return None <EOL> if len ( queryset ) == <NUM_LIT:1> : <EOL> objects_name = force_text ( opts . verbose_name ) <EOL> else : <EOL> objects_name = force_text ( opts . verbose_name_plural ) <EOL> if perms_needed or protected : <EOL> title = _ ( "<STR_LIT>" ) % { "<STR_LIT:name>" : objects_name } <EOL> else : <EOL> title = _ ( "<STR_LIT>" ) <EOL> context = { <EOL> "<STR_LIT:title>" : title , <EOL> "<STR_LIT>" : objects_name , <EOL> "<STR_LIT>" : [ deletable_objects ] , <EOL> '<STR_LIT>' : queryset , <EOL> "<STR_LIT>" : perms_needed , <EOL> "<STR_LIT>" : protected , <EOL> "<STR_LIT>" : opts , <EOL> "<STR_LIT>" : app_label , <EOL> '<STR_LIT>' : helpers . ACTION_CHECKBOX_NAME , <EOL> } <EOL> return TemplateResponse ( request , modeladmin . delete_selected_confirmation_template or [ <EOL> "<STR_LIT>" % ( app_label , opts . model_name ) , <EOL> "<STR_LIT>" % app_label , <EOL> "<STR_LIT>" <EOL> ] , context , current_app = modeladmin . admin_site . name ) <EOL> delete_selected . short_description = ugettext_lazy ( "<STR_LIT>" ) </s>
