##parameters=groupids=None
model = context.REQUEST.model
view = context
deleted_ids = []
not_deleted_ids = []
message_type = 'feedback'

if groupids is None:
    return view.tab_access_groups(message_type="error", message="Nothing was selected, so nothing was deleted.")

for id in groupids:
    if model.is_delete_allowed(id):
        deleted_ids.append(id)
    else:
        not_deleted_ids.append(id)
 
model.action_delete(groupids)

if deleted_ids:
    if not_deleted_ids:
        message = 'Deleted %s, <span class="error">but could not delete %s.</span>' % (view.quotify_list(deleted_ids),
            view.quotify_list(not_deleted_ids))
    else:
        message = 'Deleted %s.' % view.quotify_list(deleted_ids)
else:
    message = 'Could not delete %s.' % view.quotify_list(not_deleted_ids)
    message_type = 'error'

return view.tab_access_groups(message_type=message_type, message=message)
