-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathforms.py
More file actions
168 lines (138 loc) · 4.56 KB
/
forms.py
File metadata and controls
168 lines (138 loc) · 4.56 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# FederatedCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/federatedcode for support or download.
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
#
from django import forms
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV2Checkbox
from .models import Note
from .models import Repository
from .models import Review
class CreateGitRepoForm(forms.ModelForm):
class Meta:
model = Repository
fields = ["url"]
def __init__(self, *args, **kwargs):
super(CreateGitRepoForm, self).__init__(*args, **kwargs)
self.fields["url"].widget.attrs.update(
{"class": "input", "placeholder": "https://github.com/nexB/vulnerablecode-data"}
)
self.fields["url"].help_text = ""
self.fields["url"].label = ""
class CreateNoteForm(forms.ModelForm):
class Meta:
model = Note
fields = ["content"]
def __init__(self, *args, **kwargs):
super(CreateNoteForm, self).__init__(*args, **kwargs)
self.fields["content"].widget.attrs.update(
{"class": "textarea", "placeholder": "Comment...", "rows": 5}
)
self.fields["content"].label = ""
self.fields["content"].help_text = ""
class ReviewStatusForm(forms.ModelForm):
class Meta:
model = Review
fields = ["status"]
help_texts = {
"status": None,
}
def __init__(self, *args, **kwargs):
super(ReviewStatusForm, self).__init__(*args, **kwargs)
self.fields["status"].widget.attrs.update({"class": "input mb-5"})
class PersonSignUpForm(UserCreationForm):
captcha = ReCaptchaField(
error_messages={"required": ("Captcha is required")}, widget=ReCaptchaV2Checkbox
)
email = forms.EmailField(max_length=254)
class Meta:
model = User
fields = (
"username",
"email",
"password1",
"password2",
)
class CreateReviewForm(forms.Form):
headline = forms.CharField(
widget=forms.TextInput(
attrs={
"class": "input is-medium title has-text-centered",
"placeholder": "Review Title",
}
)
)
data = forms.CharField(widget=forms.Textarea(attrs={"class": "textarea", "rows": 16}))
filename = forms.CharField(widget=forms.HiddenInput())
class FetchForm(forms.Form):
file_path = forms.CharField(
widget=forms.TextInput(
attrs={
"class": "input",
"placeholder": "alpine/dia/VCID-xxx-xxx-xxx.yaml",
}
)
)
class SubscribePackageForm(forms.Form):
acct = forms.CharField(
label="Subscribe with a remote account:",
widget=forms.TextInput(
attrs={"placeholder": "ziadhany@vulnerablecode.io", "class": "input"}
),
)
class SearchPackageForm(forms.Form):
search = forms.CharField(
required=True,
label=False,
widget=forms.TextInput(
attrs={
"placeholder": "Search a package...",
"class": "input ",
},
),
)
class SearchReviewForm(forms.Form):
search = forms.CharField(
required=True,
label=False,
widget=forms.TextInput(
attrs={
"placeholder": "Please Enter a valid Review Name",
"class": "input is-rounded",
"style": "width: 90%;",
},
),
)
class SearchRepositoryForm(forms.Form):
search = forms.CharField(
required=True,
label=False,
widget=forms.TextInput(
attrs={
"placeholder": "Search a repository...",
"class": "input",
},
),
)
class UserLoginForm(AuthenticationForm):
captcha = ReCaptchaField(
error_messages={
"required": ("Captcha is required"),
},
widget=ReCaptchaV2Checkbox,
)
class AdminLoginForm(AdminAuthenticationForm):
captcha = ReCaptchaField(
error_messages={
"required": ("Captcha is required"),
},
widget=ReCaptchaV2Checkbox(),
)