from .models import * class WTPwelcome(Page): form_model = 'player' def before_next_page(self): timeout_happened = self.timeout_happened participant = self.participant player = self.player player.brico = player.set_brico() player.r1_earnings = participant.payoff class WTPinstuctions(Page): form_model = 'player' def vars_for_template(self): player = self.player if player.brico == True: card1 = "a Brico" card2 = "an Amazon" else: card1 = "an Amazon" card2 = "a Brico" return dict(card1=card1, card2=card2) class WTPdecision(Page): form_model = 'player' form_fields = ['willingness_to_pay'] class WTPresults(Page): form_model = 'player' def vars_for_template(self): player = self.player if player.brico == True: card1 = "Brico" card2 = "Amazon" elif player.brico == False: card1 = "Amazon" card2 = "Brico" if player.willingness_to_pay > 2: payment_status = "will pay" cardname_outcome = card2 else: payment_status = "will not pay" cardname_outcome = card1 return dict(cardname=card1, wtp = player.willingness_to_pay, card2=card2, payment_status=payment_status, cardname_outcome=cardname_outcome) def before_next_page(self): timeout_happened = self.timeout_happened player = self.player wtp = player.willingness_to_pay if player.brico == True: card1 = "Brico" card2 = "Amazon" else: card1 = "Amazon" card2 = "Brico" if wtp > 2: payment = wtp cardname_outcome = card2 player.paid = True else: payment = 0 cardname_outcome = card1 player.paid = False player.payment = payment player.outcome_card = cardname_outcome player.payoff = 5 - payment class Results(Page): form_model = 'player' def vars_for_template(self): player = self.player total_earnings = player.r1_earnings + player.payoff player.total = total_earnings return dict(r1=player.r1_earnings, r2 = player.payoff, total = total_earnings) page_sequence = [WTPwelcome, WTPinstuctions, WTPdecision, WTPresults, Results]