mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-19 02:22:37 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d67c6d0e | ||
|
|
627eb6abb1 | ||
|
|
c908b47ccf | ||
|
|
88af33b7c2 | ||
|
|
136537fcfb | ||
|
|
dfd404c549 | ||
|
|
53886a5abf | ||
|
|
50d3125fec | ||
|
|
1145305f11 | ||
|
|
433f063142 |
@@ -43,7 +43,7 @@ class AccountViewSet(OrgBulkModelViewSet):
|
|||||||
asset = get_object_or_404(Asset, pk=asset_id)
|
asset = get_object_or_404(Asset, pk=asset_id)
|
||||||
accounts = asset.accounts.all()
|
accounts = asset.accounts.all()
|
||||||
else:
|
else:
|
||||||
accounts = []
|
accounts = Account.objects.none()
|
||||||
accounts = self.filter_queryset(accounts)
|
accounts = self.filter_queryset(accounts)
|
||||||
serializer = serializers.AccountSerializer(accounts, many=True)
|
serializer = serializers.AccountSerializer(accounts, many=True)
|
||||||
return Response(data=serializer.data)
|
return Response(data=serializer.data)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from rest_framework.permissions import IsAuthenticated
|
|||||||
from common.drf.filters import DatetimeRangeFilter
|
from common.drf.filters import DatetimeRangeFilter
|
||||||
from common.plugins.es import QuerySet as ESQuerySet
|
from common.plugins.es import QuerySet as ESQuerySet
|
||||||
from common.utils import is_uuid
|
from common.utils import is_uuid
|
||||||
|
from common.utils import lazyproperty
|
||||||
from orgs.mixins.api import OrgReadonlyModelViewSet, OrgModelViewSet
|
from orgs.mixins.api import OrgReadonlyModelViewSet, OrgModelViewSet
|
||||||
from orgs.utils import current_org, tmp_to_root_org
|
from orgs.utils import current_org, tmp_to_root_org
|
||||||
from orgs.models import Organization
|
from orgs.models import Organization
|
||||||
@@ -143,13 +144,19 @@ class OperateLogViewSet(OrgReadonlyModelViewSet):
|
|||||||
search_fields = ['resource', 'user']
|
search_fields = ['resource', 'user']
|
||||||
ordering = ['-datetime']
|
ordering = ['-datetime']
|
||||||
|
|
||||||
|
@lazyproperty
|
||||||
|
def is_action_detail(self):
|
||||||
|
return self.detail and self.request.query_params.get('type') == 'action_detail'
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
if self.request.query_params.get('type') == 'action_detail':
|
if self.is_action_detail:
|
||||||
return OperateLogActionDetailSerializer
|
return OperateLogActionDetailSerializer
|
||||||
return super().get_serializer_class()
|
return super().get_serializer_class()
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
org_q = Q(org_id=Organization.SYSTEM_ID) | Q(org_id=current_org.id)
|
org_q = Q(org_id=current_org.id)
|
||||||
|
if self.is_action_detail:
|
||||||
|
org_q |= Q(org_id=Organization.SYSTEM_ID)
|
||||||
with tmp_to_root_org():
|
with tmp_to_root_org():
|
||||||
qs = OperateLog.objects.filter(org_q)
|
qs = OperateLog.objects.filter(org_q)
|
||||||
es_config = settings.OPERATE_LOG_ELASTICSEARCH_CONFIG
|
es_config = settings.OPERATE_LOG_ELASTICSEARCH_CONFIG
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from django.db import transaction
|
|||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from users.models import User
|
|
||||||
from common.utils import get_request_ip, get_logger
|
from common.utils import get_request_ip, get_logger
|
||||||
from common.utils.timezone import as_current_tz
|
from common.utils.timezone import as_current_tz
|
||||||
from common.utils.encode import Singleton
|
from common.utils.encode import Singleton
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||||
from audits.backends.db import OperateLogStore
|
from audits.backends.db import OperateLogStore
|
||||||
from common.serializers.fields import LabeledChoiceField
|
from common.serializers.fields import LabeledChoiceField
|
||||||
from common.utils import reverse, i18n_trans
|
from common.utils import reverse, i18n_trans
|
||||||
@@ -78,7 +78,7 @@ class OperateLogActionDetailSerializer(serializers.ModelSerializer):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class OperateLogSerializer(serializers.ModelSerializer):
|
class OperateLogSerializer(BulkOrgResourceModelSerializer):
|
||||||
action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action"))
|
action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action"))
|
||||||
resource = serializers.SerializerMethodField(label=_("Resource"))
|
resource = serializers.SerializerMethodField(label=_("Resource"))
|
||||||
resource_type = serializers.SerializerMethodField(label=_('Resource Type'))
|
resource_type = serializers.SerializerMethodField(label=_('Resource Type'))
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import codecs
|
import codecs
|
||||||
import copy
|
import copy
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
from common.utils.timezone import as_current_tz
|
||||||
from common.utils import validate_ip, get_ip_city, get_logger
|
from common.utils import validate_ip, get_ip_city, get_logger
|
||||||
from settings.serializers import SettingsSerializer
|
|
||||||
from .const import DEFAULT_CITY
|
from .const import DEFAULT_CITY
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
@@ -70,6 +72,8 @@ def _get_instance_field_value(
|
|||||||
f.verbose_name = 'id'
|
f.verbose_name = 'id'
|
||||||
elif isinstance(value, (list, dict)):
|
elif isinstance(value, (list, dict)):
|
||||||
value = copy.deepcopy(value)
|
value = copy.deepcopy(value)
|
||||||
|
elif isinstance(value, datetime):
|
||||||
|
value = as_current_tz(value).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
elif isinstance(f, models.OneToOneField) and isinstance(value, models.Model):
|
elif isinstance(f, models.OneToOneField) and isinstance(value, models.Model):
|
||||||
nested_data = _get_instance_field_value(
|
nested_data = _get_instance_field_value(
|
||||||
value, include_model_fields, model_need_continue_fields, ('id',)
|
value, include_model_fields, model_need_continue_fields, ('id',)
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
# This will make sure the app is always imported when
|
# This will make sure the app is always imported when
|
||||||
# Django starts so that shared_task will use this app.
|
# Django starts so that shared_task will use this app.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from werkzeug.local import Local
|
from werkzeug.local import Local
|
||||||
|
|
||||||
thread_local = Local()
|
thread_local = Local()
|
||||||
encrypted_field_set = set()
|
encrypted_field_set = {'password'}
|
||||||
|
|
||||||
|
|
||||||
def _find(attr):
|
def _find(attr):
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class Subscription:
|
|||||||
try:
|
try:
|
||||||
self.sub.close()
|
self.sub.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Unsubscribe msg error: {}'.format(e))
|
logger.debug('Unsubscribe msg error: {}'.format(e))
|
||||||
|
|
||||||
def retry(self, _next, error, complete):
|
def retry(self, _next, error, complete):
|
||||||
logger.info('Retry subscribe channel: {}'.format(self.ch))
|
logger.info('Retry subscribe channel: {}'.format(self.ch))
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ only_system_permissions = (
|
|||||||
('xpack', 'license', '*', '*'),
|
('xpack', 'license', '*', '*'),
|
||||||
('settings', 'setting', '*', '*'),
|
('settings', 'setting', '*', '*'),
|
||||||
('tickets', '*', '*', '*'),
|
('tickets', '*', '*', '*'),
|
||||||
('ops', 'task', 'view', 'taskmonitor'),
|
('ops', 'celerytask', 'view', 'taskmonitor'),
|
||||||
('terminal', 'terminal', '*', '*'),
|
('terminal', 'terminal', '*', '*'),
|
||||||
('terminal', 'commandstorage', '*', '*'),
|
('terminal', 'commandstorage', '*', '*'),
|
||||||
('terminal', 'replaystorage', '*', '*'),
|
('terminal', 'replaystorage', '*', '*'),
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class MailTestingAPI(APIView):
|
|||||||
# if k.startswith('EMAIL'):
|
# if k.startswith('EMAIL'):
|
||||||
# setattr(settings, k, v)
|
# setattr(settings, k, v)
|
||||||
try:
|
try:
|
||||||
subject = settings.EMAIL_SUBJECT_PREFIX + "Test"
|
subject = settings.EMAIL_SUBJECT_PREFIX or '' + "Test"
|
||||||
message = "Test smtp setting"
|
message = "Test smtp setting"
|
||||||
email_from = email_from or email_host_user
|
email_from = email_from or email_host_user
|
||||||
email_recipient = email_recipient or email_from
|
email_recipient = email_recipient or email_from
|
||||||
|
|||||||
Reference in New Issue
Block a user