Skip to content

Commit

Permalink
Fix permission on Analysis CRUD to GraphQL mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
sauravsapkota committed Jul 29, 2024
1 parent 067cf25 commit d68451c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
22 changes: 14 additions & 8 deletions apps/analysis/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,21 @@ 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
serializer_class = AnalysisGqlSerializer
result = graphene.Field(AnalysisType)


class UpdateAnalysis(RequiredPermissionMixin, PsGrapheneMutation):
class UpdateAnalysis(AnalysisMutationMixin, PsGrapheneMutation):
class Arguments:
data = AnalysisInputType(required=True)
id = graphene.ID(required=True)
Expand All @@ -295,26 +301,26 @@ class Arguments:
result = graphene.Field(AnalysisType)


class DeleteAnalysis(RequiredPermissionMixin, PsDeleteMutation):
class DeleteAnalysis(AnalysisMutationMixin, PsDeleteMutation):
class Arguments:
id = graphene.ID(required=True)
model = Analysis
result = graphene.Field(AnalysisType)


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():
Expand All @@ -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()
16 changes: 8 additions & 8 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3280,12 +3280,6 @@ enum AutomaticSummaryStatusEnum {
SEND_FAILED
}

type BulkAnalysis {
errors: [[GenericScalar!]]
result: [AnalysisType]
deletedResult: [AnalysisType!]
}

input BulkAnalysisFrameworkMembershipInputType {
id: ID
member: ID!
Expand All @@ -3294,7 +3288,7 @@ input BulkAnalysisFrameworkMembershipInputType {
}

input BulkAnalysisInputType {
id: ID
id: ID!
title: String!
teamLead: ID!
startDate: Date
Expand Down Expand Up @@ -3372,6 +3366,12 @@ input BulkProjectUserGroupMembershipInputType {
id: ID
}

type BulkUpdateAnalysis {
errors: [[GenericScalar!]]
result: [AnalysisType]
deletedResult: [AnalysisType!]
}

type BulkUpdateAnalysisFrameworkMembership {
errors: [[GenericScalar!]]
result: [AnalysisFrameworkMembershipType]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d68451c

Please sign in to comment.