from otree.api import * from validate_email import validate_email doc = """ This application provides a webpage instructing participants how to get paid. Examples are given for the lab and Amazon Mechanical Turk (AMT). """ class C(BaseConstants): NAME_IN_URL = 'payment_info' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): paypal = models.StringField( label='Ihre E-Mail-Adresse zum Empfang einer Zahlung über PayPal:' ) # FUNCTIONS # PAGES class PaymentInfo(Page): form_model = 'player' form_fields = ['paypal'] @staticmethod def error_message(player, value): print('value is', value) if not validate_email( email_address=value['paypal'], check_dns=False, check_smtp=False): return 'Dies ist keine gültige E-Mail-Addresse.' @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( payoff=participant.payoff, participant_communication_mode=participant.communication_mode ) class End(Page): pass page_sequence = [PaymentInfo, End]