39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Form(s) for the quest page.
|
|
"""
|
|
from django import forms
|
|
|
|
class DiceCallForm(forms.Form):
|
|
"""
|
|
The form for the QM making dice calls.
|
|
"""
|
|
diceNum = forms.IntegerField(min_value=1, max_value=99)
|
|
diceSides = forms.IntegerField(min_value=1, max_value=99)
|
|
diceMod = forms.IntegerField(
|
|
min_value=-999, max_value=999, required=False)
|
|
diceChal = forms.IntegerField(
|
|
min_value=1, max_value=999, required=False)
|
|
diceRollsTaken = forms.IntegerField(
|
|
min_value=1, max_value=99, required=False)
|
|
diceStrict = forms.BooleanField(required=False)
|
|
|
|
|
|
class PollForm(forms.Form):
|
|
"""
|
|
The form for the QM making new polls.
|
|
"""
|
|
multi_choice = forms.BooleanField(required=False)
|
|
allow_writein = forms.BooleanField(required=False)
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(PollForm, self).__init__(*args, **kwargs)
|
|
data = args[0] # it's not nice to assume
|
|
options = {k: v for k, v in data.items() if k.startswith('pollOption')}
|
|
if len(options) > 20:
|
|
return
|
|
for key, value in options.items():
|
|
if not value:
|
|
continue
|
|
self.fields[key] = forms.CharField(max_length=200)
|