mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from captcha.fields import CaptchaField
|
|
from django import forms
|
|
|
|
from comic.models import Setting
|
|
|
|
|
|
class LoginForm(forms.Form):
|
|
|
|
username = forms.CharField(max_length=50,
|
|
label='',
|
|
widget=forms.TextInput(
|
|
attrs={
|
|
'class': 'form-control',
|
|
'placeholder': 'Username',
|
|
'autofocus': True,
|
|
'required': True,
|
|
}
|
|
))
|
|
password = forms.CharField(label='Password',
|
|
widget=forms.PasswordInput(
|
|
attrs={
|
|
'class': 'form-control',
|
|
'placeholder': 'Username',
|
|
'required': True,
|
|
}
|
|
))
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(LoginForm, self).__init__(*args, **kwargs)
|
|
setting, created = Setting.objects.get_or_create(name='RECAPTCHA')
|
|
if created:
|
|
setting.value = '0'
|
|
if setting.value == '1':
|
|
public_key = Setting.objects.get(name='RECAPTCHA_PUBLIC_KEY').value
|
|
private_key = Setting.objects.get(name='RECAPTCHA_PRIVATE_KEY').value
|
|
|
|
captcha = CaptchaField(
|
|
label='',
|
|
public_key=public_key,
|
|
private_key=private_key,
|
|
attrs={
|
|
'theme': 'white',
|
|
'class': 'form-control',
|
|
}
|
|
)
|
|
self.fields['captcha'] = captcha |