14
14
15
15
16
16
def index (request ):
17
- link_dict = {"Login" : 'login_screen' , "Register" : 'register' ,
18
- "Log out" : 'logout_user' , "Car Management" : 'cars' ,
19
- "User Management" : 'user' }
20
- return render (request , 'web/index.html' , {"links" : link_dict })
17
+ return render (request , 'web/index.html' )
21
18
22
19
def logout_user (request ):
23
20
logout (request )
24
- return HttpResponseRedirect ('../../' )
21
+ return HttpResponseRedirect ('../../' ) ## TODO: OPRAVIT, vyvaruj se absolutnim adresam
25
22
26
23
27
24
class LoginScreen (View ):
@@ -46,13 +43,14 @@ def post(self, request):
46
43
47
44
if self .user :
48
45
login (request , self .user )
46
+ return HttpResponseRedirect ('../../' )
49
47
else :
50
48
return HttpResponse ("INVALID CREDENTIALS!" )
51
- return HttpResponseRedirect ('../../' )
52
49
53
50
def _check_credentials (self ):
54
51
if self .user_name and self .user_pass :
55
- self .user = authenticate (username = self .user_name , password = self .user_pass )
52
+ self .user = authenticate (email = self .user_name ,
53
+ password = self .user_pass )
56
54
else :
57
55
return HttpResponse ("MISSING CREDENTIALS!" )
58
56
@@ -125,15 +123,17 @@ def _check_details(self):
125
123
126
124
127
125
def _check_existing_user (self ):
128
- test_auth = authenticate (username = self .user_mail , password = self .user_pass )
126
+ test_auth = authenticate (username = self .user_mail ,
127
+ password = self .user_pass ,
128
+ email = self .user_mail )
129
129
if test_auth :
130
130
self .user_exists = True
131
131
else :
132
132
self .user_exists = False
133
133
134
134
135
135
136
- class CarManagement (View ):
136
+ class Car (View ):
137
137
header = "Car Management page"
138
138
139
139
model = None
@@ -167,7 +167,6 @@ def get(self, request):
167
167
168
168
def post (self , request ):
169
169
self .inp_method = request .POST .get ('method' )
170
- print (request .POST )
171
170
if self .inp_method == 'add_vehicle' :
172
171
return self ._add_car (request )
173
172
elif self .inp_method == 'remove_vehicle' :
@@ -210,7 +209,7 @@ def _check_required(self):
210
209
return HttpResponse ("FAILED TO SAVE, MISSING DATA!" )
211
210
212
211
213
- class UserManagement (View ):
212
+ class User (View ):
214
213
header = "User control panel and information page"
215
214
form = forms .ManageForm
216
215
0 commit comments