Beispiel #1
0
    def seed_static_data(self):
        self.test_user = self.add_user('*****@*****.**')
        self.add_organisation('Deep Learning Indaba')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        event = self.add_event(
            name={'en': "Tech Talk"},
            description={'en': "tech talking"},
            start_date=datetime(2019, 12, 12, 10, 10, 10),
            end_date=datetime(2020, 12, 12, 10, 10, 10),
            key='REGINAL'
        )
        db.session.commit()
        self.event = event
Beispiel #2
0
    def seed_static_data(self):
        self.add_organisation('Deep Learning Indaba')
        self.add_organisation('Deep Learning IndabaX')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        self.event1 = self.add_event('Indaba', 'Indaba Event', datetime.now(),
                                     datetime.now(), 'SOUTHAFRI2019')
        self.event2 = self.add_event('IndabaX',
                                     'IndabaX Sudan', datetime.now(),
                                     datetime.now(), 'SUDANMO', 2)
        db.session.commit()

        self.event1_id = self.event1.id
        self.event2_id = self.event2.id

        db.session.flush()
Beispiel #3
0
    def setup_static_data(self):
        self.add_organisation('Deep Learning Indaba', 'blah.png', 'blah_big.png')
        self.add_organisation('Deep Learning IndabaX', 'blah.png', 'blah_big.png')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        events = [
            Event('Indaba', 'Indaba Event', datetime.now(), datetime.now(), 'ADAMOPTIM', 1, '*****@*****.**','indaba.deeplearning',
                           datetime.now(), datetime.now(), datetime.now(), datetime.now(),
                           datetime.now(), datetime.now(), datetime.now(), datetime.now(),
                           datetime.now(), datetime.now()),
            Event('Indaba2', 'Indaba Event 2', datetime.now(), datetime.now(), 'HACFTET', 2, '*****@*****.**','indaba.deeplearning',
                           datetime.now(), datetime.now(), datetime.now(), datetime.now(),
                           datetime.now(), datetime.now(), datetime.now(), datetime.now(),
                           datetime.now(), datetime.now())
        ]
        db.session.add_all(events)

        application_forms = [
            ApplicationForm(1, True, datetime.now()),
            ApplicationForm(2, False, datetime.now())
        ]
        db.session.add_all(application_forms)

        candidate1 = AppUser(email='*****@*****.**', firstname='candidate', lastname='1', user_title='Mr',password= '******', organisation_id=1)
        candidate2 = AppUser(email='*****@*****.**', firstname='candidate', lastname='2', user_title='Ms', password='******', organisation_id=1)
        system_admin = AppUser(email='*****@*****.**', firstname='system_admin', lastname='1', user_title='Mr',password='******', organisation_id=1, is_admin=True)
        event_admin = AppUser(email='*****@*****.**', firstname='event_admin', lastname='1', user_title='Ms', password='******',organisation_id=1)
        reviewer = AppUser(email='*****@*****.**', firstname='reviewer', lastname='1', user_title='Ms', password='******', organisation_id=1)
        users = [candidate1, candidate2, system_admin, event_admin, reviewer]
        for user in users:
            user.verify()
        db.session.add_all(users)

        event_roles = [
            EventRole('admin', 4, 1),
            EventRole('reviwer', 5, 1)
        ]
        db.session.add_all(event_roles)
        db.session.commit()
        responses = [
            Response(1, 1, True, datetime(2019, 4, 10)),
            Response(2, 2, True, datetime(2019, 4, 9))
        ]
        db.session.add_all(responses)
        db.session.commit()
Beispiel #4
0
    def seed_static_data(self, add_offer=True):
        test_user = self.add_user('*****@*****.**')
        offer_admin = self.add_user('*****@*****.**',
                                    'event_admin',
                                    is_admin=True)
        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png', 'deeplearningindaba')
        db.session.add(UserCategory('Offer Category'))
        db.session.add(Country('Suid Afrika'))
        db.session.commit()

        event = Event(name="Tech Talk",
                      description="tech talking",
                      start_date=datetime(2019, 12, 12),
                      end_date=datetime(2020, 12, 12),
                      key='SPEEDNET',
                      organisation_id=1,
                      email_from='*****@*****.**',
                      url='indaba.deeplearning',
                      application_open=datetime.now(),
                      application_close=datetime.now(),
                      review_open=datetime.now(),
                      review_close=datetime.now(),
                      selection_open=datetime.now(),
                      selection_close=datetime.now(),
                      offer_open=datetime.now(),
                      offer_close=datetime.now(),
                      registration_open=datetime.now(),
                      registration_close=datetime.now())
        db.session.add(event)
        db.session.commit()

        if add_offer:
            offer = Offer(user_id=test_user.id,
                          event_id=event.id,
                          offer_date=datetime.now(),
                          expiry_date=datetime.now() + timedelta(days=15),
                          payment_required=False,
                          travel_award=True,
                          accommodation_award=False)
            db.session.add(offer)
            db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #5
0
    def seed_static_data(self, add_offer=True):
        db.session.add(UserCategory('Offer Category'))
        db.session.add(Country('Suid Afrika'))
        db.session.commit()
        db.session.commit()

        test_user = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                            'Male', 'University', 'Computer Science', 'None',
                            1, datetime(1984, 12, 12), 'Zulu', '654321')
        test_user.verified_email = True
        db.session.add(test_user)
        db.session.commit()

        offer_admin = AppUser('*****@*****.**', 'event_admin', '1', 'Ms',
                              1, 1, 'F', 'NWU', 'Math', 'NA', 1,
                              datetime(1984, 12, 12), 'Eng', '654321', True)
        offer_admin.verified_email = True
        db.session.add(offer_admin)

        db.session.commit()

        event = Event(
            name="Tech Talk",
            description="tech talking",
            start_date=datetime(2019, 12, 12),
            end_date=datetime(2020, 12, 12),
        )
        db.session.add(event)
        db.session.commit()

        if add_offer:
            offer = Offer(user_id=test_user.id,
                          event_id=event.id,
                          offer_date=datetime.now(),
                          expiry_date=datetime.now() + timedelta(days=15),
                          payment_required=False,
                          travel_award=True,
                          accommodation_award=False)
            db.session.add(offer)
            db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #6
