Пример #1
0
    def post(self):
        title = self.request.get('title')
        venue = self.request.get('venue')
        when_from = self.request.get('when_from')
        when_to = self.request.get('when_to')
        faculty = self.request.get('faculty')
        when_registration_ends = self.request.get('when_registration_ends')
        when_payment_is_calculated = self.request.get('when_payment_is_calculated')
        max_participants = self.request.get('max_participants')
        brochure_url = self.request.get('brochure_url')
        description = self.request.get("description")

        training_program = TrainingProgram()
        training_program.title = title
        training_program.venue = venue
        training_program.when_from = parse_iso_datetime_string(when_from)
        training_program.when_to = parse_iso_datetime_string(when_to)
        training_program.faculty = faculty
        training_program.when_registration_ends = parse_iso_datetime_string(when_registration_ends)
        training_program.when_payment_is_calculated = parse_iso_datetime_string(when_payment_is_calculated)
        training_program.max_participants = dec(max_participants)
        training_program.brochure_url = brochure_url
        training_program.description = description
        training_program.put()

        fees1 = Decimal(self.request.get('fees_1'))
        fees2 = Decimal(self.request.get('fees_2'))
        fees3 = Decimal(self.request.get('fees_3'))
        participants1 = dec(self.request.get('participants_1'))
        participants2 = dec(self.request.get('participants_2'))
        participants3 = dec(self.request.get('participants_3'))

        fees_1 = TrainingProgramFee(fee=fees1, for_participant_count=participants1)
        fees_1.training_program = training_program
        fees_2 = TrainingProgramFee(fee=fees2, for_participant_count=participants2)
        fees_2.training_program = training_program
        fees_3 = TrainingProgramFee(fee=fees3, for_participant_count=participants3)
        fees_3.training_program = training_program

        db.put([fees_1, fees_2, fees_3])

        self.response.out.write(training_program.to_json('title', 'is_deleted', 'is_active', 'is_starred', 'when_created'))