-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
59 lines (43 loc) · 1.63 KB
/
Copy pathviews.py
File metadata and controls
59 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'''
Created on Oct 17, 2013
@author: Avi
'''
from django.shortcuts import render_to_response
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import auth
from django.contrib.auth import authenticate
from django.core.context_processors import csrf
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from forms import MyRegistrationForm
def loginView(request):
c = {}
c.update(csrf(request))
return render_to_response('login.html',c)
def authView(request):
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return HttpResponseRedirect('/accounts/logedin')
else:
return HttpResponse("Hey Wrong User Name")
def logedinView(request):
username = request.user.username
request.session['user_name']=username
return render_to_response('logedin.html',{'username':username})
def logoutView(request):
auth.logout(request)
def registerView(request):
if request.method == 'POST':
form = MyRegistrationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_sucess')
args = {}
args.update(csrf(request))
args['form'] = MyRegistrationForm()
return render_to_response('registration_form.html',args)
def registerSuccessView(request):
return render_to_response('register_success.html')