0
    def setup_static_data(self):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))

        events = [
            Event('Indaba', 'Indaba Event', datetime.now(), datetime.now()),
            Event('Indaba2', 'Indaba Event 2', datetime.now(), datetime.now())
        ]
        db.session.add_all(events)

        application_forms = [
            ApplicationForm(1, True, datetime.now()),
            ApplicationForm(2, False, datetime.now())
        ]
        db.session.add_all(application_forms)

        candidate1 = AppUser('*****@*****.**', 'candidate', '1', 'Mr', 1,
                             1, 'M', 'UWC', 'CS', 'NA', 1,
                             datetime(1984, 12, 12), 'Eng', 'abc')
        candidate2 = AppUser('*****@*****.**', 'candidate', '2', 'Ms', 1,
                             1, 'F', 'RU', 'Chem', 'NA', 1,
                             datetime(1984, 12, 12), 'Eng', 'abc')
        system_admin = AppUser('*****@*****.**', 'system_admin', '1',
                               'Mr', 1, 1, 'M', 'UFH', 'Phys', 'NA', 1,
                               datetime(1984, 12, 12), 'Eng', 'abc', True)
        event_admin = AppUser('*****@*****.**', 'event_admin', '1', 'Ms',
                              1, 1, 'F', 'NWU', 'Math', 'NA', 1,
                              datetime(1984, 12, 12), 'Eng', 'abc')
        reviewer = AppUser('*****@*****.**', 'reviewer', '1', 'Ms', 1,
                           1, 'F', 'NWU', 'Math', 'NA', 1,
                           datetime(1984, 12, 12), 'Eng', 'abc')
        users = [candidate1, candidate2, system_admin, event_admin, reviewer]
        for user in users:
            user.verify()
        db.session.add_all(users)

        event_roles = [EventRole('admin', 4, 1), EventRole('reviwer', 5, 1)]
        db.session.add_all(event_roles)

        responses = [
            Response(1, 1, True, datetime(2019, 4, 10)),
            Response(2, 2, True, datetime(2019, 4, 9))
        ]
        db.session.add_all(responses)
        db.session.commit()
Beispiel #7
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['DEBUG'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        self.app = app.test_client()
        db.reflect()
        db.drop_all()
        db.create_all()

        # Add dummy metadata
        self.user_category = UserCategory('Postdoc')
        db.session.add(self.user_category)
        self.country = Country('South Africa')
        db.session.add(self.country)

        # Add a dummy organisation
        self.add_organisation(domain='org')
        db.session.flush()
Beispiel #8
0
    def seed_static_data(self):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        self.add_organisation('Deep Learning Indaba', 'blah.png', 'blah_big.png', domain='indaba')

        self.user1_org1 = AppUser('*****@*****.**', 'candidate', '1', 'Mr',  password="******",organisation_id=1)
        self.user1_org2 = AppUser('*****@*****.**', 'candidate', '2', 'Ms',  password="******",organisation_id=2)
        self.user2_org1 = AppUser('*****@*****.**', 'system_admin', '1', 'Mr', password="******",organisation_id=1, is_admin=True)

        users = [self.user1_org1, self.user1_org2, self.user2_org1]
        for user in users:
            user.verify()
        db.session.add_all(users)

        self.add_email_template('verify-email')
        self.add_email_template('password-reset')

        db.session.commit()
Beispiel #9
0
    def seed_static_data(self):
        test_country = Country('Indaba Land')
        db.session.add(test_country)
        db.session.commit()

        test_category = UserCategory('Category1')
        db.session.add(test_category)
        db.session.commit()

        response = self.app.post('/api/v1/user', data=self.user_data_dict)
        self.test_user1 = json.loads(response.data)

        other_user_data = self.user_data_dict.copy()
        other_user_data['email'] = '*****@*****.**'
        response = self.app.post('/api/v1/user', data=other_user_data)
        self.test_user2 = json.loads(response.data)

        self.test_event = Event('Test Event', 'Event Description',
                                datetime.now() + timedelta(days=30),
                                datetime.now() + timedelta(days=60))
        db.session.add(self.test_event)
        db.session.commit()

        self.test_form = ApplicationForm(self.test_event.id, True,
                                         datetime.now() + timedelta(days=60))
        db.session.add(self.test_form)
        db.session.commit()

        self.test_response = Response(self.test_form.id, self.test_user1['id'])
        db.session.add(self.test_response)
        db.session.commit()

        self.test_response2 = Response(self.test_form.id,
                                       self.test_user2['id'])
        self.test_response2.submit_response()
        db.session.add(self.test_response2)
        db.session.commit()

        self.user_role1 = EventRole('admin', self.test_user1['id'],
                                    self.test_event.id)
        db.session.add(self.user_role1)
        db.session.commit()

        db.session.flush()
Beispiel #10
0
    def seed_static_data(self):
        self.add_organisation('Test Indaba', 'blah.png', 'blah_big.png',
                              'testindaba')

        test_country = Country('Test Land')
        db.session.add(test_country)
        db.session.commit()

        test_category = UserCategory('TestYear')
        db.session.add(test_category)
        db.session.commit()

        self.test_admin_user = AppUser(email='*****@*****.**',
                                       firstname='Some',
                                       lastname='One',
                                       user_title='Mr',
                                       password='******',
                                       organisation_id=1,
                                       is_admin=True)
        self.test_admin_user.verify()
        db.session.add(self.test_admin_user)
        db.session.commit()
        self.test_user = AppUser(email='*****@*****.**',
                                 firstname='Some',
                                 lastname='One',
                                 user_title='Mr',
                                 password='******',
                                 organisation_id=1)
        self.test_user.verify()
        db.session.add(self.test_user)
        db.session.commit()

        event = Event('Indaba 2019', 'Deep Learning Indaba',
                      datetime(2019, 8, 25), datetime(2019, 8, 31), 'COOLER',
                      1, '*****@*****.**', 'indaba.deeplearning',
                      datetime.now(), datetime.now(), datetime.now(),
                      datetime.now(), datetime.now(), datetime.now(),
                      datetime.now(), datetime.now(), datetime.now(),
                      datetime.now())
        db.session.add(event)
        db.session.commit()

        db.session.flush()
Beispiel #11
0
    def _seed_data(self):
        # Add a user
        test_country = Country('Indaba Land')
        _add_object_to_db(test_country)

        test_category = UserCategory('Category1')
        _add_object_to_db(test_category)

        other_user_data = self.user_data_dict.copy()
        other_user_data['email'] = '*****@*****.**'
        response = self.app.post('/api/v1/user', data=other_user_data)
        self.other_user_data = json.loads(response.data)

        response = self.app.post('/api/v1/user', data=self.user_data_dict)
        self.user_data = json.loads(response.data)

        # Add application form data
        self.test_event = Event('Test Event', 'Event Description', date(
            2019, 2, 24), date(2019, 3, 24))
        _add_object_to_db(self.test_event)
        self.test_form = ApplicationForm(
            self.test_event.id, True, date(2019, 3, 24))
        _add_object_to_db(self.test_form)
        test_section = Section(
            self.test_form.id, 'Test Section', 'Test Description', 1)
        _add_object_to_db(test_section)
        self.test_question = Question(self.test_form.id, test_section.id,
                                      'Test Question Description', 'Test question placeholder', 1, 'Test Type', None)
        _add_object_to_db(self.test_question)
        self.test_question2 = Question(
            self.test_form.id, test_section.id, 'Test Question 2', 'Enter something', 2, 'short-text', None)
        _add_object_to_db(self.test_question2)

        self.test_response = Response(
            self.test_form.id, self.other_user_data['id'])
        _add_object_to_db(self.test_response)

        self.test_answer1 = Answer(
            self.test_response.id, self.test_question.id, 'My Answer')
        _add_object_to_db(self.test_answer1)

        db.session.flush()
Beispiel #12
0
    def seed_static_data(self):
        test_user = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                            'Male', 'University', 'Computer Science', 'None', 1,
                            datetime(1984, 12, 12),
                            'Zulu',
                            '123456')
        test_user.verified_email = True
        db.session.add(test_user)

        test_user2 = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                             'Male', 'University', 'Computer Science', 'None', 1,
                             datetime(1984, 12, 12),
                             'Zulu',
                             '123456')
        test_user2.verified_email = True
        db.session.add(test_user2)

        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))

        event_admin = AppUser('*****@*****.**', 'event_admin', '1', 'Ms', 1,
                              1, 'F', 'NWU', 'Math', 'NA', 1, datetime(1984, 12, 12), 'Eng', '123456')
        event_admin.verified_email = True
        db.session.add(event_admin)

        self.event1 = Event('Indaba', 'Indaba Event',
                            datetime.now(), datetime.now())
        self.event2 = Event('IndabaX', 'IndabaX Sudan',
                            datetime.now(), datetime.now())
        db.session.add(self.event1)
        db.session.add(self.event2)

        adminRole = EventRole('admin', 3, 1)
        db.session.add(adminRole)
        db.session.commit()

        self.event1_id = self.event1.id
        self.event2_id = self.event2.id
        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #13
