File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 11# coding=utf-8
22from __future__ import absolute_import
33from flask_wtf import Form
4+ from flask_login import current_user
45from wtforms import StringField , PasswordField
5- from wtforms .validators import ValidationError , Email , Required
6+ from wtforms .validators import ValidationError , Email , Required , URL
67
78from firefly .models .user import User
89
@@ -39,3 +40,17 @@ def validate_password(self, field):
3940 self .user = user
4041 else :
4142 raise ValidationError ('邮箱或密码错误' )
43+
44+
45+ class ProfileForm (Form ):
46+ location = StringField ('Location' )
47+ website = StringField ('URL' , [URL ()])
48+ github_id = StringField ('Github' )
49+
50+ def save (self ):
51+ user = current_user
52+ if user and not user .is_anonymous :
53+ user .location = self .location .data
54+ user .website = self .website .data
55+ user .github_id = self .github_id .data
56+ user .save ()
Original file line number Diff line number Diff line change 33
44from flask .views import MethodView
55from flask .blueprints import Blueprint
6+ from flask_login import login_required
67
78
89bp = Blueprint ('user' , __name__ , url_prefix = '/user' )
@@ -12,4 +13,14 @@ class UserView(MethodView):
1213 def get (self , id ):
1314 return ''
1415
16+
17+ class UserSettingsView (MethodView ):
18+ decorators = [login_required ]
19+
20+ def get (self ):
21+ return ''
22+
23+ def post (self ):
24+ return ''
25+
1526bp .add_url_rule ('/<id>/' , view_func = UserView .as_view ('detail' ))
You can’t perform that action at this time.
0 commit comments