8a8226baa8e8debff390feb7d30f79fba4cf1ac1
[django-cas-provider.git] / cas_provider / forms.py
1 from django import forms
2 from django.contrib.auth.forms import AuthenticationForm
3 from django.contrib.auth import authenticate
4 from django.utils.translation import ugettext_lazy as _
5
6 from utils import create_login_ticket
7
8 class LoginForm(forms.Form):
9     username = forms.CharField(max_length=30, label=_('username'))
10     password = forms.CharField(widget=forms.PasswordInput, label=_('password'))
11     #warn = forms.BooleanField(required=False)  # TODO: Implement
12     lt = forms.CharField(widget=forms.HiddenInput, initial=create_login_ticket)
13     def __init__(self, service=None, renew=None, gateway=None, request=None, *args, **kwargs):
14         super(LoginForm, self).__init__(*args, **kwargs)
15         self.request = request
16         if service is not None:
17             self.fields['service'] = forms.CharField(widget=forms.HiddenInput, initial=service)