0
    def setup_static_data(self):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))

        self.candidate1 = AppUser('*****@*****.**', 'candidate', '1', 'Mr', 1, 1,
                                  'M', 'UWC', 'CS', 'NA', 1,
                                  datetime(1984, 12, 12), 'Eng', 'abc')
        self.candidate2 = AppUser('*****@*****.**', 'candidate', '2', 'Ms', 1, 1,
                                  'F', 'RU', 'Chem', 'NA', 1,
                                  datetime(1984, 12, 12), 'Eng', 'abc')
        self.system_admin = AppUser('*****@*****.**', 'system_admin', '1',
                                    'Mr', 1, 1, 'M', 'UFH', 'Phys', 'NA', 1,
                                    datetime(1984, 12, 12), 'Eng', 'abc', True)

        users = [self.candidate1, self.candidate2, self.system_admin]
        for user in users:
            user.verify()
        db.session.add_all(users)

        db.session.commit()
Beispiel #14
0
    def allow_same_email_different_org(self):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png')

        response = self.app.post('/api/v1/user',
                                 data=USER_DATA,
                                 headers={'Origin': 'www.myorg.net'})
        self.assertEqual(response.status_code, 201)

        response = self.app.post('/api/v1/user',
                                 data=USER_DATA,
                                 headers={'Origin': 'www.indaba.net'})
        self.assertEqual(response.status_code, 201)

        response = self.app.post('/api/v1/user',
                                 data=USER_DATA,
                                 headers={'Origin': 'www.indaba.net'})
        self.assertEqual(response.status_code, 409)
Beispiel #15
0
    def seed_static_data(self):
        self.add_organisation('Deep Learning Indaba')
        self.add_organisation('Deep Learning IndabaX')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        self.event1 = self.add_event({'en': 'Indaba'}, {'en': 'Indaba Event'},
                                     datetime.now(), datetime.now(),
                                     'SOUTHAFRI2019')
        self.event2 = self.add_event({'en': 'IndabaX'},
                                     {'en': 'IndabaX Sudan'}, datetime.now(),
                                     datetime.now(), 'SUDANMO', 2)
        db.session.commit()

        self.event1_id = self.event1.id
        self.event2_id = self.event2.id

        self.add_email_template('verify-email')
        self.add_email_template('password-reset')

        db.session.flush()
Beispiel #16
0
    def seed_static_data(self):
        test_user = self.add_user('*****@*****.**')
        test_user2 = self.add_user('*****@*****.**')

        event_admin = self.add_user('*****@*****.**')
        db.session.commit()
        self.add_organisation('Deep Learning Indaba')
        self.add_organisation('Deep Learning IndabaX')
        db.session.commit()

        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))

        self.event1 = Event('Indaba', 'Indaba Event', datetime.now(),
                            datetime.now(), 'LBFSOLVER', 1,
                            '*****@*****.**', 'indaba.deeplearning',
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now())
        self.event2 = Event('IndabaX', 'IndabaX Sudan', datetime.now(),
                            datetime.now(), 'NAGSOLVER', 2,
                            '*****@*****.**', 'indaba.deeplearning',
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now(), datetime.now(), datetime.now(),
                            datetime.now())
        db.session.add(self.event1)
        db.session.add(self.event2)
        db.session.commit()

        adminRole = EventRole('admin', event_admin.id, self.event1.id)
        db.session.add(adminRole)
        db.session.commit()

        self.event1_id = self.event1.id
        self.event2_id = self.event2.id
        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #17
