예제 #1
0
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3')
     return root.users
예제 #2
0
def _fixture(config):
    from voteit.core.models.user import User
    from voteit.core.models.meeting import Meeting
    config.include('pyramid_chameleon')
    root = bootstrap_and_fixture(config)
    config.include('arche.testing.setup_auth')
    config.include('voteit.core.models.meeting')
    tester = User(
        password='******',
        creators=['tester'],
        first_name=u'Tester',
        email="*****@*****.**",
    )
    root.users['tester'] = tester
    moderator = User(
        password='******',
        creators=['moderator'],
        first_name=u'Moderator',
        email="*****@*****.**",
    )
    root.users['moderator'] = moderator
    meeting = Meeting()
    meeting.add_groups('tester', [
        security.ROLE_DISCUSS, security.ROLE_PROPOSE, security.ROLE_VOTER,
        security.ROLE_VIEWER
    ])
    meeting.add_groups('moderator', [security.ROLE_MODERATOR])
    root['meeting'] = meeting
    return root
예제 #3
0
 def test_gender_title(self):
     context = testing.DummyResource()
     request = testing.DummyRequest()
     obj = self._cut(context, request)
     user = User()
     user.gender = 'other'
     self.assertEqual(obj.gender_title(user), 'Other')
예제 #4
0
 def test_get_user_by_oauth_token(self):
     obj = self._cut()
     from voteit.core.models.user import User
     obj['user'] = User(first_name = 'Anders')
     obj['user'].auth_domains['dummy'] = {'oauth_access_token': 'dummy_token'}
     res = obj.get_user_by_oauth_token('dummy', 'dummy_token')
     self.assertEqual(res.get_field_value('first_name'), 'Anders')
예제 #5
0
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root.users
예제 #6
0
 def _fixture(self):
     from voteit.core.models.user import User
     self.config.scan('voteit.core.schemas.user')  #Login / register form
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root
예제 #7
0
 def test_get_user_by_oauth_token(self):
     obj = self._cut()
     from voteit.core.models.user import User
     obj['user'] = User(first_name='Anders')
     obj['user'].auth_domains['dummy'] = {
         'oauth_access_token': 'dummy_token'
     }
     res = obj.get_user_by_oauth_token('dummy', 'dummy_token')
     self.assertEqual(res.get_field_value('first_name'), 'Anders')
예제 #8
0
파일: gender.py 프로젝트: VoteIT/voteit.irl
def includeme(config):
    config.add_subscriber(add_gender_in_meeting, [ClaimParticipantNumberSchema, ISchemaCreatedEvent])
    config.add_subscriber(add_gender_in_schema, [UserSchema, ISchemaCreatedEvent])
    config.add_subscriber(pronoun_in_site_settings, [SiteSettingsSchema, ISchemaCreatedEvent])
    config.registry.registerAdapter(ParticipantNumberAPWithGender, name=ParticipantNumberAPWithGender.name)
    # Add attribute to User class
    from voteit.core.models.user import User
    User.add_field('gender')
    User.add_field('pronoun')
    def _make_obj(self):
        from voteit.cloudsignon.profile_image_plugins import TwitterProfileImagePlugin
        from voteit.core.models.user import User
        from voteit.core.models.site import SiteRoot 

        root = SiteRoot()
        root['user'] = User()
        root['user'].auth_domains['twitter'] = {'oauth_userid': 'oauth_userid', 'display_name': 'display_name'}
        
        return TwitterProfileImagePlugin( root['user'] )
    def _make_obj(self):
        from voteit.cloudsignon.profile_image_plugins import FacebookProfileImagePlugin
        from voteit.core.models.user import User
        from voteit.core.models.site import SiteRoot 

        root = SiteRoot()
        root['user'] = User()
        root['user'].auth_domains['facebook'] = {'oauth_userid': 'oauth_userid'}
        
        return FacebookProfileImagePlugin( root['user'] )
예제 #11
0
 def test_find_role_userids_other_context(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     self.root['m'] = meeting = Meeting()
     self.root.users['a_user'] = User()
     self.root.users['b_user'] = User()
     self.root.users['c_user'] = User()
     meeting.add_groups('a_user', ['role:a'])
     meeting.add_groups('b_user', ['role:a'])
     self.assertEqual(security.find_role_userids(meeting, 'role:a'),
                      frozenset(['a_user', 'b_user']))
    def _make_obj(self):
        from voteit.cloudsignon.profile_image_plugins import FacebookProfileImagePlugin
        from voteit.core.models.user import User
        from voteit.core.models.site import SiteRoot

        root = SiteRoot()
        root['user'] = User()
        root['user'].auth_domains['facebook'] = {
            'oauth_userid': 'oauth_userid'
        }

        return FacebookProfileImagePlugin(root['user'])
    def _make_obj(self):
        from voteit.cloudsignon.profile_image_plugins import TwitterProfileImagePlugin
        from voteit.core.models.user import User
        from voteit.core.models.site import SiteRoot

        root = SiteRoot()
        root['user'] = User()
        root['user'].auth_domains['twitter'] = {
            'oauth_userid': 'oauth_userid',
            'display_name': 'display_name'
        }

        return TwitterProfileImagePlugin(root['user'])
예제 #14
0
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy1'].auth_domains['facebook'] = {
         'oauth_access_token': 'dummy1_token',
         'oauth_userid': 'dummy1_userid'
     }
     root.users['dummy1'].auth_domains['twitter'] = {
         'oauth_access_token': 'dummy1_token',
         'oauth_userid': 'dummy1_userid'
     }
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3')
     return root
