Ignore:
Timestamp:
13 Feb 2015, 06:31:37 (10 years ago)
Author:
Henrik Bettermann
Message:

Add department mover.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r11891 r12609  
    2020import grok
    2121import zope.location.location
     22from zope.event import notify
     23from zope.catalog.interfaces import ICatalog
    2224from zope.component.interfaces import IFactory
    2325from zope.interface import implementedBy
     
    9496        return longtitle(self)
    9597
     98    def moveDepartment(self, facname, depname):
     99        """ Move department to new department named depname in
     100        faculty named facname.
     101
     102        """
     103        self.moved = True
     104        fac = grok.getSite()['faculties'][facname]
     105        oldcode = self.code
     106        fac[depname] = self
     107        del self.__parent__[oldcode]
     108        fac[depname].code = depname
     109        #self.__parent__._p_changed = True
     110        cat = getUtility(ICatalog, name='students_catalog')
     111        results = cat.searchResults(depcode=(oldcode, oldcode))
     112        for student in results:
     113            notify(grok.ObjectModifiedEvent(student))
     114            student.__parent__.logger.info(
     115                '%s - Department moved' % student.__name__)
     116        return
     117
    96118class DepartmentFactory(grok.GlobalUtility):
    97119    """A factory for department containers.
Note: See TracChangeset for help on using the changeset viewer.