0
    def seed_static_data(self):

        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        test_user = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                            'Male', 'University', 'Computer Science', 'None',
                            1, datetime(1984, 12, 12), 'Zulu', '123456')
        test_user.verified_email = True
        db.session.add(test_user)
        db.session.commit()

        event = Event(
            name="Tech Talk",
            description="tech talking",
            start_date=datetime(2019, 12, 12, 10, 10, 10),
            end_date=datetime(2020, 12, 12, 10, 10, 10),
        )
        db.session.add(event)
        db.session.commit()
        self.event = event
Beispiel #18
0
    def seed_static_data(self, add_offer=True):
        test_user = self.add_user('*****@*****.**')
        offer_admin = self.add_user('*****@*****.**',
                                    'event_admin',
                                    is_admin=True)
        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png', 'deeplearningindaba')
        db.session.add(UserCategory('Offer Category'))
        db.session.add(Country('Suid Afrika'))
        db.session.commit()

        event = self.add_event(name={'en': "Tech Talk"},
                               description={'en': "tech talking"},
                               start_date=datetime(2019, 12, 12),
                               end_date=datetime(2020, 12, 12),
                               key='SPEEDNET')
        db.session.commit()

        app_form = self.create_application_form()
        self.add_response(app_form.id, test_user.id, True, False)

        if add_offer:
            offer = Offer(user_id=test_user.id,
                          event_id=event.id,
                          offer_date=datetime.now(),
                          expiry_date=datetime.now() + timedelta(days=15),
                          payment_required=False,
                          travel_award=True,
                          accommodation_award=False)
            db.session.add(offer)
            db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        self.add_email_template('offer')

        db.session.flush()
Beispiel #19
0
    def seed_static_data(self):
        test_user = self.add_user('*****@*****.**')
        test_user2 = self.add_user('*****@*****.**')

        event_admin = self.add_user('*****@*****.**')
        db.session.commit()
        self.add_organisation('Deep Learning Indaba')
        self.add_organisation('Deep Learning IndabaX')
        db.session.commit()

        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))

        self.event1 = self.add_event({'en': 'Indaba'}, {'en': 'Indaba Event'},
                                     datetime.now(), datetime.now(),
                                     'LBFSOLVER')
        self.event2 = self.add_event({'en': 'IndabaX'},
                                     {'en': 'IndabaX Sudan'}, datetime.now(),
                                     datetime.now(), 'NAGSOLVER', 2)
        db.session.commit()

        adminRole = EventRole('admin', event_admin.id, self.event1.id)
        db.session.add(adminRole)
        db.session.commit()

        self.event1_id = self.event1.id
        self.event2_id = self.event2.id
        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        self.add_email_template('guest-invitation-with-registration')
        self.add_email_template('guest-invitation')
        self.add_email_template('new-guest-registration')
        self.add_email_template('new-guest-no-registration')

        db.session.flush()
Beispiel #20
0
    def seed_static_data(self):
        test_user = self.add_user('*****@*****.**')
        event_admin = self.add_user('*****@*****.**')

        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png', 'deeplearningindaba')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        event = self.add_event(name={'en': "Tech Talk"},
                               description={'en': "tech talking"},
                               start_date=datetime(2019, 12, 12, 10, 10, 10),
                               end_date=datetime(2020, 12, 12, 10, 10, 10),
                               key='REGINAL')

        db.session.commit()

        self.form = RegistrationForm(event_id=event.id)
        db.session.add(self.form)
        db.session.commit()
        self.form_id = self.form.id

        self.event_id = event.id

        section = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=None,
            show_for_accommodation_award=None,
            show_for_payment_required=None,
        )
        db.session.add(section)
        db.session.commit()

        section2 = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 2",
            description="the section 2 description",
            order=1,
            show_for_travel_award=None,
            show_for_accommodation_award=None,
            show_for_payment_required=None,
        )
        db.session.add(section2)
        db.session.commit()

        self.question = RegistrationQuestion(section_id=section.id,
                                             registration_form_id=self.form.id,
                                             description="Question 1",
                                             type="short-text",
                                             is_required=True,
                                             order=1,
                                             placeholder="the placeholder",
                                             headline="the headline",
                                             validation_regex="[]/",
                                             validation_text=" text")
        db.session.add(self.question)
        db.session.commit()
        self.question_id = self.question.id

        self.question2 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 2",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question2)
        db.session.commit()
        self.question2_id = self.question2.id

        self.question3 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 3",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question3)
        db.session.commit()
        self.question3_id = self.question3.id

        db.session.flush()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        self.add_email_template('guest-registration-confirmation')
        self.add_email_template('guest-invitation-with-registration')
        self.add_email_template('guest-invitation')
        self.add_email_template('new-guest-registration')
        self.add_email_template('new-guest-no-registration')
