2018-08-23 07:40:28 -04:00
|
|
|
#!/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.
|
|
|
|
"""
|
2018-09-24 09:59:11 -04:00
|
|
|
diceNum = forms.IntegerField(min_value=1, max_value=256)
|
|
|
|
diceSides = forms.IntegerField(min_value=1, max_value=65536)
|
2018-08-23 11:57:37 -04:00
|
|
|
diceMod = forms.IntegerField(
|
2018-09-24 09:59:11 -04:00
|
|
|
min_value=-65536, max_value=65536, required=False)
|
2018-08-23 11:57:37 -04:00
|
|
|
diceChal = forms.IntegerField(
|
2018-09-24 09:59:11 -04:00
|
|
|
min_value=1, max_value=65536, required=False)
|
2018-08-23 11:57:37 -04:00
|
|
|
diceRollsTaken = forms.IntegerField(
|
2018-09-24 09:59:11 -04:00
|
|
|
min_value=1, max_value=256, required=False)
|
2018-08-23 07:40:28 -04:00
|
|
|
diceStrict = forms.BooleanField(required=False)
|
2018-08-29 14:01:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2018-09-21 14:18:54 -04:00
|
|
|
|
2018-09-24 08:22:01 -04:00
|
|
|
class EditQuestForm(forms.Form):
|
2018-09-21 14:18:54 -04:00
|
|
|
"""
|
|
|
|
Form for the /edit_quest page.
|
|
|
|
"""
|
|
|
|
anon_name = forms.CharField(max_length=20)
|
2018-09-30 15:20:42 -04:00
|
|
|
live = forms.BooleanField(required=False)
|
|
|
|
live_date = forms.DateField(required=False)
|
|
|
|
live_time = forms.TimeField(required=False)
|
|
|
|
timezone = forms.IntegerField()
|