from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class p0_set_cookies(Page): timeout_seconds = 0 def before_next_page(self): # Save the cookie to be used in case the user disconnects parti_url = self.request.build_absolute_uri( self.player.participant._start_url()) self.request.session["otree"] = parti_url self.request.session.set_expiry(30 * 60) # Set the cookie for X hours print('cookie installé pour 30 minutes') # self.participant.vars['statut'] = 'ok' # self.participant.vars['somme_finale'] = 5 class p1_paiement(Page): form_model = 'player' form_fields = ['telephone', 'email_1', 'email_2' ] def is_displayed(self): return self.participant.vars['statut'] == 'ok' def error_message(self, values): if values['email_1'] != values['email_2']: return 'Les adresses mails ne correspondent pas' if not ('.' in values['email_1']): return 'L\'adresse mail ne semble pas être au bon format' if not ('@' in values['email_1']): return 'L\'adresse mail ne semble pas être au bon format' def before_next_page(self): self.player.payoff = self.participant.vars['somme_finale'] self.player.statut = self.participant.vars['statut'] class p2_error_page(Page): def is_displayed(self): return self.participant.vars['statut'] != 'ok' pass class p2_merci(Page): def is_displayed(self): return self.participant.vars['statut'] == 'ok' pass page_sequence = [ p0_set_cookies, p1_paiement, p2_error_page, p2_merci, ]