Beispiel #21
0
    def seed_static_data(self, create_registration=False):
        test_user = self.add_user('*****@*****.**', 'Some', 'Thing', 'Mr')
        test_user2 = self.add_user('*****@*****.**', 'Something2',
                                   'Thing2', 'Mrs')
        event_admin = self.add_user('*****@*****.**',
                                    'event_admin',
                                    is_admin=True)

        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        event = Event(name="Tech Talk",
                      description="tech talking",
                      start_date=datetime(2019, 12, 12, 10, 10, 10),
                      end_date=datetime(2020, 12, 12, 10, 10, 10),
                      key='SPEEDNET',
                      organisation_id=1,
                      email_from='*****@*****.**',
                      url='indaba.deeplearning',
                      application_open=datetime.now(),
                      application_close=datetime.now(),
                      review_open=datetime.now(),
                      review_close=datetime.now(),
                      selection_open=datetime.now(),
                      selection_close=datetime.now(),
                      offer_open=datetime.now(),
                      offer_close=datetime.now(),
                      registration_open=datetime.now(),
                      registration_close=datetime.now())
        db.session.add(event)
        db.session.commit()

        self.offer = Offer(user_id=test_user.id,
                           event_id=event.id,
                           offer_date=datetime.now(),
                           expiry_date=datetime.now() + timedelta(days=15),
                           payment_required=False,
                           travel_award=True,
                           accommodation_award=False,
                           responded_at=datetime.now())
        self.offer.candidate_response = True
        self.offer.accepted_travel_award = True
        db.session.add(self.offer)
        db.session.commit()

        self.offer2 = Offer(user_id=test_user2.id,
                            event_id=event.id,
                            offer_date=datetime.now(),
                            expiry_date=datetime.now() + timedelta(days=15),
                            payment_required=True,
                            travel_award=True,
                            accommodation_award=False,
                            responded_at=datetime.now())
        db.session.add(self.offer2)
        db.session.commit()

        self.offer3 = Offer(user_id=event_admin.id,
                            event_id=event.id,
                            offer_date=datetime.now(),
                            expiry_date=datetime.now() + timedelta(days=15),
                            payment_required=True,
                            travel_award=False,
                            accommodation_award=True,
                            responded_at=datetime.now())
        db.session.add(self.offer3)
        db.session.commit()

        self.form = RegistrationForm(event_id=event.id)
        db.session.add(self.form)
        db.session.commit()

        section = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()

        section2 = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 2",
            description="the section 2 description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section2)
        db.session.commit()

        self.question = RegistrationQuestion(section_id=section.id,
                                             registration_form_id=self.form.id,
                                             description="Question 1",
                                             type="short-text",
                                             is_required=True,
                                             order=1,
                                             placeholder="the placeholder",
                                             headline="the headline",
                                             validation_regex="[]/",
                                             validation_text=" text")
        db.session.add(self.question)
        db.session.commit()

        self.question2 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 2",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question2)
        db.session.commit()

        self.question3 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 3",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question3)
        db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.headers2 = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        if create_registration:
            self.registration1 = Registration(self.offer.id,
                                              self.form.id,
                                              confirmed=False)
            db.session.add(self.registration1)
            db.session.commit()
            self.registration2 = Registration(self.offer2.id,
                                              self.form.id,
                                              confirmed=True)
            db.session.add(self.registration2)
            db.session.commit()
            self.registration3 = Registration(self.offer3.id,
                                              self.form.id,
                                              confirmed=False)
            db.session.add(self.registration3)
            db.session.commit()

        db.session.flush()
Beispiel #22
0
 def add_category(self):
     category = UserCategory('Student')
     db.session.add(category)
     db.session.commit()
     return category
Beispiel #23
0
    def seed_static_data(self, create_registration=False):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        test_user = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                            'Male', 'University', 'Computer Science', 'None', 1,
                            datetime(1984, 12, 12),
                            'Zulu',
                            '123456')
        test_user.verified_email = True
        db.session.add(test_user)
        db.session.commit()

        test_user2 = AppUser('*****@*****.**', 'Something2', 'Thing2', 'Mrs', 1, 1,
                            'Female', 'University of Indaba', 'Machine Learning', 'None', 1,
                            datetime(1985, 2, 3),
                            'Zulu',
                            '123456')
        test_user2.verified_email = True
        db.session.add(test_user2)
        db.session.commit()

        event_admin = AppUser('*****@*****.**', 'event_admin', '1', 'Ms', 1,
                              1, 'F', 'NWU', 'Math', 'NA', 1, datetime(1984, 12, 12), 'Eng', '123456', True)
        event_admin.verified_email = True
        db.session.add(event_admin)

        db.session.commit()

        event = Event(
            name="Tech Talk",
            description="tech talking",
            start_date=datetime(2019, 12, 12, 10, 10, 10),
            end_date=datetime(2020, 12, 12, 10, 10, 10),

        )
        db.session.add(event)
        db.session.commit()

        self.offer = Offer(
            user_id=test_user.id,
            event_id=event.id,
            offer_date=datetime.now(),
            expiry_date=datetime.now() + timedelta(days=15),
            payment_required=False,
            travel_award=True,
            accommodation_award=False,
            responded_at=datetime.now())
        self.offer.candidate_response = True
        self.offer.accepted_travel_award = True
        db.session.add(self.offer)
        db.session.commit()

        self.offer2 = Offer(
            user_id=test_user2.id,
            event_id=event.id,
            offer_date=datetime.now(),
            expiry_date=datetime.now() + timedelta(days=15),
            payment_required=True,
            travel_award=True,
            accommodation_award=False,
            responded_at=datetime.now())
        db.session.add(self.offer2)
        db.session.commit()

        self.offer3 = Offer(
            user_id=event_admin.id,
            event_id=event.id,
            offer_date=datetime.now(),
            expiry_date=datetime.now() + timedelta(days=15),
            payment_required=True,
            travel_award=False,
            accommodation_award=True,
            responded_at=datetime.now())
        db.session.add(self.offer3)
        db.session.commit()

        self.form = RegistrationForm(
            event_id=event.id
        )
        db.session.add(self.form)
        db.session.commit()

        section = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()

        section2 = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 2",
            description="the section 2 description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section2)
        db.session.commit()

        self.question = RegistrationQuestion(
            section_id=section.id,
            registration_form_id=self.form.id,
            description="Question 1",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text"
        )
        db.session.add(self.question)
        db.session.commit()

        self.question2 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 2",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text"
        )
        db.session.add(self.question2)
        db.session.commit()

        self.question3 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 3",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text"
        )
        db.session.add(self.question3)
        db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.headers2 = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        if create_registration:
            self.registration1 = Registration(self.offer.id, self.form.id, confirmed=False)
            db.session.add(self.registration1)
            db.session.commit()
            self.registration2 = Registration(self.offer2.id, self.form.id, confirmed=True)
            db.session.add(self.registration2)
            db.session.commit()
            self.registration3 = Registration(self.offer3.id, self.form.id, confirmed=False)
            db.session.add(self.registration3)
            db.session.commit()

        db.session.flush()