예제 #15
0
 def _fixture(self):
     root = bootstrap_voteit(echo=False)
     from voteit.core.models.user import User
     #Note that creators also fixes ownership
     for userid in ('fredrik', 'anders', 'hanna', 'robin'):
         root.users[userid] = User(creators=[userid])
     return root
예제 #16
0
 def test_update_contained_in_ai(self):
     self.config.include('arche.testing.setup_auth')
     self.config.include('arche.testing')
     self.config.include('voteit.core.models.meeting')
     self.config.include('voteit.core.models.discussion_post')
     from voteit.core.models.discussion_post import DiscussionPost
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = self._fixture()
     root['users']['john'] = User()
     root['m'] = Meeting()
     root['m'].add_groups('john', [security.ROLE_VIEWER])
     root['m']['ai'] = ai = self._ai(title='New object')
     ai['dp'] = dp = DiscussionPost()
     #To make sure dp got catalogued
     self.assertEqual(root.catalog.search(uid=dp.uid)[0], 1)
     #The discussion post shouldn't be visible now, since the ai is private
     self.assertEqual(
         root.catalog.search(uid=dp.uid,
                             allowed_to_view=[security.ROLE_VIEWER])[0], 0)
     #When the ai is made upcoming, it should be visible
     security.unrestricted_wf_transition_to(ai, 'upcoming')
     self.assertEqual(
         root.catalog.search(uid=dp.uid,
                             allowed_to_view=[security.ROLE_VIEWER])[0], 1)
 def _make_obj(self):
     from voteit.core.plugins.gravatar_profile_image import GravatarProfileImagePlugin
     from voteit.core.models.user import User
     from voteit.core.models.site import SiteRoot
     root = SiteRoot()
     root['user'] = User(email='*****@*****.**')
     return GravatarProfileImagePlugin(root['user'])
예제 #18
0
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['m'] = meeting = Meeting()
     root.users['dummy'] = User()
     return meeting
예제 #19
0
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['m'] = Meeting()
     root['users']['dummy'] = User(first_name = 'John', last_name = 'Doe')
     return root
예제 #20
0
def _voters_fixture(config):
    from voteit.core.models.user import User
    root = active_poll_fixture(config)
    for userid in ('alice', 'ben', 'celine'):
        root.users[userid] = User()
        root['meeting'].add_groups(userid, [security.ROLE_VOTER])
    return root
예제 #21
0
 def test_deferred_current_password_validator(self):
     from voteit.core.validators import deferred_current_password_validator
     from voteit.core.validators import CurrentPasswordValidator
     from voteit.core.models.user import User
     context = User()
     res = deferred_current_password_validator(None, {'context': context})
     self.assertIsInstance(res, CurrentPasswordValidator)
예제 #22
0
 def test_get_user_by_email(self):
     self.config.include('arche.models.catalog')
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.user import User
     obj = root['users']
     obj['user'] = User(email='*****@*****.**', first_name='Anders')
     res = obj.get_user_by_email('*****@*****.**')
     self.assertEqual(res.first_name, 'Anders')
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['some_user'] = User()
     root['m'] = Meeting()
     root['m']['ai'] = AgendaItem()
     return root['m']['ai']
예제 #24
0
    def test_integration(self):
        from voteit.core.models.user import User
        self.config.scan('voteit.core.views.components.user_info')

        context = User()
        request = testing.DummyRequest()
        self.assertIsInstance(
            render_view_action(context, request, 'user_info', 'basic_profile'),
            unicode)
예제 #25
0
    def _fixture(self):
        self.config.scan('betahaus.pyracont.fields.password')
        root = bootstrap_voteit(echo=False)
        from voteit.core.models.user import User

        #Note that creators also fixes ownership
        for userid in ('fredrik', 'anders', 'hanna', 'robin'):
            root.users[userid] = User(creators=[userid])

        return root
예제 #26
0
 def test_with_user_outside_of_meeting_context(self):
     from voteit.core.models.user import User
     root = _fixture(self.config)
     context = root['meeting']
     #New user
     root.users['new'] = User()
     obj = self._cut(context)
     node = None
     self.assertRaises(
         colander.Invalid, obj, node,
         "@new doesn't exist in this meeting so this shouldn't work")
