Skip to content

Commit

Permalink
is pinned project added in projectDetailType
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Jan 26, 2024
1 parent 761bc69 commit 77fd660
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion apps/project/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class Meta:
organizations = graphene.List(graphene.NonNull(ProjectOrganizationType))
has_analysis_framework = graphene.Boolean(required=True)
has_assessment_template = graphene.Boolean(required=True)
is_project_pinned = graphene.Boolean(required=True)

# NOTE: This is a custom feature
# see: https://github.com/eamigo86/graphene-django-extras/compare/graphene-v2...the-deep:graphene-v2
Expand Down Expand Up @@ -301,6 +302,12 @@ def resolve_regions(root, info, **kwargs):
return info.context.dl.project.geo_region.load(root.pk)
return info.context.dl.project.public_geo_region.load(root.pk)

def resolve_is_project_pinned(root, info, **kwargs):
return ProjectPinned.objects.filter(
project=root,
user=info.context.request.user
).exists()


class RecentActivityType(graphene.ObjectType):
id = graphene.ID(required=True)
Expand Down Expand Up @@ -447,6 +454,10 @@ class Meta:
# Other scoped queries
unified_connector = graphene.Field(UnifiedConnectorQueryType)
assisted_tagging = graphene.Field(AssistedTaggingQueryType)
is_project_pinned = graphene.Boolean(
required=True,
description='Check if user have pinned the project'
)

@staticmethod
def resolve_user_members(root, info, **kwargs):
Expand Down Expand Up @@ -496,6 +507,13 @@ def resolve_assisted_tagging(root, info, **kwargs):
if root.get_current_user_role(info.context.request.user) is not None:
return {}

@staticmethod
def resolve_is_project_pinned(root, info, **kwargs):
return ProjectPinned.objects.filter(
project=root,
user=info.context.request.user
).exists()


class UserPinnedProjectType(ClientIdMixin, DjangoObjectType):
class Meta:
Expand All @@ -506,7 +524,7 @@ class Meta:
"order",
"client_id",
)
project = graphene.Field(ProjectDetailType)
project = graphene.Field(graphene.NonNull(ProjectDetailType))


class ProjectByRegion(graphene.ObjectType):
Expand Down
4 changes: 3 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3290,6 +3290,7 @@ type ProjectDetailType {
organizations: [ProjectOrganizationType!]
hasAnalysisFramework: Boolean!
hasAssessmentTemplate: Boolean!
isProjectPinned: Boolean!
analysisOverview: AnalysisOverviewType
analysis(id: ID!): AnalysisType
analyses(createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], page: Int = 1, ordering: String, pageSize: Int): AnalysisListType
Expand Down Expand Up @@ -3620,6 +3621,7 @@ type ProjectType {
organizations: [ProjectOrganizationType!]
hasAnalysisFramework: Boolean!
hasAssessmentTemplate: Boolean!
isProjectPinned: Boolean!
}

input ProjectUpdateInputType {
Expand Down Expand Up @@ -4380,7 +4382,7 @@ input UserPinnedProjectReOrderInputType {
}

type UserPinnedProjectType {
project: ProjectDetailType
project: ProjectDetailType!
user: UserType!
order: Int!
clientId: String!
Expand Down

0 comments on commit 77fd660

Please sign in to comment.