* [Bugfix] 修复错误

* [Bugfix] 修复一些bug
This commit is contained in:
老广
2018-12-17 11:44:43 +08:00
committed by GitHub
parent 374039d287
commit 985bd6fc82
6 changed files with 22 additions and 15 deletions

View File

@@ -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", [])),
}

View File

@@ -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 = [

View File

@@ -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):