from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from datetime import date class PaymentPage(Page): form_model = 'player' form_fields = ['mobile_number', 'name', 'receipt_ack'] live_method = 'ack_payment' def vars_for_template(self): participation_fee = float(self.session.config['participation_fee']) stage3_exptpoints = int(self.player.participant.vars['Stage3Earning']['Earning']) stage3_earning = float(stage3_exptpoints * Constants.expt_point) total_earning = stage3_earning + participation_fee participation_fee = '%.2f' % participation_fee stage3_earning = '%.2f' % stage3_earning total_earning = '%.2f' % total_earning return dict( stage3_earning=stage3_earning, stage3_exptpoints=stage3_exptpoints, total_earning=total_earning, participation_fee=participation_fee, group=self.player.group.id_in_subsession, participant_id=self.player.participant.id_in_session, date=str(date.today()) ) class FinalPage(Page): pass page_sequence = [PaymentPage, FinalPage]