diff --git a/apps/analysis/mutation.py b/apps/analysis/mutation.py index 4e34220516..87791565de 100644 --- a/apps/analysis/mutation.py +++ b/apps/analysis/mutation.py @@ -278,7 +278,13 @@ class Arguments: result = graphene.Field(AnalysisReportUploadType) -class CreateAnalysis(RequiredPermissionMixin, PsGrapheneMutation): +class AnalysisMutationMixin(RequiredPermissionMixin): + @classmethod + def filter_queryset(cls, qs, info): + return qs.filter(project=info.context.active_project) + + +class CreateAnalysis(AnalysisMutationMixin, PsGrapheneMutation): class Arguments: data = AnalysisInputType(required=True) model = Analysis @@ -286,7 +292,7 @@ class Arguments: result = graphene.Field(AnalysisType) -class UpdateAnalysis(RequiredPermissionMixin, PsGrapheneMutation): +class UpdateAnalysis(AnalysisMutationMixin, PsGrapheneMutation): class Arguments: data = AnalysisInputType(required=True) id = graphene.ID(required=True) @@ -295,7 +301,7 @@ class Arguments: result = graphene.Field(AnalysisType) -class DeleteAnalysis(RequiredPermissionMixin, PsDeleteMutation): +class DeleteAnalysis(AnalysisMutationMixin, PsDeleteMutation): class Arguments: id = graphene.ID(required=True) model = Analysis @@ -303,18 +309,18 @@ class Arguments: class BulkAnalysisInputType(AnalysisInputType): - id = graphene.ID() + id = graphene.ID(required=True) -class BulkAnalysis(RequiredPermissionMixin, PsBulkGrapheneMutation): +class BulkUpdateAnalysis(AnalysisMutationMixin, PsBulkGrapheneMutation): class Arguments: items = graphene.List(graphene.NonNull(BulkAnalysisInputType)) delete_ids = graphene.List(graphene.NonNull(graphene.ID)) - result = graphene.List(AnalysisType) - deleted_result = graphene.List(graphene.NonNull(AnalysisType)) model = Analysis serializer_class = AnalysisGqlSerializer + result = graphene.List(AnalysisType) + deleted_result = graphene.List(graphene.NonNull(AnalysisType)) class Mutation(): @@ -341,4 +347,4 @@ class Mutation(): analysis_create = CreateAnalysis.Field() analysis_update = UpdateAnalysis.Field() analysis_delete = DeleteAnalysis.Field() - analysis_bulk = BulkAnalysis.Field() + analysis_bulk_update = BulkUpdateAnalysis.Field() diff --git a/schema.graphql b/schema.graphql index baec0af657..2c6a7653ee 100644 --- a/schema.graphql +++ b/schema.graphql @@ -3280,12 +3280,6 @@ enum AutomaticSummaryStatusEnum { SEND_FAILED } -type BulkAnalysis { - errors: [[GenericScalar!]] - result: [AnalysisType] - deletedResult: [AnalysisType!] -} - input BulkAnalysisFrameworkMembershipInputType { id: ID member: ID! @@ -3294,7 +3288,7 @@ input BulkAnalysisFrameworkMembershipInputType { } input BulkAnalysisInputType { - id: ID + id: ID! title: String! teamLead: ID! startDate: Date @@ -3372,6 +3366,12 @@ input BulkProjectUserGroupMembershipInputType { id: ID } +type BulkUpdateAnalysis { + errors: [[GenericScalar!]] + result: [AnalysisType] + deletedResult: [AnalysisType!] +} + type BulkUpdateAnalysisFrameworkMembership { errors: [[GenericScalar!]] result: [AnalysisFrameworkMembershipType] @@ -5474,7 +5474,7 @@ type ProjectMutationType { analysisCreate(data: AnalysisInputType!): CreateAnalysis analysisUpdate(data: AnalysisInputType!, id: ID!): UpdateAnalysis analysisDelete(id: ID!): DeleteAnalysis - analysisBulk(deleteIds: [ID!], items: [BulkAnalysisInputType!]): BulkAnalysis + analysisBulkUpdate(deleteIds: [ID!], items: [BulkAnalysisInputType!]): BulkUpdateAnalysis exportCreate(data: ExportCreateInputType!): CreateUserExport exportUpdate(data: ExportUpdateInputType!, id: ID!): UpdateUserExport exportCancel(id: ID!): CancelUserExport