-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforms.py
73 lines (59 loc) · 3.15 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
"""AUCR case plugin default page forms."""
# coding=utf-8
from flask_wtf import FlaskForm
from wtforms import SubmitField, TextAreaField, SelectMultipleField, IntegerField
from wtforms.validators import Length
from flask_babel import lazy_gettext as _l
from aucr_app.plugins.Horatio.globals import AVAILABLE_CHOICES
class Horatio(FlaskForm):
"""New Case Form."""
createnewcase = SubmitField(_l("Create New Case"))
class CreateCase(FlaskForm):
"""Crease Case Form."""
subject = TextAreaField(_l('Subject'), validators=[Length(min=0, max=256)])
description = TextAreaField('Description', validators=[Length(min=0, max=256)])
case_notes = TextAreaField('Case Notes', validators=[Length(min=0, max=4912)])
current_state = SelectMultipleField('Status', choices=AVAILABLE_CHOICES)
detection_method = SelectMultipleField('Detection Method', choices=AVAILABLE_CHOICES)
group_access = SelectMultipleField('Group Access', choices=AVAILABLE_CHOICES)
assigned_to = SelectMultipleField('Assigned To', choices=AVAILABLE_CHOICES)
submit = SubmitField('Create')
class EditCase(FlaskForm):
"""Edit user profile settings."""
case_id = IntegerField(_l('Case ID'), validators=[Length(min=0, max=12)])
subject = TextAreaField(_l('Subject'), validators=[Length(min=0, max=256)])
description = TextAreaField(_l('Description'), validators=[Length(min=0, max=256)])
case_notes = TextAreaField(_l('Case Notes'), validators=[Length(min=0, max=4912)])
case_rules = TextAreaField(_l('Case Rules'), validators=[Length(min=0, max=4912)])
current_state = SelectMultipleField('Status', choices=AVAILABLE_CHOICES)
detection_method = SelectMultipleField('Detection Method', choices=AVAILABLE_CHOICES)
group_access = SelectMultipleField(_l('Group Access'), choices=AVAILABLE_CHOICES)
assigned_to = SelectMultipleField(_l('Assigned To'), choices=AVAILABLE_CHOICES)
submit = SubmitField(_l('Save'))
def __init__(self, case, *args, **kwargs):
"""Edit user profile init self and return username."""
super(EditCase, self).__init__(*args, **kwargs)
try:
self.case_id = case.id
self.subject = case.subject
self.description = case.description
self.case_notes = case.case_notes
self.case_rules = case.case_rules
self.detection_method = case.detection_method
self.group_access = case.group_access
self.current_state = case.case_status
except:
self.subject = case["subject"]
self.description = case["description"]
self.case_notes = case["case_notes"]
self.case_rules = case["case_rules"]
class SaveCase(FlaskForm):
"""Save Case Form."""
subject = TextAreaField(_l('Subject'), validators=[Length(min=0, max=256)])
description = TextAreaField(_l('Description'), validators=[Length(min=0, max=256)])
submit = SubmitField(_l('Save'))
def __init__(self, case, *args, **kwargs):
"""Edit user profile init self and return username."""
super(SaveCase, self).__init__(*args, **kwargs)
self.subject = case.subject
self.description = case.description