Fixing edit_profile endpoint
This commit is contained in:
parent
42552f12be
commit
3e1c3bfebe
1 changed files with 21 additions and 13 deletions
34
app/api.py
34
app/api.py
|
|
@ -2,7 +2,7 @@ from flask import Blueprint, jsonify, request
|
||||||
import sys, os, datetime, re
|
import sys, os, datetime, re
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from peewee import IntegrityError
|
from peewee import IntegrityError
|
||||||
from .models import User, Message, Upload, Relationship, database, \
|
from .models import User, UserProfile, Message, Upload, Relationship, database, \
|
||||||
MSGPRV_PUBLIC, MSGPRV_UNLISTED, MSGPRV_FRIENDS, MSGPRV_ONLYME, UPLOAD_DIRECTORY
|
MSGPRV_PUBLIC, MSGPRV_UNLISTED, MSGPRV_FRIENDS, MSGPRV_ONLYME, UPLOAD_DIRECTORY
|
||||||
from .utils import check_access_token, Visibility, push_notification, unpush_notification, \
|
from .utils import check_access_token, Visibility, push_notification, unpush_notification, \
|
||||||
create_mentions, is_username
|
create_mentions, is_username
|
||||||
|
|
@ -261,20 +261,28 @@ def edit_profile(user):
|
||||||
full_name = data['full_name'] or username
|
full_name = data['full_name'] or username
|
||||||
if full_name != user.full_name:
|
if full_name != user.full_name:
|
||||||
User.update(full_name=full_name).where(User.id == user.id).execute()
|
User.update(full_name=full_name).where(User.id == user.id).execute()
|
||||||
#website = data['website'].strip().replace(' ', '%20')
|
kwargs = {}
|
||||||
#if website and not validate_website(website):
|
if 'website' in data:
|
||||||
# raise ValueError('You should enter a valid URL.')
|
website = data['website'].strip().replace(' ', '%20')
|
||||||
#location = int(request.form.get('location'))
|
if website and not validate_website(website):
|
||||||
#if location == 0:
|
raise ValueError('You should enter a valid URL.')
|
||||||
# location = None
|
kwargs['website'] = website
|
||||||
|
if 'location' in data:
|
||||||
|
location = int(request.form.get('location'))
|
||||||
|
if location == 0:
|
||||||
|
location = None
|
||||||
|
kwargs['location'] = location
|
||||||
|
if 'year' in data:
|
||||||
|
if data.get('has_year'):
|
||||||
|
kwargs['year'] = data['year']
|
||||||
|
else:
|
||||||
|
kwargs['year'] = None
|
||||||
|
if 'instagram' in data: kwargs['instagram'] = data['instagram']
|
||||||
|
if 'facebook' in data: kwargs['facebook'] = data['facebook']
|
||||||
|
if 'telegram' in data: kwargs['telegram'] = data['telegram']
|
||||||
UserProfile.update(
|
UserProfile.update(
|
||||||
biography=data['biography'],
|
biography=data['biography'],
|
||||||
#year=data['year'] if data.get('has_year') else None,
|
**kwargs
|
||||||
#location=location,
|
|
||||||
website=website,
|
|
||||||
#instagram=data['instagram'],
|
|
||||||
#facebook=data['facebook'],
|
|
||||||
#telegram=data['telegram']
|
|
||||||
).where(UserProfile.user == user).execute()
|
).where(UserProfile.user == user).execute()
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue