1616 You should have received a copy of the GNU General Public License
1717 along with this program. If not, see <https://www.gnu.org/licenses/>.
1818"""
19+ import datetime
20+
1921import flask_jwt_extended as fjwt
2022import PyMatcha .models .user as user
2123from flask import Blueprint
3032
3133profile_bp = Blueprint ("profile" , __name__ )
3234
33- REQUIRED_PARAMS_COMPLETE_PROFILE = {"orientation" : str , "bio" : str , "tags" : list }
35+ REQUIRED_PARAMS_COMPLETE_PROFILE = {"gender" : str , "birthdate" : str , " orientation" : str , "bio" : str , "tags" : list }
3436
3537
3638@profile_bp .route ("/profile/complete" , methods = ["POST" ])
@@ -46,15 +48,22 @@ def complete_profile():
4648 orientation = data ["orientation" ]
4749 bio = data ["bio" ]
4850 tags = data ["tags" ]
51+ gender = data ["gender" ]
52+ birthday = data ["birthdate" ]
4953
5054 if orientation not in ["heterosexual" , "homosexual" , "bisexual" , "other" ]:
51- raise BadRequestError ("Genre must be heterosexual, homosexual, bisexual or other" , "Try again" )
55+ raise BadRequestError ("Orientation must be heterosexual, homosexual, bisexual or other" , "Try again" )
56+
57+ if gender not in ["male" , "female" , "other" ]:
58+ raise BadRequestError ("Gender must be male, female or other" , "Try again" )
5259
5360 for tag in tags :
5461 Tag .create (name = tag , user_id = current_user .id )
5562
5663 current_user .orientation = orientation
5764 current_user .bio = bio
5865 current_user .is_profile_completed = True
66+ current_user .gender = gender
67+ current_user .birthday = datetime .date .fromtimestamp (birthday )
5968 current_user .save ()
6069 return Success ("Profile completed !" )
0 commit comments