Beispiel #24
0
    def seed_static_data(self):
        self.add_organisation('Deep Learning Indaba')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        test_user = self.add_user('*****@*****.**')
        test_user_2 = self.add_user('*****@*****.**')
        db.session.commit()

        event = self.add_event(name="Tech Talk",
                               description="tech talking",
                               start_date=datetime(2019, 12, 12, 10, 10, 10),
                               end_date=datetime(2020, 12, 12, 10, 10, 10),
                               key='REGINAL',
                               organisation_id=1,
                               email_from='*****@*****.**',
                               url='indaba.deeplearning')

        db.session.commit()

        offer = Offer(user_id=test_user.id,
                      event_id=event.id,
                      offer_date=datetime.now(),
                      expiry_date=datetime.now() + timedelta(days=15),
                      payment_required=False,
                      accommodation_award=True,
                      travel_award=True,
                      accepted_accommodation_award=True,
                      accepted_travel_award=True)
        db.session.add(offer)
        db.session.commit()

        offer_2 = Offer(
            user_id=test_user_2.id,
            event_id=event.id,
            offer_date=datetime.now(),
            expiry_date=datetime.now() + timedelta(days=15),
            payment_required=True,
            accommodation_award=False,
            travel_award=False,
            accepted_accommodation_award=False,
            accepted_travel_award=False,
        )
        db.session.add(offer_2)
        db.session.commit()

        form = RegistrationForm(event_id=event.id)
        db.session.add(form)
        db.session.commit()

        section = RegistrationSection(
            registration_form_id=form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()

        rq = RegistrationQuestion(section_id=section.id,
                                  registration_form_id=form.id,
                                  description="Will you be bringing a poster?",
                                  type="short-text",
                                  is_required=True,
                                  order=1,
                                  placeholder="the placeholder",
                                  headline="Will you be bringing a poster?",
                                  validation_regex="[]/",
                                  validation_text=" text")
        db.session.add(rq)
        db.session.commit()

        registration = Registration(offer_id=offer.id,
                                    registration_form_id=form.id,
                                    confirmed=True)
        db.session.add(registration)
        db.session.commit()

        registration_2 = Registration(offer_id=offer_2.id,
                                      registration_form_id=form.id,
                                      confirmed=True)
        db.session.add(registration_2)
        db.session.commit()

        ra = RegistrationAnswer(registration_id=registration_2.id,
                                registration_question_id=rq.id,
                                value="yes")
        db.session.add(ra)
        db.session.commit()

        template = InvitationTemplate(
            event_id=event.id,
            template_path="Indaba 2019  - Invitation Letter - General.docx",
            send_for_travel_award_only=False,
            send_for_accommodation_award_only=False,
            send_for_both_travel_accommodation=True)
        db.session.add(template)

        template_2 = InvitationTemplate(
            event_id=event.id,
            template_path=
            "Indaba 2019 - Invitation Letter - Travel & Accomodation.docx",
            send_for_travel_award_only=False,
            send_for_accommodation_award_only=False,
            send_for_both_travel_accommodation=False)
        db.session.add(template_2)
        db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.headers_2 = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #25
0
    def seed_static_data(self):
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        test_user = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr', 1, 1,
                            'Male', 'University', 'Computer Science', 'None',
                            1, datetime(1984, 12, 12), 'Zulu', '123456')
        test_user.verified_email = True
        db.session.add(test_user)
        db.session.commit()

        test_user_2 = AppUser('*****@*****.**', 'Some', 'Thing', 'Mr',
                              1, 1, 'Female', 'University',
                              'Computer Science', 'None', 1,
                              datetime(1984, 12, 12), 'Zulu', '123456')
        test_user_2.verified_email = True
        db.session.add(test_user_2)
        db.session.commit()

        event = Event(
            name="Tech Talk",
            description="tech talking",
            start_date=datetime(2019, 12, 12, 10, 10, 10),
            end_date=datetime(2020, 12, 12, 10, 10, 10),
        )
        db.session.add(event)
        db.session.commit()

        offer = Offer(user_id=test_user.id,
                      event_id=event.id,
                      offer_date=datetime.now(),
                      expiry_date=datetime.now() + timedelta(days=15),
                      payment_required=False,
                      accommodation_award=True,
                      travel_award=True,
                      accepted_accommodation_award=True,
                      accepted_travel_award=True)
        db.session.add(offer)
        db.session.commit()

        offer_2 = Offer(
            user_id=test_user_2.id,
            event_id=event.id,
            offer_date=datetime.now(),
            expiry_date=datetime.now() + timedelta(days=15),
            payment_required=True,
            accommodation_award=False,
            travel_award=False,
            accepted_accommodation_award=False,
            accepted_travel_award=False,
        )
        db.session.add(offer_2)
        db.session.commit()

        form = RegistrationForm(event_id=event.id)
        db.session.add(form)
        db.session.commit()

        section = RegistrationSection(
            registration_form_id=form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()

        rq = RegistrationQuestion(section_id=section.id,
                                  registration_form_id=form.id,
                                  description="Will you be bringing a poster?",
                                  type="short-text",
                                  is_required=True,
                                  order=1,
                                  placeholder="the placeholder",
                                  headline="Will you be bringing a poster?",
                                  validation_regex="[]/",
                                  validation_text=" text")
        db.session.add(rq)
        db.session.commit()

        registration = Registration(offer_id=offer.id,
                                    registration_form_id=form.id,
                                    confirmed=True)
        db.session.add(registration)
        db.session.commit()

        registration_2 = Registration(offer_id=offer_2.id,
                                      registration_form_id=form.id,
                                      confirmed=True)
        db.session.add(registration_2)
        db.session.commit()

        ra = RegistrationAnswer(registration_id=registration_2.id,
                                registration_question_id=rq.id,
                                value="yes")
        db.session.add(ra)
        db.session.commit()

        template = InvitationTemplate(
            event_id=event.id,
            template_path="Indaba 2019  - Invitation Letter - General.docx",
            send_for_travel_award_only=False,
            send_for_accommodation_award_only=False,
            send_for_both_travel_accommodation=True)
        db.session.add(template)

        template_2 = InvitationTemplate(
            event_id=event.id,
            template_path=
            "Indaba 2019 - Invitation Letter - Travel & Accomodation.docx",
            send_for_travel_award_only=False,
            send_for_accommodation_award_only=False,
            send_for_both_travel_accommodation=False)
        db.session.add(template_2)
        db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.headers_2 = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #26
0
    def _seed_data(self):
        organisation = self.add_organisation(
            'Deep Learning Indaba', 'Baobab', 'blah.png', 'blah_big.png',
            'deeplearningindba', 'https://www.deeplearningindaba.com',
            '*****@*****.**')

        email_templates = [
            EmailTemplate('withdrawal', None, ''),
            EmailTemplate('confirmation-response', None,
                          '{question_answer_summary}')
        ]
        db.session.add_all(email_templates)
        db.session.commit()

        # Add a user
        test_country = Country('Indaba Land')
        _add_object_to_db(test_country)

        test_category = UserCategory('Category1')
        _add_object_to_db(test_category)

        other_user_data = self.user_data_dict.copy()
        other_user_data['email'] = '*****@*****.**'
        response = self.app.post('/api/v1/user', data=other_user_data)
        self.other_user_data = json.loads(response.data)

        response = self.app.post('/api/v1/user', data=self.user_data_dict)
        self.user_data = json.loads(response.data)

        # Add application form data
        self.test_event = Event('Test Event', 'Event Description',
                                date(2019, 2, 24), date(2019, 3, 24),
                                'NAGSOLVER', 1, '*****@*****.**',
                                'indaba.deeplearning', datetime.now(),
                                datetime.now(), datetime.now(), datetime.now(),
                                datetime.now(), datetime.now(), datetime.now(),
                                datetime.now(), datetime.now(), datetime.now())
        _add_object_to_db(self.test_event)
        self.test_form = ApplicationForm(self.test_event.id, True,
                                         date(2019, 3, 24))
        _add_object_to_db(self.test_form)
        test_section = Section(self.test_form.id, 'Test Section',
                               'Test Description', 1)
        _add_object_to_db(test_section)
        self.test_question = Question(self.test_form.id, test_section.id,
                                      'Test Question Description',
                                      'Test question placeholder', 1,
                                      'Test Type', None)
        _add_object_to_db(self.test_question)
        self.test_question2 = Question(self.test_form.id, test_section.id,
                                       'Test Question 2', 'Enter something', 2,
                                       'short-text', None)
        _add_object_to_db(self.test_question2)

        self.test_response = Response(self.test_form.id,
                                      self.other_user_data['id'])
        _add_object_to_db(self.test_response)

        self.test_answer1 = Answer(self.test_response.id,
                                   self.test_question.id, 'My Answer')
        _add_object_to_db(self.test_answer1)

        db.session.flush()
Beispiel #27
0
    def seed_static_data(self):
        test_user = self.add_user('*****@*****.**')
        event_admin = self.add_user('*****@*****.**')

        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png', 'deeplearningindaba')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        event = Event(name="Tech Talk",
                      description="tech talking",
                      start_date=datetime(2019, 12, 12, 10, 10, 10),
                      end_date=datetime(2020, 12, 12, 10, 10, 10),
                      key='REGINAL',
                      organisation_id=1,
                      email_from='*****@*****.**',
                      url='indaba.deeplearning',
                      application_open=datetime.now(),
                      application_close=datetime.now(),
                      review_open=datetime.now(),
                      review_close=datetime.now(),
                      selection_open=datetime.now(),
                      selection_close=datetime.now(),
                      offer_open=datetime.now(),
                      offer_close=datetime.now(),
                      registration_open=datetime.now(),
                      registration_close=datetime.now())
        db.session.add(event)
        db.session.commit()

        self.form = RegistrationForm(event_id=event.id)
        db.session.add(self.form)
        db.session.commit()
        self.form_id = self.form.id

        self.event_id = event.id

        section = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=None,
            show_for_accommodation_award=None,
            show_for_payment_required=None,
        )
        db.session.add(section)
        db.session.commit()

        section2 = RegistrationSection(
            registration_form_id=self.form.id,
            name="Section 2",
            description="the section 2 description",
            order=1,
            show_for_travel_award=None,
            show_for_accommodation_award=None,
            show_for_payment_required=None,
        )
        db.session.add(section2)
        db.session.commit()

        self.question = RegistrationQuestion(section_id=section.id,
                                             registration_form_id=self.form.id,
                                             description="Question 1",
                                             type="short-text",
                                             is_required=True,
                                             order=1,
                                             placeholder="the placeholder",
                                             headline="the headline",
                                             validation_regex="[]/",
                                             validation_text=" text")
        db.session.add(self.question)
        db.session.commit()
        self.question_id = self.question.id

        self.question2 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 2",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question2)
        db.session.commit()
        self.question2_id = self.question2.id

        self.question3 = RegistrationQuestion(
            section_id=section2.id,
            registration_form_id=self.form.id,
            description="Question 3",
            type="short-text",
            is_required=True,
            order=1,
            placeholder="the placeholder",
            headline="the headline",
            validation_regex="[]/",
            validation_text=" text")
        db.session.add(self.question3)
        db.session.commit()
        self.question3_id = self.question3.id

        db.session.flush()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")
