예제 #1
0
    def get(self):
        today = datetime.utcnow()
        training_programs = TrainingProgram.get_all_payable_for_date(today.year, today.month, today.day)
        for training_program in training_programs:
#            if not training_program.is_registration_closed:
            fees = training_program.get_fees_sorted()
            count = training_program.get_participant_count()

            current_fee = max([f.fee for f in fees])
            for fee in fees:
                if count <= fee.for_participant_count:
                    current_fee = fee.fee
                else:
                    continue
            training_program.final_price = current_fee
            training_program.put()

            for registrant in training_program.registrants:
                queue_mail_task(url='/worker/mail/training_announcement_payment_notification/',
                    params=dict(
                        registrant_key=str(registrant.key()),
                        training_program_key=str(training_program.key()),
                        current_fee=current_fee
                    ),
                    method='POST'
                )
예제 #2
0
파일: api.py 프로젝트: spaceone/mils-secure
 def get(self):
     #announcements = TrainingProgram.all().order('title').fetch(MAX_FETCH_LIMIT)
     announcements = TrainingProgram.get_all()
     announcements_list = []
     for announcement in announcements:
         d = announcement.to_json_dict('title', 'is_starred', 'is_active', 'is_deleted', 'when_created', 'is_canceled')
         d['participant_count'] = announcement.participant_count
         d['total_participant_count'] = announcement.total_participant_count
         announcements_list.append(d)
     self.response.out.write(json.dumps(announcements_list))
예제 #3
0
    def get(self):
        auth_level = self.is_user_authorized()
        if auth_level == models.AUTH_LEVEL_REGISTERED_USER:
            self.redirect('/account/activate/reminder/')
        elif auth_level == models.AUTH_LEVEL_ACTIVATED_USER:
            from datetime import datetime
            today = datetime.utcnow()

            training_announcements = TrainingProgram.get_all_approved_for_month(today.year, today.month)
            response = render_template('training_announcements.html', training_announcements=training_announcements)
            self.response.out.write(response)
        else:
            response = render_template('index.html')
            self.response.out.write(response)
예제 #4
0
 def get(self):
     today = datetime.utcnow()
     training_programs = TrainingProgram.get_all_closable_for_date(today.year, today.month, today.day)
     for training_program in training_programs:
         if not training_program.is_registration_closed:
             for registrant in training_program.registrants:
                 queue_mail_task(url='/worker/mail/training_announcement/closure/',
                     params=dict(
                         registrant_key=str(registrant.key()),
                         training_program_key=str(training_program.key())
                     ),
                     method='POST'
                 )
             training_program.is_registration_closed = True
             training_program.put()
예제 #5
0
    def get(self):
        from fee_calculation import calculate_fee
        
        today = datetime.utcnow()
        training_programs = TrainingProgram.get_all_payable_for_date(today.year, today.month, today.day)
        for training_program in training_programs:
            fees = training_program.get_fees_sorted_by_count()
            count = training_program.get_participant_count()
            current_fee = calculate_fee(fees, count)

            logging.info("fees: " + str(fees) + " count: " + str(count) + " current_fee: " + str(current_fee))
            training_program.final_price = current_fee
            training_program.is_payment_mail_queued = True
            training_program.put()

            for registrant in training_program.registrants:
                queue_mail_task(url='/worker/mail/training_announcement_payment_notification/',
                    params=dict(
                        registrant_key=str(registrant.key()),
                        training_program_key=str(training_program.key()),
                        current_fee=current_fee
                    ),
                    method='POST'
                )
예제 #6
0
파일: rpc.py 프로젝트: atulg/mils-secure
def get_announcement_titles():
    announcements = TrainingProgram.all().order('title').fetch(MAX_FETCH_LIMIT)
    announcements_list = []
    for announcement in announcements:
        announcements_list.append(announcement.to_json_dict('title', 'is_starred', 'is_active', 'is_deleted', 'when_created'))
    return announcements_list
예제 #7
0
파일: api.py 프로젝트: spaceone/mils-secure
    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'))