예제 #27
0
 def test_auto_claim_on_add_user(self):
     root = self._fixture()
     self.config.include('voteit.core.subscribers.auto_claim_ticket')
     self.config.include(
         'arche.subscribers')  #<- Delegating subscriber here
     root['m'].add_invite_ticket('*****@*****.**',
                                 roles=[security.ROLE_VIEWER])
     from voteit.core.models.user import User
     user = User(email='*****@*****.**', email_validated=True)
     root['users']['tester'] = user
     self.assertIn(security.ROLE_VIEWER, root['m'].local_roles['tester'])
예제 #28
0
 def _fixture_and_setup(self):
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.user import User
     from voteit.core.models.agenda_item import AgendaItem
     #from voteit.core.models.meeting import Meeting
     from voteit.core.models.proposal import Proposal
     for userid in ('fredrik', 'anders', 'hanna', 'robin'):
         root.users[userid] = User()
     root['ai'] = AgendaItem()
     security.unrestricted_wf_transition_to(root['ai'], 'upcoming')
     root['ai']['p'] = Proposal()
     return root['ai']['p']
 def test_claim_ticket_causes_email_validation(self):
     from voteit.core.models.invite_ticket import claim_ticket
     from voteit.core.models.user import User
     self.config.include('arche.testing')
     self.config.include('voteit.core.models.invite_ticket')
     root = _fixture(self.config)
     meeting = root['m']
     root['users']['some_user'] = user = User(email = '*****@*****.**')
     obj = meeting.add_invite_ticket('*****@*****.**', [security.ROLE_MODERATOR, security.ROLE_DISCUSS, security.ROLE_VIEWER])
     request = testing.DummyRequest()
     claim_ticket(obj, request, 'some_user')
     self.assertTrue(user.email_validated)
예제 #30
0
 def _fixture(self):
     root = bootstrap_and_fixture(self.config)
     self.config.include('arche.portlets')
     self.config.include('voteit.irl')
     self.config.include('voteit.qr')
     request = testing.DummyRequest()
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     root['m'] = Meeting()
     root['users']['jane'] = User()
     root['m'].local_roles['jane'] = [ROLE_VIEWER]
     return root, request
예제 #31
0
 def test_integration(self):
     from voteit.core.models.user import User
     from voteit.core.views.api import APIView
     self.config.scan('voteit.core.views.components.user_info')
     root = _fixture(self.config)
     root['u'] = context = User()
     request = testing.DummyRequest()
     api = APIView(context, request)
     self.assertIsInstance(
         render_view_action(context,
                            request,
                            'user_info',
                            'latest_meeting_entries',
                            api=api), unicode)
예제 #32
0
 def test_integration(self):
     from voteit.core.models.user import User
     from voteit.core.views.api import APIView
     self.config.include('pyramid_chameleon')
     self.config.scan('voteit.core.views.components.user_info')
     context = User()
     request = testing.DummyRequest()
     api = APIView(context, request)
     self.assertIsInstance(
         render_view_action(context,
                            request,
                            'user_info',
                            'basic_profile',
                            api=api), unicode)
예제 #33
0
 def _fixture(self):
     """ Normal context for this view is an agenda item. """
     from voteit.core.models.user import User
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.poll import Poll
     self.config.include('voteit.core.plugins.majority_poll')
     root = bootstrap_and_fixture(self.config)
     root.users['dummy'] = User()
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     ai['poll'] = Poll(start_time=utcnow(), end_time=utcnow())
     ai['poll'].set_field_value('poll_plugin', 'majority_poll')
     return ai
 def test_claim_ticket(self):
     from voteit.core.models.invite_ticket import claim_ticket
     from voteit.core.models.user import User
     self.config.include('arche.testing')
     self.config.include('voteit.core.models.invite_ticket')
     root = _fixture(self.config)
     meeting = root['m']
     root['users']['some_user'] = User()
     obj = meeting.add_invite_ticket('*****@*****.**', [security.ROLE_MODERATOR, security.ROLE_DISCUSS, security.ROLE_VIEWER])
     request = testing.DummyRequest()
     claim_ticket(obj, request, 'some_user')
     self.assertTrue(isinstance(obj.closed, datetime))
     self.assertEqual(obj.claimed_by, 'some_user')
     self.assertEqual(obj.get_workflow_state(), 'closed')
     self.assertEqual(meeting.get_groups('some_user'), (security.ROLE_MODERATOR, security.ROLE_DISCUSS, security.ROLE_VIEWER))
예제 #35
0
 def test_integration(self):
     from voteit.core.models.user import User
     self.config.scan('voteit.core.views.components.user_info')
     root = _fixture(self.config)
     root['u'] = context = User()
     request = testing.DummyRequest(context=context)
     request.meeting = None
     request.root = root
     view = BaseView(context, request)
     self.assertIsInstance(
         render_view_action(context,
                            request,
                            'user_info',
                            'latest_meeting_entries',
                            view=view), unicode)