Exemplo n.º 1
0
    def handleApply(self, action):
        data, errors = self.extractData()
        typestool = getToolByName(self.context, 'portal_types')
        wftool = getToolByName(self.context, 'portal_workflow')
        identifier = queryUtility(IIDNormalizer).normalize(data['title'])
        if not self.context.has_key('sessions'):
            unrestrictedExec(
                typestool.constructContent,
                type_name='Folder',
                container=self.context,
                id='sessions'
            )
            unrestrictedExec(
                self.context['sessions'].setTitle,
                'Sessions'
            )
            unrestrictedExec(
                wftool.doActionFor,
                self.context['sessions'],
                'publish'
            )
            self.context['sessions'].reindexObject()
        container = self.context['sessions']
        identifier = str(len(container.keys()) + 1)
        if data['subject']:
            subject = list([i for i in data['subject'].split('\n') if i])
        else:
            subject = []
        del data['subject']

        level = data['level']
        del data['level']
        speaker = data['speaker']
        del data['speaker']
        session_type = data['session_type']
        del data['session_type']

        unrestrictedExec(
            typestool.constructContent,
            type_name="BarcampSession",
            container=container,
            id=identifier,
            **data
        )
        
        content = container[identifier]
        schema = content.Schema()
        schema['subject'].set(content, subject)
        schema['level'].set(content, level)
        schema['speaker'].set(content, speaker)
        schema['session_type'].set(content, session_type)
        schema['startDate'].set(content, self.context.startDate)
        schema['endDate'].set(content, self.context.endDate)
        unrestrictedExec(
            wftool.doActionFor,
            container[identifier], 
            'publish'
        )
        content.reindexObject()
        self.request.response.redirect(content.absolute_url())
Exemplo n.º 2
0
    def handleApply(self, action):
        data, errors = self.extractData()
        typestool = getToolByName(self.context, 'portal_types')
        # wftool = getToolByName(self.context, 'portal_workflow')
        plone_utils = getToolByName(self.context, 'plone_utils')
        # if not self.context.has_key('registrations'):
        if 'registrations' not in self.context:
            unrestrictedExec(
                typestool.constructContent,
                type_name='Folder',
                container=self.context,
                id='registrations'
            )
            unrestrictedExec(
                self.context['registrations'].setTitle,
                'Registrations'
            )
            cschema = self.context['registrations'].Schema()
            cschema['excludeFromNav'].set(
                self.context['registrations'],
                True
            )
            self.context['registrations'].reindexObject()
        container = self.context['registrations']
        identifier = str(len(container.keys()) + 1)

        unrestrictedExec(
            typestool.constructContent,
            type_name='BarcampParticipant',
            container=container,
            id=identifier,
            **data
        )
        plone_utils.addPortalMessage(
            _(u'Thank you for your submission. You are now registered'),
            'info'
        )
        self.request.response.redirect(self.context.absolute_url())