forms.py 7.53 KB
Newer Older
Timo Heikkilä's avatar
Timo Heikkilä committed
1
2
3
4
5
6
7
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField
from wtforms.validators import DataRequired, InputRequired
from wtforms_sqlalchemy.fields import QuerySelectField
from flask_bootstrap import Bootstrap
from app.models import background_question
from wtforms import Form, TextField, TextAreaField, SubmitField, FieldList, FormField
Timo Heikkilä's avatar
Timo Heikkilä committed
8
from wtforms import Form, BooleanField, StringField, PasswordField, validators, RadioField, IntegerField
Timo Heikkilä's avatar
Timo Heikkilä committed
9
from flask_wtf.file import FileField, FileAllowed, FileRequired
Timo Heikkilä's avatar
Timo Heikkilä committed
10
11
from flask_babel import _
from flask_babel import lazy_gettext as _l
Timo Heikkilä's avatar
Timo Heikkilä committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')


class RegisterForm(Form):
    
    questions1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


class TaskForm(Form):
28
    __name__= 'slider'
Timo Heikkilä's avatar
Timo Heikkilä committed
29
30
31
32
    categories1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


33
34
35
36
37
38
class StringForm(Form):
    __name__= 'embody'
    text = StringField()
    submit = SubmitField("Send")


