def test_multiple_microlocation_for_same_event(self):
     microlocation1 = ObjectMother.get_microlocation()
     microlocation2 = Microlocation(name='test2',
                                    latitude=1.0,
                                    longitude=1.0,
                                    event_id=1)
     self.assertEqual(microlocation1.event_id, 1)
     self.assertEqual(microlocation2.event_id, 1)
Exemplo n.º 2
0
def create_services():
    track = Track.get_service_name()
    session = Session.get_service_name()
    speaker = Speaker.get_service_name()
    sponsor = Sponsor.get_service_name()
    microlocation = Microlocation.get_service_name()

    get_or_create(Service, name=track)
    get_or_create(Service, name=session)
    get_or_create(Service, name=speaker)
    get_or_create(Service, name=sponsor)
    get_or_create(Service, name=microlocation)
Exemplo n.º 3
0
def create_services(event_id, serial_no=''):
    """Creates services and associates them with `event_id`. Service names
    have an optional `serial_no` that can be used to make them unique.
    """
    test_micro = 'TestMicrolocation{}_{}'.format(serial_no, event_id)
    test_track = 'TestTrack{}_{}'.format(serial_no, event_id)
    test_session = 'TestSession{}_{}'.format(serial_no, event_id)
    test_speaker = 'TestSpeaker{}_{}'.format(serial_no, event_id)
    test_sponsor = 'TestSponsor{}_{}'.format(serial_no, event_id)
    test_sponsor_type = 'TestSponsorType{}_{}'.format(serial_no, event_id)
    test_session_type = 'TestSessionType{}_{}'.format(serial_no, event_id)
    test_social_link = 'TestSocialLink{}_{}'.format(serial_no, event_id)

    microlocation = Microlocation(name=test_micro, event_id=event_id)
    track = Track(
        name=test_track,
        description='descp',
        event_id=event_id,
        color='#caf034'
    )
    session_type = SessionType(
        name=test_session_type,
        length=30,
        event_id=event_id
    )
    session = Session(title=test_session,
                      long_abstract='descp',
                      start_time=datetime(2014, 8, 4, 12, 30, 45),
                      end_time=datetime(2014, 8, 4, 13, 00, 00),
                      event_id=event_id,
                      session_type=session_type)
    speaker = Speaker(name=test_speaker,
                      email='*****@*****.**',
                      organisation='org',
                      country='japan',
                      event_id=event_id)
    sponsor = Sponsor(name=test_sponsor, sponsor_type=test_sponsor_type,
                      event_id=event_id, level='level')
    social_link = SocialLink(
        name=test_social_link,
        link='http://fb.com',
        event_id=event_id
    )

    save_to_db(social_link, 'SocialLink saved')
    save_to_db(session_type, 'SessionType saved')
    save_to_db(microlocation, 'Microlocation saved')
    save_to_db(track, 'Track saved')
    save_to_db(session, 'Session saved')
    save_to_db(speaker, 'Speaker saved')
    save_to_db(sponsor, 'Sponsor saved')
Exemplo n.º 4
0
def create_permissions():
    ownr = Role.query.filter_by(name=Role.OWNER).first()
    orgr = Role.query.filter_by(name=Role.ORGANIZER).first()
    coorgr = Role.query.filter_by(name=Role.COORGANIZER).first()
    track_orgr = Role.query.filter_by(name=TRACK_ORGANIZER).first()
    mod = Role.query.filter_by(name=MODERATOR).first()
    regist = Role.query.filter_by(name=REGISTRAR).first()
    track = Service.query.filter_by(name=Track.get_service_name()).first()
    session = Service.query.filter_by(name=Session.get_service_name()).first()
    speaker = Service.query.filter_by(name=Speaker.get_service_name()).first()
    sponsor = Service.query.filter_by(name=Sponsor.get_service_name()).first()
    microlocation = Service.query.filter_by(
        name=Microlocation.get_service_name()).first()

    # For ORGANIZER and OWNER
    # All four permissions set to True
    services = [track, session, speaker, sponsor, microlocation]
    for service in services:
        perm, _ = get_or_create(Permission, role=ownr, service=service)
        db.session.add(perm)

    for service in services:
        perm, _ = get_or_create(Permission, role=orgr, service=service)
        db.session.add(perm)

    # For COORGANIZER
    for service in services:
        perm, _ = get_or_create(Permission, role=coorgr, service=service)
        perm.can_create, perm.can_delete = False, False
        db.session.add(perm)

    # For TRACK_ORGANIZER
    for service in services:
        perm, _ = get_or_create(Permission, role=track_orgr, service=service)
        if not service == track:
            perm.can_create, perm.can_update, perm.can_delete = False, False, False
        db.session.add(perm)

    # For MODERATOR
    for service in services:
        perm, _ = get_or_create(Permission, role=mod, service=service)
        perm.can_create, perm.can_update, perm.can_delete = False, False, False
        db.session.add(perm)

    # For REGISTRAR
    services = [track, session, speaker, sponsor, microlocation]
    for service in services:
        perm, _ = get_or_create(Permission, role=regist, service=service)
        perm.can_create, perm.can_update, perm.can_delete = False, False, False
        db.session.add(perm)
Exemplo n.º 5
0
    def setUp(self):
        self.app = Setup.create_app()
        with app.test_request_context():
            event = Event(name=UNICODE_STRING,
                          start_time=datetime(2013, 8, 4, 12, 30, 45),
                          end_time=datetime(2016, 9, 4, 12, 30, 45))
            event.owner = 1

            microlocation = Microlocation(name=UNICODE_STRING)
            session = Session(title=UNICODE_STRING,
                              long_abstract='descp',
                              start_time=datetime(2014, 8, 4, 12, 30, 45),
                              end_time=datetime(2015, 9, 4, 12, 30, 45))
            speaker = Speaker(name=UNICODE_STRING,
                              email='*****@*****.**',
                              organisation='org',
                              country='japan')
            sponsor = Sponsor(name=UNICODE_STRING)

            save_to_db(event, "Event saved")
            save_to_db(microlocation, 'Microlocation saved')
            save_to_db(session, 'Session saved')
            save_to_db(speaker, 'Speaker saved')
            save_to_db(sponsor, 'Sponsor saved')
Exemplo n.º 6
0
 def get_microlocation(event_id=1):
     return Microlocation(name="name",
                          latitude=1.0,
                          longitude=1.0,
                          event_id=event_id)