mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-04 23:24:19 +00:00
feat: report charts (#15630)
* perf: initial * perf: basic finished * perf: depend * perf: Update Dockerfile with new base image tag * perf: Add user report api * perf: Update Dockerfile with new base image tag * perf: Use user report api * perf: Update Dockerfile with new base image tag * perf: user login report * perf: Update Dockerfile with new base image tag * perf: user change password * perf: change password dashboard * perf: Update Dockerfile with new base image tag * perf: Translate * perf: asset api * perf: asset activity * perf: Asset report * perf: add charts_map * perf: account report * perf: Translate * perf: account automation * perf: Account automation * perf: title * perf: Update Dockerfile with new base image tag --------- Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: feng <1304903146@qq.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: wangruidong <940853815@qq.com> Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
This commit is contained in:
@@ -172,10 +172,7 @@ class UserLoginLogViewSet(UserLoginCommonMixin, OrgReadonlyModelViewSet):
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
if current_org.is_root() or not settings.XPACK_ENABLED:
|
||||
return queryset
|
||||
users = self.get_org_member_usernames()
|
||||
queryset = queryset.filter(username__in=users)
|
||||
queryset = queryset.model.filter_queryset_by_org(queryset)
|
||||
return queryset
|
||||
|
||||
|
||||
@@ -297,12 +294,7 @@ class PasswordChangeLogViewSet(OrgReadonlyModelViewSet):
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
if not current_org.is_root():
|
||||
users = current_org.get_members()
|
||||
queryset = queryset.filter(
|
||||
user__in=[str(user) for user in users]
|
||||
)
|
||||
return queryset
|
||||
return self.model.filter_queryset_by_org(queryset)
|
||||
|
||||
|
||||
class UserSessionViewSet(CommonApiMixin, viewsets.ModelViewSet):
|
||||
|
||||
@@ -189,6 +189,15 @@ class PasswordChangeLog(models.Model):
|
||||
class Meta:
|
||||
verbose_name = _("Password change log")
|
||||
|
||||
@staticmethod
|
||||
def filter_queryset_by_org(queryset):
|
||||
if not current_org.is_root():
|
||||
users = current_org.get_members()
|
||||
queryset = queryset.filter(
|
||||
user__in=[str(user) for user in users]
|
||||
)
|
||||
return queryset
|
||||
|
||||
|
||||
class UserLoginLog(models.Model):
|
||||
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
||||
@@ -258,6 +267,15 @@ class UserLoginLog(models.Model):
|
||||
reason = old_reason_choices.get(self.reason, self.reason)
|
||||
return reason
|
||||
|
||||
@staticmethod
|
||||
def filter_queryset_by_org(queryset):
|
||||
from audits.utils import construct_userlogin_usernames
|
||||
if current_org.is_root() or not settings.XPACK_ENABLED:
|
||||
return queryset
|
||||
user_queryset = current_org.get_members()
|
||||
users = construct_userlogin_usernames(user_queryset)
|
||||
return queryset.filter(username__in=users)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-datetime", "username"]
|
||||
verbose_name = _("User login log")
|
||||
|
||||
Reference in New Issue
Block a user