Пример #1
0
    def test_save_attendees(self):
        """ """
        portal = self.layer['portal']
        app = self.layer['app']
        z2.login(app['acl_users'], SITE_OWNER_NAME)
        self.register_users()
        event = self._create_event()
        storage = IAttendeesStorage(event)
        self.assertFalse(hasattr(storage, 'internal_attendees'))
        self.assertFalse(hasattr(storage, 'external_attendees'))
        self.assertFalse(hasattr(storage, 'groups'))

        data = {
            'internal_attendees': ['max-musterman', 'john-doe','Administrators'],
            'external_attendees': [{'name':'John Smith', 
                                    'email':'*****@*****.**',}],
        }
        utils.save_attendees(event, data)

        self.assertTrue(hasattr(storage, 'internal_attendees'))
        self.assertTrue(hasattr(storage, 'external_attendees'))
        self.assertTrue(hasattr(storage, 'groups'))

        self.assertEqual(storage.internal_attendees, [
            {'attending': None, 'id': 'max-musterman', 'name': 'Max Musterman', 'email': '*****@*****.**'},
            {'attending': None, 'id': 'john-doe', 'name': 'John Doe', 'email': '*****@*****.**'}])

        self.assertEqual(storage.external_attendees, [
            {'name': 'John Smith', 'email': '*****@*****.**'}])

        self.assertEqual(storage.groups, [
            {'attending': {'Maybe': [], 'Yes': [], 'No': []}, 'name': 'Administrators'}])
Пример #2
0
    def test_confirmation(self):
        portal = self.layer['portal']
        app = self.layer['app']
        z2.login(app['acl_users'], SITE_OWNER_NAME)
        self.register_users()
        event = self._create_event()
        data = {
            'internal_attendees': ['max-musterman', 'john-doe','Administrators', 'Reviewers'],
            'external_attendees': [{'name':'John Smith', 
                                    'email':'*****@*****.**',}],
        }
        utils.save_attendees(event, data)
        storage = IAttendeesStorage(event)

        login(portal, 'max-musterman')
        utils.save_confirmation(event, 'Yes')
        usernames = [i['id'] for i in storage.internal_attendees]
        self.assertTrue('max-musterman' in usernames)
        self.assertEqual(
                storage.internal_attendees[usernames.index('max-musterman')]['attending'],
                'Yes')
        self.assertEqual(utils.get_confirmation(event), 'Yes')

        utils.save_confirmation(event, 'No')
        self.assertEqual(utils.get_confirmation(event), 'No')

        utils.save_confirmation(event, 'Maybe')
        self.assertEqual(utils.get_confirmation(event), 'Maybe')

        login(portal, 'john-doe')
        utils.save_confirmation(event, 'Maybe')
        self.assertEqual(utils.get_confirmation(event), 'Maybe')

        utils.save_confirmation(event, 'No')
        self.assertEqual(utils.get_confirmation(event), 'No')
Пример #3
0
    def test_confirmation_group(self):
        portal = self.layer['portal']
        app = self.layer['app']
        z2.login(app['acl_users'], SITE_OWNER_NAME)
        self.register_users()
        event = self._create_event()
        data = {
            'internal_attendees': ['Reviewers'],
            'external_attendees': [],
        }
        utils.save_attendees(event, data)

        login(portal, 'jan-keller')
        utils.save_confirmation(event, 'Yes')
        self.assertEqual(utils.get_confirmation(event), 'Yes')
Пример #4
0
    def email_new(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = '\n'.join([error.error.__str__() for error in errors])
            return 

        context = aq_inner(self.context)
        new_attendees = utils.get_new_attendees(context, data)
        utils.save_attendees(context, data)
        utils.email_recipients(context, new_attendees)
        if new_attendees['internal_attendees'] or \
                new_attendees['external_attendees']:
            addStatusMessage(self.request, 
                            "The new attendees have been added and notified.",
                            type='info')
        self.request.response.redirect(self.context.REQUEST.get('URL'))
Пример #5
0
 def email_all(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = '\n'.join([error.error.__str__() for error in errors])
         return 
     data = utils.save_attendees(self.context, data)
     utils.email_recipients(self.context, data)
     addStatusMessage(self.request, 
                     "Attendees have been saved and notified",
                     type='info')
     self.request.response.redirect(self.context.REQUEST.get('URL'))
Пример #6
0
    def test_get_new_attendees(self):
        """ """
        portal = self.layer['portal']
        app = self.layer['app']
        z2.login(app['acl_users'], SITE_OWNER_NAME)
        self.register_users()
        event = self._create_event()
        data = {
            'external_attendees': [
                    {'email': '*****@*****.**', 'name': 'Maxine Mustermann'},
                    {'email': '*****@*****.**', 'name': 'Jane Doe'}
                ],
            'internal_attendees': [
                    'Administrators',
                    'Site Administrators',
                    'andreas-ebersbacher',
                    'jan-keller',
                    'werner-wechsler'
                ]
            }
        new_attendees = utils.get_new_attendees(event, data)
        control_new_attendees = {
            'internal_attendees': [
                { 'name': 'Andreas Ebersbacher', 'email': '*****@*****.**' }, 
                { 'name': 'Jan Keller', 'email': '*****@*****.**' },
                { 'name': 'Werner Wechsler', 'email': '*****@*****.**' }
            ], 
            'groups': [
                {'name': 'Administrators'}, 
                {'name': 'Site Administrators'}
            ], 
            'external_attendees': [
                {'email': '*****@*****.**', 'name': 'Maxine Mustermann'}, 
                {'email': '*****@*****.**', 'name': 'Jane Doe'}
            ]
        }
        self.assertEqual(new_attendees, control_new_attendees)
        utils.save_attendees(event, data)

        new_attendees = utils.get_new_attendees(event, data)
        self.assertEqual(new_attendees,
                { 'internal_attendees': [], 
                  'groups': [], 
                  'external_attendees': []})

        data = {
            'external_attendees': [
                    {'email': '*****@*****.**', 'name': 'Piet Pompies'},
                    {'email': '*****@*****.**', 'name': 'Jane Doe'}
                ],
            'internal_attendees': [
                    'Reviewers',
                    'Site Administrators',
                    'max-musterman',
                    'jan-keller',
                ]
            }
        new_attendees = utils.get_new_attendees(event, data)
        control_new_attendees = {
            'internal_attendees': [{'name': 'Max Musterman', 'email': '*****@*****.**'}], 
            'groups': [{'name': 'Reviewers'}],
            'external_attendees': [{'email': '*****@*****.**', 'name': 'Piet Pompies'}]}

        self.assertEqual(new_attendees, control_new_attendees)