Ignore:
Timestamp:
30 Apr 2007, 15:37:48 (18 years ago)
Author:
joachim
Message:

improve or fix id_rename and catalog handling

Location:
WAeUP_SRP/trunk/skins/waeup_default
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_default/id_rename.py

    r681 r1724  
    66Used within the folder_contents template.
    77"""
     8try:
     9    from Products.zdb import set_trace
     10except:
     11    def set_trace():
     12        pass
     13import logging
     14logger = logging.getLogger('Skins.id_rename')
     15mtool = context.portal_membership
     16member = mtool.getAuthenticatedMember()
    817
    918REQUEST = context.REQUEST
     
    1423                                % ('Courses cannot be renamed',)))
    1524
     25old_ids = REQUEST['ids']
    1626new_ids = REQUEST['new_ids']
    1727new_ids = [id.upper() for id in REQUEST['new_ids']]
     
    2030if context.portal_type == "University":
    2131    here = context.academics
    22 
     32pt = context.portal_type
     33mt = context.meta_type
     34logger.info('%s starting renaming %s to %s' % (member,old_ids,new_ids))
    2335
    2436here.manage_renameObjects(REQUEST['ids'], new_ids, REQUEST)
     37if pt == 'University':
     38    for faculty in old_ids:
     39        students = context.students_catalog(faculty=faculty)
     40        student_ids = [s.id for s in students]
     41        data = {}
     42        new_fid = new_ids[old_ids.index(faculty)]
     43        data['faculty'] = new_fid
     44        for sid in student_ids:
     45            data['id'] = sid
     46            context.students_catalog.modifyRecord(**data)
     47        courses = context.courses_catalog(faculty=faculty)
     48        courses_ids = [c.code for c in courses]
     49        for cid in courses_ids:
     50            data['code'] = cid
     51            context.courses_catalogModify(**data)
     52elif pt == 'Faculty':
     53    for department in old_ids:
     54        students = context.students_catalog(department=department)
     55        student_ids = [s.id for s in students]
     56        data = {}
     57        new_did = new_ids[old_ids.index(department)]
     58        data['department'] = new_did
     59        for sid in student_ids:
     60            data['id'] = sid
     61            context.students_catalog.modifyRecord(**data)
     62        courses = context.courses_catalog(department=department)
     63        courses_ids = [c.code for c in courses]
     64        for cid in courses_ids:
     65            data['code'] = cid
     66            context.courses_catalogModify(**data)
     67logger.info('%s finished renaming %s to %s' % (member,old_ids,new_ids))
    2568
    2669return REQUEST.RESPONSE.redirect(here.absolute_url() + \
  • WAeUP_SRP/trunk/skins/waeup_default/id_rename_form.pt

    r586 r1724  
    4646</div><!-- tal:condition="here/folder_rename_items" -->
    4747
    48 <div tal:condition="not: here/folder_rename_items">
     48<div tal:condition="not: here/academics_rename_items">
    4949
    5050  <p i18n:translate="help_no_items_to_rename">
  • WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py

    r1716 r1724  
    3434if new_id is not None:
    3535    id = new_id
    36 if type_name == "Course": # disable if handled by event
     36if type_name == "xxxCourse": # disabled handled by event
    3737    d = {}
    3838    ptl = request.get('PATH_TRANSLATED').split('/')
  • WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py

    r1716 r1724  
    102102                                             )
    103103        logger.info('%s edited %s of %s' % (member,context.id,student_id))
    104     elif context.portal_type == "Course": # disable if handled by events
     104    elif context.portal_type == "xxxxCourse": # disabled handled by events
    105105        dd = {}
    106106        dd.update(ds) # ds is not a real dictionary
Note: See TracChangeset for help on using the changeset viewer.