X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/blobdiff_plain/c4e951ccbda6275dd5134a431af7e0ee8f129feb..34cdae232d0d9a1b26133b7dd39ab484243d6493:/cas_provider/views.py?ds=inline diff --git a/cas_provider/views.py b/cas_provider/views.py index 27c7f7a..5343232 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -1,9 +1,9 @@ -from django.http import HttpResponse, HttpResponseForbidden, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext -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 @@ -32,7 +32,7 @@ def login(request, template_name='cas/login.html', success_redirect='/accounts/' 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) @@ -45,9 +45,9 @@ def login(request, template_name='cas/login.html', success_redirect='/accounts/' 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)) @@ -59,12 +59,12 @@ def validate(request): ticket = ServiceTicket.objects.get(ticket=ticket_string) username = ticket.user.username ticket.delete() - return HttpResponse("yes\n\r%s\n\r" % username) + return HttpResponse("yes\r\n%s\r\n" % username) except: pass - return HttpResponse("no\n\r\n\r") + return HttpResponse("no\r\n\r\n") def logout(request, template_name='cas/logout.html'): url = request.GET.get('url', None) auth_logout(request) - return render_to_response(template_name, {'url': url}, context_instance=RequestContext(request)) \ No newline at end of file + return render_to_response(template_name, {'url': url}, context_instance=RequestContext(request))