2
2
from django .contrib .auth import authenticate , login , logout
3
3
from django .shortcuts import render , redirect
4
4
5
- from core .localization .messages import MSG_PASSWORDS_UNEQUAL , MSG_OFM_PASSWORDS_UNEQUAL , MSG_NOT_LOGGED_IN , \
6
- OFM_USERNAME_ALREADY_EXISTS , USERNAME_ALREADY_EXISTS , EMAIL_ALREADY_EXISTS , MSG_ALREADY_LOGGED_IN , \
7
- MSG_ACCOUNT_CREATED , LOGGED_OUT , USERNAME_OR_PASSWORD_INVALID , LOGIN_IMPOSSIBLE_ACCOUNT_IS_DEACTIVATED , \
5
+ from core .localization .messages import PASSWORDS_UNEQUAL , OFM_PASSWORDS_UNEQUAL , NOT_LOGGED_IN , \
6
+ OFM_USERNAME_ALREADY_EXISTS , USERNAME_ALREADY_EXISTS , EMAIL_ALREADY_EXISTS , ALREADY_LOGGED_IN , \
7
+ ACCOUNT_CREATED , LOGGED_OUT , USERNAME_OR_PASSWORD_INVALID , LOGIN_IMPOSSIBLE_ACCOUNT_IS_DEACTIVATED , \
8
8
LOGIN_SUCCESSFUL
9
9
from users .models import OFMUser
10
10
11
11
12
12
def register_view (request ):
13
13
if request .user .is_authenticated ():
14
- messages .error (request , MSG_ALREADY_LOGGED_IN )
14
+ messages .error (request , ALREADY_LOGGED_IN )
15
15
return render (request , 'core/account/home.html' )
16
16
if request .POST :
17
17
username = request .POST .get ('username' )
@@ -31,15 +31,15 @@ def register_view(request):
31
31
return redirect ('core:register' )
32
32
33
33
if password != password2 :
34
- messages .error (request , MSG_PASSWORDS_UNEQUAL )
34
+ messages .error (request , PASSWORDS_UNEQUAL )
35
35
return redirect ('core:register' )
36
36
37
37
if OFMUser .objects .filter (ofm_username = ofm_username ).exists ():
38
38
messages .error (request , OFM_USERNAME_ALREADY_EXISTS )
39
39
return redirect ('core:register' )
40
40
41
41
if ofm_password != ofm_password2 :
42
- messages .error (request , MSG_OFM_PASSWORDS_UNEQUAL )
42
+ messages .error (request , OFM_PASSWORDS_UNEQUAL )
43
43
return redirect ('core:register' )
44
44
45
45
OFMUser .objects .create_user (
@@ -50,7 +50,7 @@ def register_view(request):
50
50
ofm_password = ofm_password ,
51
51
)
52
52
53
- messages .success (request , MSG_ACCOUNT_CREATED )
53
+ messages .success (request , ACCOUNT_CREATED )
54
54
return redirect ('core:login' )
55
55
56
56
else :
@@ -91,5 +91,5 @@ def account_view(request):
91
91
if request .user .is_authenticated ():
92
92
return render (request , 'core/account/home.html' )
93
93
else :
94
- messages .error (request , MSG_NOT_LOGGED_IN )
94
+ messages .error (request , NOT_LOGGED_IN )
95
95
return redirect ('core:login' )
0 commit comments