예제 #1
0
파일: tests.py 프로젝트: s-mawjee/Baobab
    def test_get_attendance_list(self):
        self.seed_static_data()

        # Create an unconfirmed user
        attendee2 = AppUser('*****@*****.**', 'attendee2', 'attendee2',
                            'Ms', 1, 1, 'M', 'Wits', 'CS', 'NA', 1,
                            datetime(1984, 12, 12), 'Eng', 'abc')

        self.attendee2 = attendee2
        db.session.add(attendee2)
        db.session.commit()

        offer2 = Offer(user_id=attendee2.id,
                       event_id=self.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(offer2)
        db.session.commit()

        registration2 = Registration(offer_id=offer2.id,
                                     registration_form_id=self.form.id,
                                     confirmed=False)
        db.session.add(registration2)
        db.session.commit()

        header = self.get_auth_header_for('*****@*****.**')

        user_id = 1
        params = {'event_id': 1}
        result = self.app.get('/api/v1/registration/confirmed',
                              headers=header,
                              data=params)
        data = json.loads(result.data)
        self.assertEqual(len(data), 2)
        self.assertEqual(data[0]['user_id'], user_id)

        params = {'user_id': user_id, 'event_id': 1}
        self.app.post('/api/v1/attendance', headers=header, data=params)

        # Exclude signed in
        params = {'event_id': 1, 'exclude_already_signed_in': True}
        result2 = self.app.get('/api/v1/registration/confirmed',
                               headers=header,
                               data=params)
        data2 = json.loads(result2.data)
        self.assertEqual(len(data2), 1)

        # Include signed in - possible to undo
        params = {'exclude_already_signed_in': 'false', 'event_id': 1}
        LOGGER.debug(params)
        result2 = self.app.get('/api/v1/registration/confirmed',
                               headers=header,
                               data=params)
        data2 = json.loads(result2.data)
        self.assertEqual(len(data2), 2)
예제 #2
0
    def test_registered(self):
        """Test statusess for registered attendees."""
        self.seed_static_data()

        outcome = Outcome(self.event.id, self.user1.id, OutcomeStatus.ACCEPTED,
                          self.user2.id)
        db.session.add(outcome)

        self.add_response(self.application_form.id,
                          self.user1.id,
                          is_submitted=True)

        offer = Offer(user_id=self.user1.id,
                      event_id=self.event.id,
                      offer_date=date.today(),
                      expiry_date=date.today() + timedelta(days=1),
                      payment_required=False,
                      travel_award=False,
                      accommodation_award=False,
                      candidate_response=True)
        db.session.add(offer)
        db.session.commit()

        registration = Registration(offer.id, self.registration_form.id)
        db.session.add(registration)
        db.session.commit()

        status = event_status.get_event_status(self.event.id, self.user1.id)
        self.assertIsNone(status.invited_guest)
        self.assertEqual(status.registration_status, 'Not Confirmed')
        self.assertEqual(status.application_status, 'Submitted')
        self.assertEqual(status.outcome_status, outcome.status.name)
        self.assertEqual(status.offer_status, 'Accepted')

        registration.confirm()
        db.session.commit()

        status = event_status.get_event_status(self.event.id, self.user1.id)
        self.assertEqual(status.registration_status, 'Confirmed')
예제 #3
0
    def post(self):
        # Save a new response for the logged-in user.
        req_parser = reqparse.RequestParser()
        args = self.req_parser.parse_args()
        offer_id = args['offer_id']

        try:
            offer = db.session.query(Offer).filter(
                Offer.id == offer_id).first()

            if not offer:
                return errors.OFFER_NOT_FOUND

            user_id = verify_token(request.headers.get('Authorization'))['id']
            if not user_id:
                return errors.USER_NOT_FOUND
            current_user = db.session.query(AppUser).filter(
                AppUser.id == user_id).first()

            registration_form = db.session.query(RegistrationForm).filter(
                RegistrationForm.id == args['registration_form_id']).first()

            if not registration_form:
                return errors.REGISTRATION_FORM_NOT_FOUND

            registration = Registration(
                offer_id=args['offer_id'],
                registration_form_id=args['registration_form_id'],
                confirmed=True if (not offer.payment_required) else False,
                confirmation_email_sent_at=date.today())

            db.session.add(registration)
            db.session.commit()

            event = event_repository.get_by_id(registration_form.event_id)

            for answer_args in args['answers']:
                if db.session.query(RegistrationQuestion).filter(
                        RegistrationQuestion.id ==
                        answer_args['registration_question_id']).first():

                    answer = RegistrationAnswer(
                        registration_id=registration.id,
                        registration_question_id=answer_args[
                            'registration_question_id'],
                        value=answer_args['value'])

                    db.session.add(answer)
            db.session.commit()

            registration_answers = db.session.query(RegistrationAnswer).filter(
                RegistrationAnswer.registration_id == registration.id).all()
            registration_questions = db.session.query(
                RegistrationQuestion).filter(
                    RegistrationQuestion.registration_form_id ==
                    args['registration_form_id']).all()

            self.send_confirmation(current_user, registration_questions,
                                   registration_answers,
                                   registration.confirmed, event)

            # 201 is 'CREATED' status code
            return marshal(registration, self.registration_fields), 201

        except SQLAlchemyError as e:
            LOGGER.error("Database error encountered: {}".format(e))
            return errors.DB_NOT_AVAILABLE
        except Exception as e:
            LOGGER.error("Encountered unknown error: {}".format(
                traceback.format_exc()))
            return errors.DB_NOT_AVAILABLE
예제 #4
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()
예제 #5
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()
예제 #6
0
파일: tests.py 프로젝트: s-mawjee/Baobab
    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()
예제 #7
0
파일: tests.py 프로젝트: s-mawjee/Baobab
    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()
예제 #8
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()
예제 #9
0
    def seed_static_data(self):
        self.add_organisation('Deep Learning Indaba', 'blah.png',
                              'blah_big.png', 'deeplearningindaba')
        user_category = UserCategory('PhD')
        db.session.add(user_category)
        db.session.commit()

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

        self.attendee = self.add_user(email='*****@*****.**')

        registration_admin = self.add_user('*****@*****.**')

        event = self.add_event(
            'indaba 2019',
            'The Deep Learning Indaba 2019, Kenyatta University, Nairobi, Kenya ',
            datetime(2019, 8, 25), datetime(2019, 8, 31), 'JOLLOF')
        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=self.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()