Commit 0a931bbf authored by ibuler's avatar ibuler

[Feature] es support

parent 17181db8
...@@ -63,8 +63,6 @@ class LDAPTestingAPI(APIView): ...@@ -63,8 +63,6 @@ class LDAPTestingAPI(APIView):
search_filter = serializer.validated_data["AUTH_LDAP_SEARCH_FILTER"] search_filter = serializer.validated_data["AUTH_LDAP_SEARCH_FILTER"]
attr_map = serializer.validated_data["AUTH_LDAP_USER_ATTR_MAP"] attr_map = serializer.validated_data["AUTH_LDAP_USER_ATTR_MAP"]
print(serializer.validated_data)
try: try:
attr_map = json.loads(attr_map) attr_map = json.loads(attr_map)
except json.JSONDecodeError: except json.JSONDecodeError:
...@@ -77,9 +75,6 @@ class LDAPTestingAPI(APIView): ...@@ -77,9 +75,6 @@ class LDAPTestingAPI(APIView):
except Exception as e: except Exception as e:
return Response({"error": str(e)}, status=401) return Response({"error": str(e)}, status=401)
print(search_ou)
print(search_filter % ({"user": "*"}))
print(attr_map.values())
ok = conn.search(search_ou, search_filter % ({"user": "*"}), ok = conn.search(search_ou, search_filter % ({"user": "*"}),
attributes=list(attr_map.values())) attributes=list(attr_map.values()))
if not ok: if not ok:
......
...@@ -18,7 +18,6 @@ class DictField(forms.Field): ...@@ -18,7 +18,6 @@ class DictField(forms.Field):
# we don't need to handle that explicitly. # we don't need to handle that explicitly.
if isinstance(value, six.string_types): if isinstance(value, six.string_types):
try: try:
print(value)
value = json.loads(value) value = json.loads(value)
return value return value
except json.JSONDecodeError: except json.JSONDecodeError:
......
...@@ -36,9 +36,9 @@ class BaseForm(forms.Form): ...@@ -36,9 +36,9 @@ class BaseForm(forms.Form):
for name, field in self.fields.items(): for name, field in self.fields.items():
db_value = getattr(db_settings, name).value db_value = getattr(db_settings, name).value
django_value = getattr(settings, name) if hasattr(settings, name) else None django_value = getattr(settings, name) if hasattr(settings, name) else None
if db_value is not None: if db_value is False or db_value:
field.initial = to_form_value(db_value) field.initial = to_form_value(db_value)
elif django_value is not None: elif django_value is False or django_value:
field.initial = django_value field.initial = django_value
def save(self, category="default"): def save(self, category="default"):
......
...@@ -2,6 +2,7 @@ import json ...@@ -2,6 +2,7 @@ import json
import ldap import ldap
from django.db import models from django.db import models
from django.db.utils import ProgrammingError, OperationalError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.conf import settings from django.conf import settings
from django_auth_ldap.config import LDAPSearch from django_auth_ldap.config import LDAPSearch
...@@ -50,9 +51,12 @@ class Setting(models.Model): ...@@ -50,9 +51,12 @@ class Setting(models.Model):
@classmethod @classmethod
def refresh_all_settings(cls): def refresh_all_settings(cls):
settings_list = cls.objects.all() try:
for setting in settings_list: settings_list = cls.objects.all()
setting.refresh_setting() for setting in settings_list:
setting.refresh_setting()
except (ProgrammingError, OperationalError):
pass
def refresh_setting(self): def refresh_setting(self):
try: try:
......
...@@ -107,7 +107,6 @@ class TerminalSettingView(AdminUserRequiredMixin, TemplateView): ...@@ -107,7 +107,6 @@ class TerminalSettingView(AdminUserRequiredMixin, TemplateView):
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)
def post(self, request): def post(self, request):
print(request.POST)
form = self.form_class(request.POST) form = self.form_class(request.POST)
if form.is_valid(): if form.is_valid():
form.save() form.save()
......
...@@ -385,10 +385,6 @@ TERMINAL_COMMAND_STORAGE = { ...@@ -385,10 +385,6 @@ TERMINAL_COMMAND_STORAGE = {
# 'TYPE': 'elasticsearch', # 'TYPE': 'elasticsearch',
# 'HOSTS': ['http://elastic:changeme@localhost:9200'], # 'HOSTS': ['http://elastic:changeme@localhost:9200'],
# }, # },
# 'ali-hz-es': {
# 'TYPE': 'elasticsearch',
# 'HOSTS': ['http://elastic:changeme@localhost:9200'],
# }
} }
......
This diff is collapsed.
...@@ -172,7 +172,6 @@ class UserBulkUpdateForm(forms.ModelForm): ...@@ -172,7 +172,6 @@ class UserBulkUpdateForm(forms.ModelForm):
if self.data.get(field) is not None: if self.data.get(field) is not None:
changed_fields.append(field) changed_fields.append(field)
print(changed_fields)
cleaned_data = {k: v for k, v in self.cleaned_data.items() cleaned_data = {k: v for k, v in self.cleaned_data.items()
if k in changed_fields} if k in changed_fields}
users = cleaned_data.pop('users', '') users = cleaned_data.pop('users', '')
......
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