##// END OF EJS Templates
Removed the old and unneeded jumper view
Removed the old and unneeded jumper view

File last commit:

r544:5f217adc 1.7-dev
r554:11802a56 1.7-dev
Show More
login.py
30 lines | 919 B | text/x-python | PythonLexer
neko259
Moved login view to a separate class. Refactored thread and all threads views
r544 from django.shortcuts import render, redirect
from boards.forms import LoginForm, PlainErrorList
from boards.models import User
from boards.views.base import BaseBoardView, PARAMETER_FORM
__author__ = 'neko259'
class LoginView(BaseBoardView):
def get(self, request, form=None):
context = self.get_context_data(request=request)
if not form:
form = LoginForm()
context[PARAMETER_FORM] = form
return render(request, 'boards/login.html', context)
def post(self, request):
form = LoginForm(request.POST, request.FILES,
error_class=PlainErrorList)
form.session = request.session
if form.is_valid():
user = User.objects.get(user_id=form.cleaned_data['user_id'])
request.session['user_id'] = user.id
return redirect('index')
else:
return self.get(request, form)