from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): form_model = 'player' def vars_for_template(self): lik_unlik = " " ass_typ = " " pair_typ = " " if self.player.is_mcf: if self.player.with_mcf: lik_unlik = "Like you" pair_typ = " is " ass_typ = " mcf to mcf" else: lik_unlik = "Unlike you" pair_typ = " is not" ass_typ = " mcf to non_mcf" else: if self.player.with_mcf: # pair is a mcf lik_unlik = "Unlike you" pair_typ = " is " ass_typ = " non_mcf to mcf" else: # pair is not a mcf lik_unlik = "Like you" pair_typ = " is not" ass_typ = " non_mcf to non_mcf" return dict( like_unlike = lik_unlik, pair_type= pair_typ, association_type = ass_typ ) class Offer(Page): form_model = 'player' form_fields = ['sent'] def vars_for_template(self): lik_unlik = " " pair_typ = " " ass_typ = " " if self.player.is_mcf: if self.player.with_mcf: lik_unlik = "Like you" pair_typ = " is " ass_typ = " mcf to mcf" else: lik_unlik = "Unlike you" pair_typ = " is not " ass_typ = " mcf to non_mcf" else: if self.player.with_mcf: # pair is a mcf lik_unlik = "Unlike you" pair_typ = " is " ass_typ = " non_mcf to mcf" else: # pair is not a mcf lik_unlik = "Like you" pair_typ = " is not" ass_typ = " non_mcf to non_mcf" return dict( like_unlike = lik_unlik, pair_type= pair_typ, association_type = ass_typ, prompt = 'Please select how much of the {} you would like to send to the receiver?'.format(Constants.endowment) ) # def is_displayed(self): # return self.player.id_in_group == 1 class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): form_model = 'player' def vars_for_template(self): return dict( is_sender = self.player.is_sender, sent = self.player.sent, payoff = self.player.payoff ) page_sequence = [ Introduction, Offer , ResultsWaitPage , Results ]