from my_survey._builtin import Page from my_survey.models import Constants class Introduction(Page): def is_displayed(self): return self.round_number == 1 class Introduction_latter(Page): def is_displayed(self): return self.round_number == Constants.the_latter class Investment1(Page): def is_displayed(self): return self.player.pressure == 1 and self.round_number >= Constants.the_latter form_model = 'player' form_fields = ['lottery_num'] timeout_seconds = 10 def before_next_page(self): player = self.player timeout_happened = self.timeout_happened if timeout_happened: player.lottery_num = -1 class Investment2(Page): def is_displayed(self): return self.player.pressure == 0 or self.round_number < Constants.the_latter form_model = 'player' form_fields = ['lottery_num'] class Results(Page): def vars_for_template(self): lottery_num = self.player.lottery_num self.player.invest_return(lottery_num) class ResultsSummary(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [Introduction, Introduction_latter, Investment1, Investment2, Results, ResultsSummary]