Beispiel #28
0
    def _seed_data(self):
        """Create dummy data for testing"""
        organisation = self.add_organisation(
            'Deep Learning Indaba', 'Baobab', 'blah.png', 'blah_big.png',
            'deeplearningindba', 'https://www.deeplearningindaba.com',
            '*****@*****.**')

        email_templates = [
            EmailTemplate('withdrawal', None, ''),
            EmailTemplate('confirmation-response', None,
                          '{question_answer_summary}')
        ]
        db.session.add_all(email_templates)
        db.session.commit()

        # Add country
        test_country = Country('Indaba Land')
        self.add_to_db(test_country)

        # Add category
        test_category = UserCategory('Category1')
        self.add_to_db(test_category)

        # Add users to database
        other_user_data = self.user_data_dict.copy()
        other_user_data['email'] = self.other_user_email
        response = self.app.post('/api/v1/user', data=other_user_data)
        self.other_user_data = json.loads(response.data)

        response = self.app.post('/api/v1/user', data=self.user_data_dict)
        self.user_data = json.loads(response.data)

        self.add_n_users(self.num_dummy_users)

        # Add application form data
        self.test_event = self.add_event('Test Event', 'Event Description',
                                         date(2019, 2, 24), date(2019, 3, 24),
                                         'NAGSOLVER')
        self.test_form = self.create_application_form(self.test_event.id, True)
        self.test_section = Section(self.test_form.id, 'Test Section',
                                    'Test Description', 1)
        self.test_section.key = 'test_section'
        self.add_to_db(self.test_section)
        self.test_question = Question(self.test_form.id, self.test_section.id,
                                      'Test Question Description',
                                      'Test question placeholder', 1,
                                      'Test Type', None)
        self.add_to_db(self.test_question)
        self.test_question2 = Question(self.test_form.id, self.test_section.id,
                                       'Test Question 2', 'Enter something', 2,
                                       'short-text', None)
        self.add_to_db(self.test_question2)

        # responses
        self.test_response = Response(self.test_form.id,
                                      self.other_user_data['id'])
        self.add_to_db(self.test_response)

        self.test_answer1 = Answer(self.test_response.id,
                                   self.test_question.id, 'My Answer')
        self.add_to_db(self.test_answer1)

        self.responses = []
        for user in self.test_users:
            response = Response(self.test_form.id, user.id)
            self.add_to_db(response)
            answer1 = Answer(
                response.id, self.test_question.id,
                "{}'s Answer for question 1".format(user.firstname))
            answer2 = Answer(
                response.id, self.test_question2.id,
                "{}'s Answer for question 2".format(user.firstname))
            self.add_to_db(answer1)
            self.add_to_db(answer2)
            self.responses.append(response)

        # add nomination application form
        self.test_nomination_form = self.create_application_form(
            self.test_event.id, True, True)
        self.test_nomination_response = Response(self.test_nomination_form.id,
                                                 self.other_user_data['id'])
        self.add_to_db(self.test_nomination_response)

        db.session.flush()
