-
Notifications
You must be signed in to change notification settings - Fork 20
/
forms.py
85 lines (55 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from flask_wtf import FlaskForm
from wtforms import BooleanField, StringField, TextAreaField, validators
"""
Note: field names must match the method names used by the various API client libraries.
Libraries are located under twexit/lib.
"""
class BaseForm(FlaskForm):
def __iter__(self):
token = self.csrf_token
yield token
field_names = {token.name}
for cls in self.__class__.__bases__:
for field in cls():
field_name = field.name
if field_name not in field_names:
field_names.add(field_name)
yield self[field_name]
for field_name in self._fields:
if field_name not in field_names:
yield self[field_name]
class UserIdForm(BaseForm):
USER_ID = StringField('LDAP user name', [validators.DataRequired(), validators.Length(min=2)])
class GoogleAdminApiForm(BaseForm):
RESET_PASSWORD = BooleanField('Reset Google apps password')
DELETE_ASPS = BooleanField('Purge application specific passwords')
DELETE_TOKENS = BooleanField('Purge 3rd party access tokens')
INVALIDATE_BACKUP_CODES = BooleanField('Invalidate backup codes')
ORG_UNIT_CHANGE = BooleanField('Move to Offboarded OU')
ORG_UNIT_RESET = BooleanField('Restore move to Offboarded OU')
class GoogleGmailApiForm(BaseForm):
SET_OOO_MSG = BooleanField('Set Out Of Office message')
OOO_MSG_TEXT = TextAreaField('Message text', [validators.Length(min=2)])
DISABLE_IMAP = BooleanField('Disable IMAP email')
DISABLE_POP = BooleanField('Disable POP email')
class GoogleCalendarApiForm(BaseForm):
CHANGE_EVENTS_OWNERSHIP = BooleanField('Change events ownership')
GCAL_NEW_OWNER = StringField('LDAP of new owner', [validators.Length(min=2)])
REMOVE_FUTURE_EVENTS = BooleanField('Delete future dated events')
class PagerDutyApiForm(BaseForm):
REMOVE_FROM_ONCALLS = BooleanField('Remove from OnCall rotas')
class DuoApiForm(BaseForm):
REMOVE_FROM_DUO = BooleanField('Remove from DUO')
class GoogleApiForms(GoogleAdminApiForm, GoogleGmailApiForm, GoogleCalendarApiForm):
pass
class OffboardForm(UserIdForm, GoogleApiForms, PagerDutyApiForm, DuoApiForm):
pass
class LostAssetForm(UserIdForm, GoogleAdminApiForm, GoogleGmailApiForm):
pass
class GoogleMailForwardingForm(BaseForm):
SET_MAIL_FORWARDING = BooleanField('Set a mail forwarding address')
class GoogleDriveForm(BaseForm):
FILE_SEARCH = StringField('File Search Query', [validators.Length(min=2)])
NEW_OWNER = StringField('New files owner', [validators.DataRequired(), validators.Length(min=2)])
class FilesOwnershipTransferForm(UserIdForm, GoogleDriveForm):
pass