mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
python: setUsers for region protection
This commit is contained in:
@ -90,7 +90,7 @@ USERS = [
|
||||
},
|
||||
['group-2', ''],
|
||||
True, [], descr_user_2, False),
|
||||
User('uid-3', 'Hamish Mitchell', 'mitchell@example.com',
|
||||
User('uid-3', 'Hamish Mitchell', None,
|
||||
'group-3', ['group-2'], {
|
||||
'view': ["group-3", "group-2"],
|
||||
'edit': ["group-2"],
|
||||
@ -126,6 +126,14 @@ def getUsersForMentions(uid):
|
||||
usersData.append({'name':user.name, 'email':user.email})
|
||||
return usersData
|
||||
|
||||
# get users data for protect
|
||||
def getUsersForProtect(uid):
|
||||
usersData = []
|
||||
for user in USERS:
|
||||
if(user.id != uid and user.name != None):
|
||||
usersData.append({'id': user.id, 'name': user.name, 'email': user.email})
|
||||
return usersData
|
||||
|
||||
def find_user(id: Optional[str]) -> User:
|
||||
if id is None:
|
||||
return DEFAULT_USER
|
||||
|
||||
@ -322,6 +322,8 @@ def edit(request):
|
||||
|
||||
# users data for mentions
|
||||
usersForMentions = users.getUsersForMentions(user.id)
|
||||
# users data for protect
|
||||
usersForProtect = users.getUsersForProtect(user.id)
|
||||
|
||||
if jwtManager.isEnabled(): # if the secret key to generate token exists
|
||||
edConfig['token'] = jwtManager.encode(edConfig) # encode the edConfig object into a token
|
||||
@ -340,7 +342,8 @@ def edit(request):
|
||||
'dataInsertImage': json.dumps(dataInsertImage)[1 : len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document
|
||||
'dataDocument': dataDocument, # document which will be compared with the current document
|
||||
'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging
|
||||
'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None
|
||||
'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None,
|
||||
'usersForProtect': json.dumps(usersForProtect) if user.id !='uid-0' else None
|
||||
}
|
||||
return render(request, 'editor.html', context) # execute the "editor.html" template with context data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user