updated gitignore
[django-cas-provider.git] / cas_provider / forms.py
1 from django import forms
2 from django.conf import settings
3 from django.contrib.auth import authenticate
4 from django.forms import ValidationError
5 from django.utils.translation import ugettext_lazy as _
6 from models import LoginTicket
7 import datetime
8
9
10 class LoginForm(forms.Form):
11     email = forms.CharField(widget=forms.TextInput(attrs={'autofocus': 'autofocus',
12                                                           'placeholder': 'Email',
13                                                           'max_length': '255'}))
14     password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
15     service = forms.CharField(widget=forms.HiddenInput, required=False)
16     remember_me = forms.BooleanField(required=False, label="Keep me signed in",
17                                      widget=forms.CheckboxInput(attrs={'class': 'remember_me'}))
18
19     def __init__(self, *args, **kwargs):
20         # renew = kwargs.pop('renew', None)
21         # gateway = kwargs.pop('gateway', None)
22         request = kwargs.pop('request', None)
23         super(LoginForm, self).__init__(*args, **kwargs)
24         self.request = request
25
26     def clean_remember_me(self):
27         remember = self.cleaned_data['remember_me']
28         if not remember and self.request is not None:
29             self.request.session.set_expiry(0)
30
31
32 class MergeLoginForm(LoginForm):
33     email = forms.CharField(max_length=255, widget=forms.HiddenInput)