Beispiel #29
0
    def seed_static_data(self):
        test_user = self.add_user('*****@*****.**', 'Some', 'Thing', 'Mr')
        event_admin = self.add_user('*****@*****.**',
                                    'event_admin',
                                    is_admin=True)
        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png')
        db.session.add(UserCategory('Postdoc'))
        db.session.add(Country('South Africa'))
        db.session.commit()

        event = self.add_event(name="Tech Talk",
                               description="tech talking",
                               start_date=datetime(2019, 12, 12, 10, 10, 10),
                               end_date=datetime(2020, 12, 12, 10, 10, 10),
                               key='SPEEDNET')
        db.session.commit()

        self.event_id = event.id

        offer = Offer(user_id=test_user.id,
                      event_id=event.id,
                      offer_date=datetime.now(),
                      expiry_date=datetime.now() + timedelta(days=15),
                      payment_required=False,
                      travel_award=True,
                      accommodation_award=False)

        offer.candidate_response = True
        offer.accepted_travel_award = True

        db.session.add(offer)
        db.session.commit()
        self.offer_id = offer.id

        form = RegistrationForm(event_id=event.id)
        db.session.add(form)
        db.session.commit()

        section = RegistrationSection(
            registration_form_id=form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()

        section2 = RegistrationSection(
            registration_form_id=form.id,
            name="Section 2",
            description="the section 2 description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section2)
        db.session.commit()

        question = RegistrationQuestion(section_id=section.id,
                                        registration_form_id=form.id,
                                        description="Question 1",
                                        type="short-text",
                                        is_required=True,
                                        order=1,
                                        placeholder="the placeholder",
                                        headline="the headline",
                                        validation_regex="[]/",
                                        validation_text=" text")
        db.session.add(question)
        db.session.commit()

        question2 = RegistrationQuestion(section_id=section2.id,
                                         registration_form_id=form.id,
                                         description="Question 2",
                                         type="short-text",
                                         is_required=True,
                                         order=1,
                                         placeholder="the placeholder",
                                         headline="the headline",
                                         validation_regex="[]/",
                                         validation_text=" text")
        db.session.add(question2)
        db.session.commit()

        self.headers = self.get_auth_header_for("*****@*****.**")
        self.adminHeaders = self.get_auth_header_for("*****@*****.**")

        db.session.flush()
Beispiel #30
0
    def seed_static_data(self):
        user_category = UserCategory('PhD')
        db.session.add(user_category)

        country = Country('South Africa')
        db.session.add(country)

        attendee = AppUser('*****@*****.**', 'attendee', 'attendee', 'Mr',
                           1, 1, 'M', 'Wits', 'CS', 'NA', 1,
                           datetime(1984, 12, 12), 'Eng', 'abc')

        self.attendee = attendee

        registration_admin = AppUser('*****@*****.**', 'registration', 'admin',
                                     'Ms', 1, 1, 'F', 'NWU', 'Math', 'NA', 1,
                                     datetime(1984, 12, 12), 'Eng', 'abc')
        users = [attendee, registration_admin]

        for user in users:
            user.verify()
        db.session.add_all(users)

        event = Event(
            'indaba 2019',
            'The Deep Learning Indaba 2019, Kenyatta University, Nairobi, Kenya ',
            datetime(2019, 8, 25), datetime(2019, 8, 31))
        self.event = event
        db.session.add(self.event)

        event_role = EventRole('registration-admin', 2, 1)
        db.session.add(event_role)
        db.session.commit()
        offer = Offer(user_id=attendee.id,
                      event_id=event.id,
                      offer_date=datetime.now(),
                      expiry_date=datetime.now() + timedelta(days=15),
                      payment_required=False,
                      accommodation_award=True,
                      travel_award=True,
                      accepted_accommodation_award=True,
                      accepted_travel_award=True)
        db.session.add_all([offer])

        form = RegistrationForm(event_id=event.id)
        db.session.add(form)
        db.session.commit()
        self.form = form
        section = RegistrationSection(
            registration_form_id=form.id,
            name="Section 1",
            description="the section description",
            order=1,
            show_for_travel_award=True,
            show_for_accommodation_award=False,
            show_for_payment_required=False,
        )
        db.session.add(section)
        db.session.commit()
        rq = RegistrationQuestion(section_id=section.id,
                                  registration_form_id=form.id,
                                  description="Will you be bringing a poster?",
                                  type="short-text",
                                  is_required=True,
                                  order=1,
                                  placeholder="the placeholder",
                                  headline="Will you be bringing a poster?",
                                  validation_regex="[]/",
                                  validation_text=" text")
        db.session.add(rq)
        db.session.commit()

        registration = Registration(offer_id=offer.id,
                                    registration_form_id=form.id,
                                    confirmed=True)

        db.session.add_all([registration])
        db.session.commit()
        ra = RegistrationAnswer(registration_id=registration.id,
                                registration_question_id=rq.id,
                                value="yes")
        db.session.add_all([ra])
        db.session.commit()