Пример #1
0
def commis_delete_confirmation(context, obj):
    request = context["request"]
    opts = obj._meta
    deleted_objects, perms_needed, protected = get_deleted_objects(obj, request)
    return {
        "object": obj,
        "object_name": force_unicode(opts.verbose_name),
        "deleted_objects": deleted_objects,
        "perms_lacking": perms_needed,
        "protected": protected,
        "opts": opts,
    }
Пример #2
0
 def delete(self, request, name):
     opts = self.model._meta
     obj = self.get_object(request, name)
     self.assert_permission(request, 'delete', obj)
     deleted_objects, perms_needed, protected = get_deleted_objects(obj, request)
     if request.POST: # The user has already confirmed the deletion.
         if perms_needed:
             raise PermissionDenied
         obj.delete()
         messages.success(request, _(u'Deleted %s %s')%(opts.verbose_name, obj))
         return self.change_redirect(request, 'delete', obj)
     return TemplateResponse(request, ('commis/%s/delete.html'%self.get_app_label(), 'commis/generic/delete.html'), {
         'opts': opts,
         'obj': obj,
         'action': 'delete',
         'block_nav': self.block_nav(request, obj),
         'deleted_objects': deleted_objects,
         'perms_lacking': perms_needed,
         'protected': protected,
     })