class FormFieldModel(otree.models.BaseGroup): null_boolean = models.BooleanField() big_integer = models.BigIntegerField() boolean = models.BooleanField(default=False) char = models.CharField() comma_separated_integer = models.CommaSeparatedIntegerField(max_length=100) date = models.DateField() date_time = models.DateTimeField() alt_date_time = models.DateTimeField( widget=otree.forms.SplitDateTimeWidget) decimal = models.DecimalField(max_digits=5, decimal_places=2) email = models.EmailField() file = models.FileField(upload_to='_tmp/uploads') file_path = models.FilePathField() float = models.FloatField() integer = models.IntegerField() generic_ip_address = models.GenericIPAddressField() positive_integer = models.PositiveIntegerField() positive_small_integer = models.PositiveSmallIntegerField() slug = models.SlugField() small_integer = models.SmallIntegerField() text = models.TextField() alt_text = models.TextField(widget=otree.forms.TextInput) time = models.TimeField() url = models.URLField() many_to_many = models.ManyToManyField('SimpleModel', related_name='+') one_to_one = models.OneToOneField('SimpleModel', related_name='+') currency = models.CurrencyField() currency_choice = models.CurrencyField(choices=[('0.01', '0.01'), ('1.20', '1.20')]) sent_amount = models.CurrencyField(choices=currency_range(0, 0.75, 0.05)) slider_widget = models.IntegerField(widget=widgets.SliderInput())
class Player(otree.models.BasePlayer): # <built-in> group = models.ForeignKey(Group, null=True) subsession = models.ForeignKey(Subsession) # </built-in> # training training_buyer_earnings = models.IntegerField( verbose_name="Buyer's period payoff would be") training_seller1_earnings = models.IntegerField( verbose_name="Seller 1's period payoff would be") training_seller2_earnings = models.IntegerField( verbose_name="Seller 2's period payoff would be") # seller price = models.CurrencyField( bounds=[0, Constants.INITIAL], verbose_name='Please indicate a price (from 0 to %i) you want to sell' % Constants.INITIAL) quality = models.CurrencyField(choices=[ (30, 'High'), (20, 'Medium'), (10, 'Low')], verbose_name='Please select a quality grade you want to produce', widget=widgets.RadioSelectHorizontal()) # buyer choice = models.PositiveSmallIntegerField( choices=[(i, 'Buy from seller %i' % i) for i in range(1, Constants.players_per_group)] + [(0, 'Buy nothing')], blank=True, widget=widgets.RadioSelect(), verbose_name='And you will') # seller index def role(self): if self.id_in_group == 1: return 'buyer' return 'seller %i' % (self.id_in_group - 1)