* [Update] 优化切换组织时重定向页面逻辑 (#3133)

* [Update] 优化切换组织时重定向页面逻辑

* [Update] 优化切换组织时重定向页面逻辑 2

* [Update] WebTerminal 跳转添加时间戳

* [Update] 修复创建授权规则授权节点时,系统用户不自动推送的问题
pull/3261/head^2 1.5.2
BaiJiangJie 5 years ago committed by GitHub
parent 7d4e9c5669
commit 05818671a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,16 +57,16 @@ def on_system_user_update(sender, instance=None, created=True, **kwargs):
push_system_user_to_assets.delay(instance, assets)
# @receiver(m2m_changed, sender=SystemUser.nodes.through)
# def on_system_user_nodes_change(sender, instance=None, **kwargs):
# if instance and kwargs["action"] == "post_add":
# logger.info("System user `{}` nodes update signal received".format(instance))
# assets = set()
# nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
# for node in nodes:
# assets.update(set(node.get_all_assets()))
# instance.assets.add(*tuple(assets))
#
@receiver(m2m_changed, sender=SystemUser.nodes.through)
def on_system_user_nodes_change(sender, instance=None, **kwargs):
if instance and kwargs["action"] == "post_add":
logger.info("System user `{}` nodes update signal received".format(instance))
assets = set()
nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
for node in nodes:
assets.update(set(node.get_all_assets()))
instance.assets.add(*tuple(assets))
@receiver(m2m_changed, sender=SystemUser.assets.through)
def on_system_user_assets_change(sender, instance=None, **kwargs):

@ -12,7 +12,7 @@ import copy
import ipaddress
UUID_PATTERN = re.compile(r'[0-9a-zA-Z\-]{36}')
UUID_PATTERN = re.compile(r'\w{8}(-\w{4}){3}-\w{12}')
ipip_db = None

@ -4,6 +4,7 @@ from django.http import HttpResponseForbidden
from django.views.generic import DetailView, View
from .models import Organization
from common.utils import UUID_PATTERN
class SwitchOrgView(DetailView):
@ -17,10 +18,11 @@ class SwitchOrgView(DetailView):
request.session['oid'] = oid
host = request.get_host()
referer = request.META.get('HTTP_REFERER')
if referer.find(host) != -1:
return redirect(referer)
else:
return redirect('index')
if referer.find(host) == -1:
return redirect(reverse('index'))
if UUID_PATTERN.search(referer):
return redirect(reverse('index'))
return redirect(referer)
class SwitchToAOrgView(View):

@ -1,5 +1,6 @@
# ~*~ coding: utf-8 ~*~
#
import time
from django.views.generic import ListView, UpdateView, DeleteView, \
DetailView, View
from django.utils.translation import ugettext as _
@ -128,7 +129,8 @@ class TerminalConnectView(PermissionsMixin, DetailView):
class WebTerminalView(View):
def get(self, request, *args, **kwargs):
return redirect('/luna/?' + request.GET.urlencode())
redirect_url = '/luna/?_={}&'.format(int(time.time()))
return redirect(redirect_url + request.GET.urlencode())
class WebSFTPView(View):

Loading…
Cancel
Save