Timo Heikkilä's avatar
Timo Heikkilä committed
39
40
41
class ContinueTaskForm(FlaskForm):
    
    participant_id = StringField('participant_id', validators=[DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
42
    submit = SubmitField( _l('Continue rating') )
Timo Heikkilä's avatar
Timo Heikkilä committed
43
44
45
46

class StartWithIdForm(FlaskForm):
    
    participant_id = StringField('participant_id', validators=[DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
47
    submit = SubmitField( _l('Start rating') )
Timo Heikkilä's avatar
Timo Heikkilä committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 

class Questions(FlaskForm):
    
    questions = StringField()


class Answers(FlaskForm):
    
    background_question_idbackground_question = SelectField(coerce=int, validators=[InputRequired])


class BackgroundQuestionForm(Form):
    
    idbackground_question_option = StringField()
    background_question_idbackground_question = StringField()
    option = StringField()
    submit = SubmitField('Register')


class TestForm(Form):
    
    question_name = StringField()
    options1 = SelectField()


class TestForm1(Form):
    
    questions1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


class TestForm2(Form):

    questions1 = SelectField()

#Forms for editing functions
    
    
class CreateExperimentForm(Form):

    name = StringField('Name', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
90
91
92
93
94
    creator_name = StringField('Creator_name', [validators.DataRequired()])     
    single_sentence_instruction = StringField('Single_sentence_instruction', [validators.DataRequired()])
    short_instruction = TextAreaField('Short_instruction', [validators.DataRequired()])
    instruction = TextAreaField('Instruction', [validators.DataRequired()])
    consent_text = TextAreaField('Instruction', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
95
96
97
98
99
100
101
    language = StringField('Language', [validators.DataRequired()])
    submit = SubmitField('Send')


class EditExperimentForm(Form):

    name = StringField('Name', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
102
103
104
105
106
    creator_name = StringField('Creator_name', [validators.DataRequired()])
    instruction = TextAreaField('Instruction', [validators.DataRequired()])
    consent_text = TextAreaField('Instruction', [validators.DataRequired()])
    short_instruction = TextAreaField('Short_instruction', [validators.DataRequired()])
    single_sentence_instruction = StringField('Single_sentece_instruction', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
107
108
    language = SelectField('Language', choices=[
            ('Afrikanns', 'Afrikanns'), ('Albanian', 'Albanian'), ('Arabic', 'Arabic'), ('Armenian', 'Armenian'), ('Basque', 'Basque'), ('Bengali', 'Bengali'), ('Bulgarian', 'Bulgarian'),
Timo Heikkilä's avatar
Timo Heikkilä committed
109
            ('Catalan', 'Catalan'), ('Cambodian', 'Cambodian'), ('Chinese', 'Chinese'), ('Croation', 'Croation'), ('Czech', 'Czech'), ('Danish', 'Danish'),
Timo Heikkilä's avatar
Timo Heikkilä committed
110
111
112
113
114
115
116
117
118
            ('Dutch', 'Dutch'), ('English', 'English'), ('Estonian', 'Estonian'), ('Fiji', 'Fiji'), ('Finnish', 'Finnish'), ('French', 'French'), ('Georgian', 'Georgian'),
            ('German', 'German'), ('Greek', 'Greek'), ('Gujarati', 'Gujarati'), ('Hebrew', 'Hebrew'), ('Hindi', 'Hindi'), ('Hungarian', 'Hungarian'), ('Icelandic', 'Icelandic'),
            ('Indonesian', 'Indonesian'), ('Irish', 'Irish'), ('Italian', 'Italian'), ('Japanese', 'Japanese'), ('Javanese', 'Javanese'), ('Korean', 'Korean'), ('Latin', 'Latin'),
            ('Latvian', 'Latvian'), ('Lithuanian', 'Lithuanian'), ('Macedonian', 'Macedonian'), ('Malay', 'Malay'), ('Malayalam', 'Malayalam'), ('Maltese', 'Maltese'), ('Maori', 'Maori'),
            ('Marathi', 'Marathi'), ('Mongolian', 'Mongolian'), ('Nepali', 'Nepali'), ('Norwegian', 'Norwegian'), ('Persian', 'Persian'), ('Polish', 'Polish'), ('Portuguese', 'Portuguese'),
            ('Punjabi', 'Punjabi'), ('Quechua', 'Quechua'), ('Romanian', 'Romanian'), ('Russian', 'Russian'), ('Samoan', 'Samoan'), ('Serbian', 'Serbian'), ('Slovak', 'Slovak'),
            ('Slovenian', 'Slovenian'), ('Spanish', 'Spanish'), ('Swahili', 'Swahili'), ('Swedish ', 'Swedish '), ('Tamil', 'Tamil'), ('Tatar', 'Tatar'), ('Telugu', 'Telugu'),
            ('Thai', 'Thai'), ('Tibetan', 'Tibetan'), ('Tonga', 'Tonga'), ('Turkish', 'Turkish'), ('Ukranian', 'Ukranian'), ('Urdu', 'Urdu'), ('Uzbek', 'Uzbek'), ('Vietnamese', 'Vietnamese'),
            ('Welsh', 'Welsh'), ('Xhosa', 'Xhosa')])
Timo Heikkilä's avatar
Timo Heikkilä committed
119
120
121
    stimulus_size = SelectField('Stimulus_size', choices=[
            ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10'), ('11', '11'), ('12', '12')])
            
Timo Heikkilä's avatar
Timo Heikkilä committed
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    submit = SubmitField('Send')


class CreateBackgroundQuestionForm(Form):
    
    bg_questions_and_options = TextAreaField('Background questions and options', [validators.DataRequired()])
    submit = SubmitField('Send')

    
class EditBackgroundQuestionForm(Form):
    
    bg_questions_and_options = TextAreaField('Background questions and options')
    new_values = TextAreaField('New values', [validators.DataRequired()])
    submit = SubmitField('Send')


class CreateQuestionForm(Form):
    
    questions_and_options = TextAreaField('Questions and options', [validators.DataRequired()])
    submit = SubmitField('Send')


Ossi Laine's avatar
Ossi Laine committed
144
145
146
147
148
149
class CreateEmbodyForm(Form):
    
    question = TextAreaField('Question')
    picture = FileField('Upload picture')
    submit = SubmitField('Send')

Timo Heikkilä's avatar
Timo Heikkilä committed
150
151
152
153
154
155
156
157
158
159
160
161
162
163
class EditQuestionForm(Form): 

    left = StringField('left_scale', [validators.DataRequired()])
    right = StringField('right_scale', [validators.DataRequired()])
    question = StringField('question', [validators.DataRequired()])


class UploadStimuliForm(Form):
    
    type = RadioField('type', choices=[('text', 'text'), ('picture', 'picture'), ('video', 'video'), ('audio', 'audio')])
    text = TextAreaField('Text stimulus')
    media = TextAreaField('Media filename')
    file = FileField('Upload file')
    submit = SubmitField('Send')
Timo Heikkilä's avatar
Timo Heikkilä committed
164
165
166
167
168
169
170


class UploadResearchBulletinForm(Form):
    
    file = FileField('Upload file')
    submit = SubmitField('Send')

Timo Heikkilä's avatar
Timo Heikkilä committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    

class EditPageForm(Form):
    
    type = RadioField('type', choices=[('text', 'text'), ('picture', 'picture'), ('video', 'video'), ('audio', 'audio')])
    text = TextAreaField('Text stimulus')
    media = TextAreaField('Media filename')
    file = FileField('Upload file')
    submit = SubmitField('Send')
    
    
class RemoveExperimentForm(Form):
    remove = TextAreaField('Remove')
    submit = SubmitField('Send')

Timo Heikkilä's avatar
Timo Heikkilä committed
186
187
188
189
190
191
class GenerateIdForm(Form): 

    number = IntegerField('number', [validators.DataRequired()])
    string = StringField('string', [validators.DataRequired()])
    submit = SubmitField('Submit')