|
@@ -511,22 +511,23 @@ def get_banner_message(request):
|
|
|
banner_message = None
|
|
banner_message = None
|
|
|
forwarded_host = request.get_host()
|
|
forwarded_host = request.get_host()
|
|
|
|
|
|
|
|
- message = None
|
|
|
|
|
- path_info = request.environ.get("PATH_INFO")
|
|
|
|
|
- if path_info.find("/hue") < 0 and path_info.find("accounts/login") < 0:
|
|
|
|
|
- url = request.build_absolute_uri("/hue")
|
|
|
|
|
- link = '<a href="%s" style="color: #FFF; font-weight: bold">%s</a>' % (url, url)
|
|
|
|
|
- message = _('You are accessing an older version of Hue, please switch to the latest version: %s.') % link
|
|
|
|
|
- LOG.warn('User %s is using Hue 3 UI' % request.user.username)
|
|
|
|
|
-
|
|
|
|
|
- if HUE_LOAD_BALANCER.get() and HUE_LOAD_BALANCER.get() != [''] and \
|
|
|
|
|
- (not forwarded_host or not any(forwarded_host in lb for lb in HUE_LOAD_BALANCER.get())):
|
|
|
|
|
- message = _('You are accessing a non-optimized Hue, please switch to one of the available addresses: %s') % \
|
|
|
|
|
- (", ".join(['<a href="%s" style="color: #FFF; font-weight: bold">%s</a>' % (host, host) for host in HUE_LOAD_BALANCER.get()]))
|
|
|
|
|
- LOG.warn('User %s is bypassing the load balancer' % request.user.username)
|
|
|
|
|
-
|
|
|
|
|
- if message:
|
|
|
|
|
- banner_message = '<div style="padding: 4px; text-align: center; background-color: #003F6C; height: 24px; color: #DBE8F1">%s</div>' % message
|
|
|
|
|
|
|
+ if hasattr(request, 'environ'):
|
|
|
|
|
+ message = None
|
|
|
|
|
+ path_info = request.environ.get("PATH_INFO")
|
|
|
|
|
+ if path_info.find("/hue") < 0 and path_info.find("accounts/login") < 0:
|
|
|
|
|
+ url = request.build_absolute_uri("/hue")
|
|
|
|
|
+ link = '<a href="%s" style="color: #FFF; font-weight: bold">%s</a>' % (url, url)
|
|
|
|
|
+ message = _('You are accessing an older version of Hue, please switch to the latest version: %s.') % link
|
|
|
|
|
+ LOG.warn('User %s is using Hue 3 UI' % request.user.username)
|
|
|
|
|
+
|
|
|
|
|
+ if HUE_LOAD_BALANCER.get() and HUE_LOAD_BALANCER.get() != [''] and \
|
|
|
|
|
+ (not forwarded_host or not any(forwarded_host in lb for lb in HUE_LOAD_BALANCER.get())):
|
|
|
|
|
+ message = _('You are accessing a non-optimized Hue, please switch to one of the available addresses: %s') % \
|
|
|
|
|
+ (", ".join(['<a href="%s" style="color: #FFF; font-weight: bold">%s</a>' % (host, host) for host in HUE_LOAD_BALANCER.get()]))
|
|
|
|
|
+ LOG.warn('User %s is bypassing the load balancer' % request.user.username)
|
|
|
|
|
+
|
|
|
|
|
+ if message:
|
|
|
|
|
+ banner_message = '<div style="padding: 4px; text-align: center; background-color: #003F6C; height: 24px; color: #DBE8F1">%s</div>' % message
|
|
|
|
|
|
|
|
return banner_message
|
|
return banner_message
|
|
|
|
|
|