File tree 4 files changed +29
-6
lines changed 4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 60
60
61
61
MAKO_FS_CHECK = True
62
62
63
+ EMAIL_SUFFIX = 'douban.com'
64
+
63
65
try :
64
66
from local_config import *
65
67
except ImportError :
Original file line number Diff line number Diff line change 6
6
from mikoto .libs .text import *
7
7
from mikoto .libs .emoji import *
8
8
9
+ from vilya .config import EMAIL_SUFFIX
10
+
9
11
10
12
def trunc_utf8 (string , num , etc = "..." ):
11
13
"""truncate a utf-8 string, show as num chars.
@@ -47,7 +49,7 @@ def email_normalizer(name, email):
47
49
if _validate_email (email ):
48
50
return email
49
51
else :
50
- return name + '@douban.com'
52
+ return name + '@' + EMAIL_SUFFIX
51
53
52
54
53
55
def is_image (fname ):
Original file line number Diff line number Diff line change 1
1
< %inherit file="/layouts/base.html" />
2
2
3
3
< %def name="title()"> New user</ %def>
4
+ < %def name="make_value(attr)">
5
+ % if attr:
6
+ value=${attr}
7
+ % endif
8
+ </ %def>
4
9
5
10
< div class ="hero-unit ">
6
11
< div class ="panel panel-default ">
@@ -12,25 +17,29 @@ <h3 class="panel-title">New user</h3>
12
17
< div class ="form-group ">
13
18
< label for ="inputName " class ="col-sm-2 control-label "> Name</ label >
14
19
< div class ="col-sm-10 ">
15
- < input type ="text " name ="name " class ="form-control " id ="inputName " placeholder ="Name ">
20
+ < input type ="text " name ="name " class ="form-control " id ="inputName " placeholder ="Name " ${make_value(name)} >
16
21
</ div >
17
22
</ div >
18
23
< div class ="form-group ">
19
24
< label for ="inputPassword " class ="col-sm-2 control-label "> Password</ label >
20
25
< div class ="col-sm-10 ">
21
- < input type ="password " name ="password " class ="form-control " id ="inputPassword " placeholder ="">
26
+ < input type ="password " name ="password " class ="form-control " id ="inputPassword " placeholder ="" ${make_value(password)} >
22
27
</ div >
23
28
</ div >
29
+ % if not not_validate_email:
24
30
< div class ="form-group ">
31
+ % else:
32
+ < div class ="form-group has-error ">
33
+ % endif
25
34
< label for ="inputEmail " class ="col-sm-2 control-label "> Email</ label >
26
35
< div class ="col-sm-10 ">
27
- < input type ="text " name ="email " class ="form-control " id ="inputEmail " placeholder ="">
36
+ < input type ="text " name ="email " class ="form-control " id ="inputEmail " placeholder ="" ${make_value(email)} >
28
37
</ div >
29
38
</ div >
30
39
< div class ="form-group ">
31
40
< label for ="inputDescription " class ="col-sm-2 control-label "> Description</ label >
32
41
< div class ="col-sm-10 ">
33
- < input type ="text " name ="description " class ="form-control " id ="inputDescription " placeholder ="Description ">
42
+ < input type ="text " name ="description " class ="form-control " id ="inputDescription " placeholder ="Description " ${make_value(description)} >
34
43
</ div >
35
44
</ div >
36
45
< div class ="form-group ">
@@ -43,4 +52,3 @@ <h3 class="panel-title">New user</h3>
43
52
</ div >
44
53
</ div >
45
54
</ div >
46
-
Original file line number Diff line number Diff line change 6
6
from vilya .models .project import Project
7
7
from vilya .models .user import User
8
8
from vilya .views .projects import ProjectUI
9
+ from vilya .libs .text import _validate_email
9
10
10
11
_q_exports = ['new' ]
11
12
@@ -21,6 +22,16 @@ def _q_index(request):
21
22
password = request .get_form_var ('password' )
22
23
email = request .get_form_var ('email' )
23
24
description = request .get_form_var ('description' )
25
+
26
+ # Forced mail format must be correct
27
+ if not _validate_email (email ):
28
+ context ['name' ] = name
29
+ context ['not_validate_email' ] = True
30
+ context ['password' ] = password
31
+ context ['email' ] = email
32
+ context ['description' ] = description
33
+ return st ('users/new.html' , ** context )
34
+
24
35
user = User .add (name = name ,
25
36
password = password ,
26
37
description = description ,
You can’t perform that action at this time.
0 commit comments