python: add mentions

This commit is contained in:
metoou
2021-05-16 17:51:13 +03:00
parent b3dd5bc15d
commit 25ccda7e89
3 changed files with 27 additions and 1 deletions

View File

@ -54,3 +54,13 @@ def getUserFromReq(req):
return user return user
return DEFAULT_USER return DEFAULT_USER
# get users data for mentions
def getUsersForMentions(req):
uid = req.COOKIES.get('uid')
usersData = []
for user in USERS:
if(user.id != uid and user.name != None and user.email != None):
usersData.append({'name':user.name, 'email':user.email})
return usersData

View File

@ -238,7 +238,8 @@ def edit(request):
'apiUrl': config.DOC_SERV_SITE_URL + config.DOC_SERV_API_URL, # the absolute URL to the api 'apiUrl': config.DOC_SERV_SITE_URL + config.DOC_SERV_API_URL, # the absolute URL to the api
'dataInsertImage': json.dumps(dataInsertImage)[1 : len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document 'dataInsertImage': json.dumps(dataInsertImage)[1 : len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document
'dataCompareFile': dataCompareFile, # document which will be compared with the current document 'dataCompareFile': dataCompareFile, # document which will be compared with the current document
'dataMailMergeRecipients': json.dumps(dataMailMergeRecipients) # recipient data for mail merging 'dataMailMergeRecipients': json.dumps(dataMailMergeRecipients), # recipient data for mail merging
'users': json.dumps(users.getUsersForMentions(request))
} }
return render(request, 'editor.html', context) # execute the "editor.html" template with context data return render(request, 'editor.html', context) # execute the "editor.html" template with context data

View File

@ -134,6 +134,19 @@
); );
}; };
var onRequestUsers = function () {
docEditor.setUsers({
"users": {{ users | safe }}
});
};
var onRequestSendNotify = function (event) {
var actionLink = JSON.stringify(event.data.actionLink);
console.log("onRequestSendNotify:");
console.log(event.data);
console.log("Link to comment: " + replaceActionLink(location.href, actionLink));
};
var connectEditor = function () { var connectEditor = function () {
config = {{ cfg | safe }} config = {{ cfg | safe }}
@ -150,6 +163,8 @@
'onRequestInsertImage': onRequestInsertImage, 'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile, 'onRequestCompareFile': onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients, "onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestUsers": onRequestUsers,
"onRequestSendNotify": onRequestSendNotify,
}; };
{% if history and historyData %} {% if history and historyData %}