@login_required
def bulk_action(request, msgtype='inbox'):
 msgids = request.POST.getlist('id')
 if (len(msgids) == 0):
  contrib_messages.add_message(request, contrib_messages.ERROR, _('No messages selected. Please try again.'))
 elif ('delete' in request.POST):
  return delete(request, msgtype=msgtype)
 elif (('mark_read' in request.POST) and (msgtype == 'inbox')):
  messages = InboxMessage.objects.filter(pk__in=msgids, to=request.user)
  messages.update(read=True)
 elif (('mark_unread' in request.POST) and (msgtype == 'inbox')):
  messages = InboxMessage.objects.filter(pk__in=msgids, to=request.user)
  messages.update(read=False)
 return redirect(('messages.%s' % msgtype))

@ login_required def bulk_action ( request , msgtype = 'inbox' ) : msgids = request . POST . getlist ( 'id' ) if ( len ( msgids ) == 0 ) : contrib_messages . add_message ( request , contrib_messages . ERROR , _ ( 'No messages selected. Please try again.' ) ) elif ( 'delete' in request . POST ) : return delete ( request , msgtype = msgtype ) elif ( ( 'mark_read' in request . POST ) and ( msgtype == 'inbox' ) ) : messages = InboxMessage . objects . filter ( pk__in = msgids , to = request . user ) messages . update ( read = True ) elif ( ( 'mark_unread' in request . POST ) and ( msgtype == 'inbox' ) ) : messages = InboxMessage . objects . filter ( pk__in = msgids , to = request . user ) messages . update ( read = False ) return redirect ( ( 'messages.%s' % msgtype ) )
apply action to selected messages .