Commit bbe40800 authored by ibuler's avatar ibuler

[Update] 删掉Premiddleware

parent b6523da6
......@@ -78,7 +78,6 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
'orgs.middleware.OrgPreMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
......@@ -234,10 +233,10 @@ LOGGING = {
'handlers': ['console', 'ansible_logs'],
'level': "INFO",
},
'django.db': {
'handlers': ['console', 'file'],
'level': 'DEBUG'
}
# 'django.db': {
# 'handlers': ['console', 'file'],
# 'level': 'DEBUG'
# }
}
}
......
......@@ -2,17 +2,6 @@
#
from .utils import get_org_from_request, set_current_org
from .models import Organization
class OrgPreMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
set_current_org(Organization.root())
response = self.get_response(request)
return response
class OrgMiddleware:
......
......@@ -23,7 +23,8 @@ class OrgManager(models.Manager):
current_org = get_current_org()
kwargs = {}
print(">>>>>>>>>> Get query set")
# print(">>>>>>>>>> Get query set")
# print(current_org)
if not current_org:
kwargs['id'] = None
elif current_org.is_real():
......@@ -36,14 +37,14 @@ class OrgManager(models.Manager):
# print(queryset.query)
return queryset
# def all(self):
# current_org = get_current_org()
# if not current_org:
# msg = 'You can `objects.set_current_org(org).all()` then run it'
# warnings.warn(msg)
# return self
# else:
# return super(OrgManager, self).all()
def all(self):
current_org = get_current_org()
if not current_org:
msg = 'You can `objects.set_current_org(org).all()` then run it'
warnings.warn(msg)
return self
else:
return super(OrgManager, self).all()
def set_current_org(self, org):
if isinstance(org, str):
......
......@@ -24,7 +24,8 @@ def get_current_request():
def get_current_org():
return getattr(_thread_locals, 'current_org', None)
org = getattr(_thread_locals, 'current_org', None)
return org
def get_current_user():
......
......@@ -106,12 +106,13 @@ class UserUpdatePKApi(generics.UpdateAPIView):
user.save()
class UserGroupViewSet(IDInFilterMixin, OrgViewGenericMixin, BulkModelViewSet):
class UserGroupViewSet(BulkModelViewSet):
queryset = UserGroup.objects.all()
serializer_class = UserGroupSerializer
permission_classes = (IsSuperUser,)
class UserGroupUpdateUserApi(generics.RetrieveUpdateAPIView):
queryset = UserGroup.objects.all()
serializer_class = UserGroupUpdateMemeberSerializer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment