def handleNewRegistration(reg, event):
    parentevent = reg.__parent__.__parent__
    regfolderish = reg.__parent__
    reg.manage_setLocalRoles('admin', ["Owner"])
    reg.reindexObjectSecurity()

    hasWaitingList = parentevent.enableWaitingList
    hasPrivateReg = parentevent.privateRegistration
    maxreg = parentevent.maxRegistrations
    numRegApproved = getNumApprovedAndConfirmed(regfolderish)

    workflowTool = getToolByName(reg, "portal_workflow")

    # private registration means manual adding of registrations
    if hasPrivateReg:
        #workflowTool.doActionFor(reg, 'approve')
        executeUnderSpecialRole(parentevent.__parent__,
                                "Manager",
                                workflowTool.doActionFor,
                                reg,
                                'approve')
    # haven't hit max, 'approve'
    elif maxreg == None or numRegApproved < maxreg:
        #workflowTool.doActionFor(reg, 'approve')
        executeUnderSpecialRole(parentevent.__parent__,
                                "Manager",
                                workflowTool.doActionFor,
                                reg,
                                'approve')
        sendEMail(parentevent, 'thank you', [reg.email], reg)
    # waiting list, and hit max == remain 'submitted' (on waiting list)
    elif hasWaitingList:
        sendEMail(parentevent, 'on waiting list', [reg.email], reg)
    # all other cases, 'deny'
    else:
        workflowTool.doActionFor(reg, 'deny')
        sendEMail(parentevent, 'registration full', [reg.email], reg)
 def room_available(self):
     event = self.event
     num = getNumApprovedAndConfirmed(self.context)
     if not event.maxRegistrations:
         return True
     return num < event.maxRegistrations