mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-19 10:26:27 +00:00
@@ -53,7 +53,7 @@ class AdHocRunHistorySerializer(serializers.ModelSerializer):
|
||||
@staticmethod
|
||||
def get_stat(obj):
|
||||
return {
|
||||
"total": len(obj.adhoc.hosts),
|
||||
"total": obj.adhoc.hosts.count(),
|
||||
"success": len(obj.summary.get("contacted", [])),
|
||||
"failed": len(obj.summary.get("dark", [])),
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ app_name = "ops"
|
||||
router = DefaultRouter()
|
||||
router.register(r'tasks', api.TaskViewSet, 'task')
|
||||
router.register(r'adhoc', api.AdHocViewSet, 'adhoc')
|
||||
router.register(r'history', api.AdHocRunHistoryViewSet, 'history')
|
||||
router.register(r'command-executions', api.CommandExecutionViewSet, 'command-execution')
|
||||
|
||||
urlpatterns = [
|
||||
|
@@ -27,7 +27,7 @@ class TaskListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
if current_org.is_real():
|
||||
if current_org:
|
||||
queryset = queryset.filter(created_by=current_org.id)
|
||||
else:
|
||||
queryset = queryset.filter(created_by='')
|
||||
@@ -62,8 +62,11 @@ class TaskDetailView(AdminUserRequiredMixin, DetailView):
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
if current_org:
|
||||
# Todo: 需要整理默认组织等东西
|
||||
if current_org.is_real():
|
||||
queryset = queryset.filter(created_by=current_org.id)
|
||||
else:
|
||||
queryset = queryset.filter(created_by='')
|
||||
return queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
Reference in New Issue
Block a user