-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
43 lines (31 loc) · 1.32 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
from django import forms
from django.utils.translation import gettext_lazy as _
class LoginForm(forms.Form):
attrs = {
'id': "input-field",
'class': "input-field",
'placeholder': 'API key'
}
api_key = forms.CharField(label="",
widget=forms.TextInput(attrs=attrs))
class ChatForm(forms.Form):
text_field_attrs = {
'id': "input-field",
'class': "input-field",
'placeholder': _('Type your message here...')
}
text_field = forms.CharField(label="",
widget=forms.TextInput(attrs=text_field_attrs))
class ProviderLoginForm(forms.Form):
def __init__(self, *args, **kwargs):
self.provider_fields = kwargs.pop('provider_fields', [])
super().__init__(*args, **kwargs)
for field in self.provider_fields:
text_field_attrs = {
'name': field['name'],
'class': "input-field",
'placeholder': field['placeholder']
}
widget = forms.PasswordInput(attrs=text_field_attrs) if field['type'] == 'password' \
else forms.TextInput(attrs=text_field_attrs)
self.fields[field['name']] = forms.CharField(label=field.get('label', ''), widget=widget)