forked from shaba/openuds
Merge remote-tracking branch 'origin/v2.2'
This commit is contained in:
commit
44feef783b
@ -51,7 +51,7 @@ import requests
|
||||
import json
|
||||
import logging
|
||||
|
||||
__updated__ = '2018-05-16'
|
||||
__updated__ = '2018-09-13'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
traceLogger = logging.getLogger('traceLog')
|
||||
@ -142,6 +142,12 @@ class UserServiceManager(object):
|
||||
"""
|
||||
Creates a new assigned deployed service for the publication and user indicated
|
||||
"""
|
||||
# First, honor maxPreparingServices
|
||||
if self.canInitiateServiceFromDeployedService(ds) is False:
|
||||
# Cannot create new
|
||||
logger.warn('Too many preparing services. Creation of assigned service denied by max preparing services parameter. (login storm with insufficient cache?).')
|
||||
raise ServiceNotReadyError()
|
||||
|
||||
if ds.service.getType().publicationType is not None:
|
||||
dsp = ds.activePublication()
|
||||
logger.debug('Creating a new assigned element for user {0} por publication {1}'.format(user, dsp))
|
||||
|
File diff suppressed because one or more lines are too long
@ -56,11 +56,15 @@ urlpatterns = [
|
||||
|
||||
# Index
|
||||
path(r'uds/page/services/', uds.web.views.modern.index, name='page.index'),
|
||||
|
||||
# Login/logout
|
||||
path(r'uds/page/login/', uds.web.views.modern.login, name='page.login'),
|
||||
re_path(r'^uds/page/login/(?P<tag>.+)$', uds.web.views.modern.login, name='page.login.tag'),
|
||||
|
||||
path(r'uds/page/logout/', uds.web.views.logout, name='page.logout'),
|
||||
|
||||
# Error URL
|
||||
re_path(r'^uds/page/error/(?P<error>.+)$', uds.web.views.error, name='page.error'),
|
||||
|
||||
# This must be the last, so any patition will be managed by client in fact
|
||||
re_path(r'uds/page/.*', uds.web.views.modern.index, name='page.plageholder'),
|
||||
|
||||
@ -96,7 +100,7 @@ urlpatterns = [
|
||||
# re_path(r'^srvimg/(?P<idImage>.+)$', uds.web.views.serviceImage, name='uds.web.views.serviceImage'),
|
||||
# re_path(r'^galimg/(?P<idImage>.+)$', uds.web.views.image, name='galleryImage'),
|
||||
# Error URL
|
||||
re_path(r'^error/(?P<idError>.+)$', uds.web.views.error, name='uds.web.views.error'),
|
||||
# re_path(r'^error/(?P<idError>.+)$', uds.web.views.error, name='uds.web.views.error'),
|
||||
|
||||
# Transport own link processor
|
||||
# re_path(r'^trans/(?P<idService>.+)/(?P<idTransport>.+)$', uds.web.views.transportOwnLink, name='TransportOwnLink'),
|
||||
|
@ -34,16 +34,12 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.shortcuts import render
|
||||
from django.template import RequestContext
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from .transformers import scrambleId, transformId
|
||||
|
||||
from uds.core.util import encoders
|
||||
from uds.models import DeployedService, Transport, UserService, Authenticator
|
||||
from uds.core.auths.Exceptions import InvalidUserException, InvalidAuthenticatorException
|
||||
from uds.core.services.Exceptions import InvalidServiceException, MaxServicesReachedError, ServiceInMaintenanceMode, ServiceNotReadyError
|
||||
from uds.core.ui import theme
|
||||
|
||||
import traceback
|
||||
import logging
|
||||
@ -67,7 +63,6 @@ SERVICE_NOT_READY = 13
|
||||
SERVICE_IN_PREPARATION = 14
|
||||
SERVICE_CALENDAR_DENIED = 15
|
||||
|
||||
|
||||
strings = [
|
||||
_('Unknown error'),
|
||||
_('Transport not found'),
|
||||
@ -95,14 +90,26 @@ def errorString(errorId):
|
||||
return strings[0]
|
||||
|
||||
|
||||
def errorView(request, idError):
|
||||
return HttpResponseRedirect(reverse('uds.web.views.error', kwargs={'idError': scrambleId(request, idError)}))
|
||||
def errorView(request, error):
|
||||
idError = int(error)
|
||||
code = (error >> 8) & 0xFF
|
||||
|
||||
errStr = errorString(idError)
|
||||
if code != 0:
|
||||
errStr += ' (code {0:04X})'.format(code)
|
||||
|
||||
errStr = encoders.encode(str(errStr), 'base64', asText=True)[:-3]
|
||||
|
||||
return HttpResponseRedirect(reverse('page.error', kwargs={'error': errStr}))
|
||||
|
||||
|
||||
def exceptionView(request, exception):
|
||||
"""
|
||||
Tries to render an error page with error information
|
||||
"""
|
||||
from uds.core.auths.Exceptions import InvalidUserException, InvalidAuthenticatorException
|
||||
from uds.core.services.Exceptions import InvalidServiceException, MaxServicesReachedError, ServiceInMaintenanceMode, ServiceNotReadyError
|
||||
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
try:
|
||||
@ -133,19 +140,20 @@ def exceptionView(request, exception):
|
||||
raise e
|
||||
|
||||
|
||||
@transformId
|
||||
def error(request, idError):
|
||||
def error(request, error):
|
||||
"""
|
||||
Error view, responsible of error display
|
||||
:param request:
|
||||
:param idError:
|
||||
"""
|
||||
idError = int(idError)
|
||||
code = idError >> 8
|
||||
idError &= 0xFF
|
||||
return render(request, 'uds/modern/index.html', {})
|
||||
|
||||
errStr = errorString(idError)
|
||||
if code != 0:
|
||||
errStr += ' (code {0:04X})'.format(code)
|
||||
# idError = int(idError)
|
||||
# code = idError >> 8
|
||||
# idError &= 0xFF
|
||||
|
||||
return render(request, theme.template('error.html'), {'errorString': errStr})
|
||||
# errStr = errorString(idError)
|
||||
# if code != 0:
|
||||
# errStr += ' (code {0:04X})'.format(code)
|
||||
|
||||
# return render(request, theme.template('error.html'), {'errorString': errStr})
|
||||
|
@ -44,6 +44,9 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def index(request):
|
||||
from uds.web.errors import errorView
|
||||
return errorView(request, 1)
|
||||
|
||||
response = render(request, 'uds/modern/index.html', {})
|
||||
|
||||
logger.debug('Session expires at %s', request.session.get_expiry_date())
|
||||
|
Loading…
Reference in New Issue
Block a user