##parameters=
# $Id: id_rename.py 681 2006-10-13 06:43:39Z henrik $
"""
Rename objects which ids are passed in the request.

Used within the folder_contents template.
"""

REQUEST = context.REQUEST

if context.portal_type in ('CoursesFolder',):
    return REQUEST.RESPONSE.redirect(context.absolute_url() + \
                                ('/academics_index?portal_status_message=%s' \
                                % ('Courses cannot be renamed',)))

new_ids = REQUEST['new_ids']
new_ids = [id.upper() for id in REQUEST['new_ids']]

here = context
if context.portal_type == "University":
    here = context.academics


here.manage_renameObjects(REQUEST['ids'], new_ids, REQUEST)

return REQUEST.RESPONSE.redirect(here.absolute_url() + \
                                ('/academics_index?portal_status_message=%s' \
                                % ('psm_item(s)_renamed',)))
