mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
feat(python): control access to forgotten page using config variable
This commit is contained in:
@ -121,6 +121,9 @@ class ConfigurationManager:
|
||||
return int(timeout)
|
||||
return 120 * 1000
|
||||
|
||||
def enable_forgotten(self) -> bool:
|
||||
return environ.get('ENABLE_FORGOTTEN', True)
|
||||
|
||||
def languages(self) -> dict[str, str]:
|
||||
return {
|
||||
'en': 'English',
|
||||
|
||||
@ -20,13 +20,16 @@ from django.shortcuts import render
|
||||
|
||||
from src.configuration import ConfigurationManager
|
||||
from src.utils import trackManager, fileUtils
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse, HttpResponseForbidden
|
||||
import json
|
||||
|
||||
config_manager = ConfigurationManager()
|
||||
|
||||
|
||||
def default(request): # default parameters that will be passed to the template
|
||||
if not config_manager.enable_forgotten():
|
||||
return HttpResponseForbidden()
|
||||
|
||||
context = {
|
||||
'files': getForgottenFiles(), # information about stored files
|
||||
'serverVersion': config_manager.getVersion()
|
||||
@ -53,6 +56,9 @@ def getForgottenFiles():
|
||||
|
||||
# delete a forgotten file from the document server
|
||||
def delete(request):
|
||||
if not config_manager.enable_forgotten():
|
||||
return HttpResponseForbidden()
|
||||
|
||||
response = {}
|
||||
status = 204
|
||||
|
||||
|
||||
@ -39,7 +39,8 @@ def default(request): # default parameters that will be passed to the template
|
||||
'preloadurl': config_manager.document_server_preloader_url().geturl(),
|
||||
'files': docManager.getStoredFiles(request), # information about stored files
|
||||
'directUrl': str(getDirectUrlParam(request)).lower,
|
||||
'serverVersion': config_manager.getVersion()
|
||||
'serverVersion': config_manager.getVersion(),
|
||||
'enableForgotten': config_manager.enable_forgotten(),
|
||||
}
|
||||
# execute the "index.html" template with context data and return http response in json format
|
||||
return render(request, 'index.html', context)
|
||||
|
||||
@ -120,9 +120,11 @@
|
||||
<img src="{% static "images/home.svg" %}" alt="Home"/>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="forgotten">Forgotten files</a>
|
||||
</li>
|
||||
{% if enableForgotten %}
|
||||
<li>
|
||||
<a href="forgotten">Forgotten files</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</menu>
|
||||
{% if files %}
|
||||
<div id="portal-info" style="display: none">
|
||||
|
||||
Reference in New Issue
Block a user