from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import authenticate
+from django.utils.translation import ugettext_lazy as _
from utils import create_login_ticket
class LoginForm(forms.Form):
- username = forms.CharField(max_length=30)
- password = forms.CharField(widget=forms.PasswordInput)
+ username = forms.CharField(max_length=30, label=_('username'))
+ password = forms.CharField(widget=forms.PasswordInput, label=_('password'))
#warn = forms.BooleanField(required=False) # TODO: Implement
lt = forms.CharField(widget=forms.HiddenInput, initial=create_login_ticket)
def __init__(self, service=None, renew=None, gateway=None, request=None, *args, **kwargs):
from django.db import models
from django.contrib.auth.models import User
+from django.utils.translation import ugettext_lazy as _
class ServiceTicket(models.Model):
- user = models.ForeignKey(User)
- service = models.URLField(verify_exists=False)
- ticket = models.CharField(max_length=256)
- created = models.DateTimeField(auto_now=True)
-
+ user = models.ForeignKey(User, verbose_name=_('user'))
+ service = models.URLField(_('service'), verify_exists=False)
+ ticket = models.CharField(_('ticket'), max_length=256)
+ created = models.DateTimeField(_('created'), auto_now=True)
+
+ class Meta:
+ verbose_name = _('Service Ticket')
+ verbose_name_plural = _('Service Tickets')
+
def __unicode__(self):
return "%s (%s) - %s" % (self.user.username, self.service, self.created)
-
+
class LoginTicket(models.Model):
- ticket = models.CharField(max_length=32)
- created = models.DateTimeField(auto_now=True)
-
+ ticket = models.CharField(_('ticket'), max_length=32)
+ created = models.DateTimeField(_('created'), auto_now=True)
+
+ class Meta:
+ verbose_name = _('Login Ticket')
+ verbose_name_plural = _('Login Tickets')
+
def __unicode__(self):
- return "%s - %s" % (self.ticket, self.created)
\ No newline at end of file
+ return "%s - %s" % (self.ticket, self.created)
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from django.contrib.auth import login as auth_login, logout as auth_logout
+from django.utils.translation import ugettext_lazy as _
from forms import LoginForm
from models import ServiceTicket, LoginTicket
try:
login_ticket = LoginTicket.objects.get(ticket=lt)
except:
- errors.append('Login ticket expired. Please try again.')
+ errors.append(_('Login ticket expired. Please try again.'))
else:
login_ticket.delete()
user = authenticate(username=username, password=password)
else:
return HttpResponseRedirect(success_redirect)
else:
- errors.append('This account is disabled.')
+ errors.append(_('This account is disabled.'))
else:
- errors.append('Incorrect username and/or password.')
+ errors.append(_('Incorrect username and/or password.'))
form = LoginForm(service)
return render_to_response(template_name, {'form': form, 'errors': errors}, context_instance=RequestContext(request))