mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Change how the user avatar is exchanged between client und server
This commit is contained in:
parent
7ea7b6d7a7
commit
f8e94a721f
@ -838,6 +838,7 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
json_serializeable = {
|
json_serializeable = {
|
||||||
'id': self.hashid,
|
'id': self.hashid,
|
||||||
'confirmed': self.confirmed,
|
'confirmed': self.confirmed,
|
||||||
|
'avatar': url_for('users.profile_avatar', user_id=self.id),
|
||||||
'email': self.email,
|
'email': self.email,
|
||||||
'last_seen': (
|
'last_seen': (
|
||||||
None if self.last_seen is None
|
None if self.last_seen is None
|
||||||
@ -857,10 +858,6 @@ class User(HashidMixin, UserMixin, db.Model):
|
|||||||
'show_last_seen': self.has_profile_privacy_setting(ProfilePrivacySettings.SHOW_LAST_SEEN),
|
'show_last_seen': self.has_profile_privacy_setting(ProfilePrivacySettings.SHOW_LAST_SEEN),
|
||||||
'show_member_since': self.has_profile_privacy_setting(ProfilePrivacySettings.SHOW_MEMBER_SINCE)
|
'show_member_since': self.has_profile_privacy_setting(ProfilePrivacySettings.SHOW_MEMBER_SINCE)
|
||||||
}
|
}
|
||||||
json_serializeable['avatar'] = (
|
|
||||||
None if self.avatar is None
|
|
||||||
else self.avatar.to_json_serializeable(relationships=True)
|
|
||||||
)
|
|
||||||
if backrefs:
|
if backrefs:
|
||||||
json_serializeable['role'] = \
|
json_serializeable['role'] = \
|
||||||
self.role.to_json_serializeable(backrefs=True)
|
self.role.to_json_serializeable(backrefs=True)
|
||||||
|
@ -72,7 +72,7 @@ class UserList extends ResourceList {
|
|||||||
return {
|
return {
|
||||||
'id': user.id,
|
'id': user.id,
|
||||||
'member-since': user.member_since,
|
'member-since': user.member_since,
|
||||||
'avatar': user.avatar ? `/users/${user.id}/avatar` : '/static/images/user_avatar.png',
|
'avatar': user.avatar,
|
||||||
'username': user.username,
|
'username': user.username,
|
||||||
'full-name': user.full_name ? user.full_name : '',
|
'full-name': user.full_name ? user.full_name : '',
|
||||||
'location': user.location ? user.location : '',
|
'location': user.location ? user.location : '',
|
||||||
|
@ -64,10 +64,10 @@ def user(user_id):
|
|||||||
@login_required
|
@login_required
|
||||||
def profile_avatar(user_id):
|
def profile_avatar(user_id):
|
||||||
user = User.query.get_or_404(user_id)
|
user = User.query.get_or_404(user_id)
|
||||||
|
if not (user.is_public or user == current_user or current_user.is_administrator()):
|
||||||
|
abort(403)
|
||||||
if user.avatar is None:
|
if user.avatar is None:
|
||||||
return redirect(url_for('static', filename='images/user_avatar.png'))
|
return redirect(url_for('static', filename='images/user_avatar.png'))
|
||||||
if not user.is_public and not (user == current_user or current_user.is_administrator()):
|
|
||||||
abort(403)
|
|
||||||
return send_from_directory(
|
return send_from_directory(
|
||||||
os.path.dirname(user.avatar.path),
|
os.path.dirname(user.avatar.path),
|
||||||
os.path.basename(user.avatar.path),
|
os.path.basename(user.avatar.path),
|
||||||
|
Loading…
Reference in New Issue
Block a user