Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onlyoffice user avatar #6135

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion seahub/onlyoffice/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from seaserv import seafile_api

from seahub.base.templatetags.seahub_tags import email2nickname
from seahub.avatar.templatetags.avatar_tags import api_avatar_url
from seahub.utils import get_file_type_and_ext, gen_file_get_url, \
get_site_scheme_and_netloc

Expand Down Expand Up @@ -141,6 +142,7 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
onlyoffice_editor_callback_url = reverse('onlyoffice_editor_callback')
callback_url = urllib.parse.urljoin(base_url, onlyoffice_editor_callback_url)

avatar_url, _, _ = api_avatar_url(username, 72)
return_dict = {
'repo_id': repo_id,
'path': file_path,
Expand All @@ -154,6 +156,7 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
'can_edit': can_edit,
'can_download': can_download,
'username': username,
'avatar_url': avatar_url,
'onlyoffice_force_save': ONLYOFFICE_FORCE_SAVE,
'enable_watermark': ENABLE_WATERMARK,
'request_from_onlyoffice_desktop_editor': ONLYOFFICE_DESKTOP_EDITOR_HTTP_USER_AGENT in request.headers.get('user-agent', ''),
Expand Down Expand Up @@ -188,7 +191,8 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
if request.user.is_authenticated:
user_dict = {
"id": username,
"name": email2nickname(username)
"name": email2nickname(username),
"avatar_url": avatar_url,
}
config['editorConfig']['user'] = user_dict
else:
Expand Down
5 changes: 3 additions & 2 deletions seahub/templates/view_file_onlyoffice.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load seahub_tags i18n static %}
{% load seahub_tags avatar_tags i18n static %}

<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -112,7 +112,8 @@
{% if request.user.is_authenticated %}
"user": {
"id": "{{ username|escapejs }}",
"name": "{{ username|email2nickname|escapejs }}"
"name": "{{ username|email2nickname|escapejs }}",
"image": "{{ avatar_url }}",
}
{% endif %}
}
Expand Down
Loading