mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Merge remote-tracking branch 'remotes/origin/develop' into feature/submit-form
# Conflicts: # web/documentserver-example/csharp-mvc/Helpers/Users.cs # web/documentserver-example/csharp/Users.cs # web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java # web/documentserver-example/java/src/main/java/helpers/Users.java # web/documentserver-example/php/src/helpers/ExampleUsers.php # web/documentserver-example/python/src/utils/users.py # web/documentserver-example/ruby/app/models/users.rb
This commit is contained in:
@ -68,6 +68,7 @@ def routers():
|
||||
path('convert', actions.convert),
|
||||
path('create', actions.createNew),
|
||||
path('csv', actions.csv),
|
||||
path('assets', actions.assets),
|
||||
path('download', actions.download),
|
||||
path('downloadhistory', actions.downloadhistory),
|
||||
path('edit', actions.edit),
|
||||
|
||||
@ -21,7 +21,7 @@ from typing import Optional
|
||||
|
||||
class User:
|
||||
def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite,
|
||||
deniedPermissions, descriptions, templates):
|
||||
deniedPermissions, descriptions, templates, avatar):
|
||||
self.id = uid
|
||||
self.name = name
|
||||
self.email = email
|
||||
@ -33,6 +33,7 @@ class User:
|
||||
self.descriptions = descriptions
|
||||
self.templates = templates
|
||||
self.userInfoGroups = userInfoGroups
|
||||
self.avatar = avatar
|
||||
|
||||
|
||||
descr_user_1 = [
|
||||
@ -43,6 +44,7 @@ descr_user_1 = [
|
||||
"The file favorite state is undefined",
|
||||
"Can create files from templates using data from the editor",
|
||||
"Can see the information about all users",
|
||||
"Has an avatar",
|
||||
"Can submit forms"
|
||||
]
|
||||
|
||||
@ -54,6 +56,7 @@ descr_user_2 = [
|
||||
"This file is marked as favorite",
|
||||
"Can create new files from the editor",
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group",
|
||||
"Has an avatar",
|
||||
"Can’t submit forms"
|
||||
]
|
||||
|
||||
@ -89,7 +92,7 @@ descr_user_0 = [
|
||||
USERS = [
|
||||
User('uid-1', 'John Smith', 'smith@example.com',
|
||||
'', None, {}, None,
|
||||
None, [], descr_user_1, True),
|
||||
None, [], descr_user_1, True, True),
|
||||
User('uid-2', 'Mark Pottato', 'pottato@example.com',
|
||||
'group-2', ['group-2', ''], {
|
||||
'view': "",
|
||||
@ -97,17 +100,17 @@ USERS = [
|
||||
'remove': ["group-2"]
|
||||
},
|
||||
['group-2', ''],
|
||||
True, [], descr_user_2, False),
|
||||
True, [], descr_user_2, False, True),
|
||||
User('uid-3', 'Hamish Mitchell', None,
|
||||
'group-3', ['group-2'], {
|
||||
'view': ["group-3", "group-2"],
|
||||
'edit': ["group-2"],
|
||||
'remove': []
|
||||
}, ['group-2'],
|
||||
False, ["copy", "download", "print"], descr_user_3, False),
|
||||
False, ["copy", "download", "print"], descr_user_3, False, False),
|
||||
User('uid-0', None, None,
|
||||
'', None, {}, [],
|
||||
None, ["protect"], descr_user_0, False)
|
||||
None, ["protect"], descr_user_0, False, False)
|
||||
]
|
||||
|
||||
DEFAULT_USER = USERS[0]
|
||||
|
||||
@ -29,6 +29,7 @@ from src.common import http
|
||||
from src.configuration import ConfigurationManager
|
||||
from src.response import ErrorResponse
|
||||
from src.utils import docManager, fileUtils, serviceConverter, users, jwtManager, historyManager, trackManager
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
config_manager = ConfigurationManager()
|
||||
|
||||
@ -232,6 +233,16 @@ def edit(request):
|
||||
}
|
||||
]
|
||||
|
||||
usersInfo = []
|
||||
if user.id != 'uid-0':
|
||||
for userInfo in users.getAllUsers():
|
||||
u = userInfo
|
||||
u.image = docManager.getServerUrl(True, request) + f'/static/images/{u.id}.jpg' if user.avatar else None
|
||||
usersInfo.append({"id": u.id, "name": u.name, "email": u.email, "image": u.image, "group": u.group,
|
||||
"reviewGroups": u.reviewGroups, "commentGroups": u.commentGroups, "favorite": u.favorite,
|
||||
"deniedPermissions": u.deniedPermissions, "descriptions": u.descriptions,
|
||||
"templates": u.templates, "userInfoGroups": u.userInfoGroups, "avatar": u.avatar})
|
||||
|
||||
if meta: # if the document meta data exists,
|
||||
infObj = { # write author and creation time parameters to the information object
|
||||
'owner': meta['uname'],
|
||||
@ -294,7 +305,9 @@ def edit(request):
|
||||
'user': { # the user currently viewing or editing the document
|
||||
'id': user.id if user.id != 'uid-0' else None,
|
||||
'name': user.name,
|
||||
'group': user.group
|
||||
'group': user.group,
|
||||
'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar
|
||||
else None
|
||||
},
|
||||
'embedded': { # the parameters for the embedded document type
|
||||
# the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
@ -376,7 +389,8 @@ def edit(request):
|
||||
'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,
|
||||
'usersForProtect': json.dumps(usersForProtect) if user.id != 'uid-0' else None
|
||||
'usersInfo': json.dumps(usersInfo),
|
||||
'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
|
||||
|
||||
@ -444,6 +458,14 @@ def csv():
|
||||
return response
|
||||
|
||||
|
||||
# download a sample file
|
||||
def assets(request):
|
||||
filename = fileUtils.getFileName(request.GET['filename'])
|
||||
filePath = os.path.join('assets', 'document-templates', 'sample', filename)
|
||||
response = docManager.download(filePath)
|
||||
return response
|
||||
|
||||
|
||||
# download a file
|
||||
def download(request):
|
||||
try:
|
||||
@ -527,19 +549,35 @@ def reference(request):
|
||||
if userAddress == request.META['REMOTE_ADDR']:
|
||||
fileName = fileKey['fileName']
|
||||
|
||||
link = body['link']
|
||||
if not fileName and link:
|
||||
if docManager.getServerUrl(False, request) not in link:
|
||||
data = {
|
||||
'url': link,
|
||||
'directUrl': link
|
||||
}
|
||||
return HttpResponse(json.dumps(data), content_type='application/json')
|
||||
|
||||
url_obj = urlparse(link)
|
||||
query = parse_qs(url_obj.query)
|
||||
if 'filename' in query:
|
||||
fileName = query['filename'][0]
|
||||
if not os.path.exists(docManager.getStoragePath(fileName, request)):
|
||||
response.setdefault('error', 'File does not exist')
|
||||
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
|
||||
|
||||
if fileName is None:
|
||||
try:
|
||||
path = fileUtils.getFileName(body['path'])
|
||||
if os.path.exists(docManager.getStoragePath(path, request)):
|
||||
fileName = path
|
||||
else:
|
||||
response.setdefault('error', 'File not found')
|
||||
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
|
||||
except KeyError:
|
||||
response.setdefault('error', 'Path not found')
|
||||
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
|
||||
|
||||
if fileName is None:
|
||||
response.setdefault('error', 'File not found')
|
||||
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
|
||||
|
||||
data = {
|
||||
'fileType': fileUtils.getFileExt(fileName).replace('.', ''),
|
||||
'key': docManager.generateFileKey(fileName, request),
|
||||
|
||||
BIN
web/documentserver-example/python/static/images/uid-1.jpg
Normal file
BIN
web/documentserver-example/python/static/images/uid-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
BIN
web/documentserver-example/python/static/images/uid-2.jpg
Normal file
BIN
web/documentserver-example/python/static/images/uid-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@ -275,6 +275,18 @@
|
||||
var c = event.data.c;
|
||||
}
|
||||
switch (c) {
|
||||
case "info":
|
||||
users = [];
|
||||
var allUsers = {{ usersInfo | safe }};
|
||||
for (var i = 0; i < event.data.id.length; i++) {
|
||||
for (var j = 0; j < allUsers.length; j++) {
|
||||
if (allUsers[j].id == event.data.id[i]) {
|
||||
users.push(allUsers[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "protect":
|
||||
var users = {{ usersForProtect | safe }};
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user