-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathforms.py
68 lines (56 loc) · 2.63 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf8 -*-
#
# Copyright (C) 2016 Scifabric LTD.
#
# PyBossa is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBossa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
from flask_wtf import Form
from wtforms import StringField, IntegerField
from wtforms.validators import DataRequired, Email
from wtforms.fields.html5 import EmailField
class NewClient(Form):
"""New Client Form."""
name = StringField('name')
first_name = StringField('First name', validators=[DataRequired()])
last_name = StringField('Last name', validators=[DataRequired()])
address1 = StringField('Address', validators=[DataRequired()])
address2 = StringField('Address 2')
city = StringField('City', validators=[DataRequired()])
state = StringField('State', validators=[DataRequired()])
postal_code = StringField('Postal Code', validators=[DataRequired()])
country = StringField('Country', validators=[DataRequired()])
email = EmailField('Email', validators=[DataRequired(), Email()])
vat = StringField('VAT')
class NewInvoice(Form):
"""New Invoice Form."""
client_id = StringField('Client ID', validators=[DataRequired()])
product_key = StringField('Product Key')
notes = StringField('Notes')
cost = IntegerField('Cost', validators=[DataRequired()])
qty = IntegerField('Quantity', validators=[DataRequired()])
recurring = StringField('Recurring')
INVOICE_SCHEMA = {"type": "object",
"properties": {
"client_id": {"type": "number"},
"invoice_items": {"type": "array", "minItems": 1},
"recurring": {"type": "string"},
},
"required": ["client_id", "invoice_items"]}
INVOICE_ITEMS_SCHEMA = {"type": "object",
"properties": {
"notes": {"type": "string"},
"cost": {"type": "number"},
"qty": {"type": "number"},
"productkey": {"type": "string"}
},
"required": ["cost", "qty", "notes"]}