Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Graphql query node for the project roles #1485

Open
sudan45 opened this issue Apr 23, 2024 · 0 comments
Open

Implement Graphql query node for the project roles #1485

sudan45 opened this issue Apr 23, 2024 · 0 comments

Comments

@sudan45
Copy link
Contributor

sudan45 commented Apr 23, 2024

Problem Statement

The 'Project roles' features uses a Rest API.

Acceptance Criteria

The 'Project Roles' feature works with a graphql query.

Additional Information

serializers

class ProjectRoleSerializer(RemoveNullFieldsMixin,
DynamicFieldsMixin,
serializers.ModelSerializer):
lead_permissions = serializers.SerializerMethodField()
entry_permissions = serializers.SerializerMethodField()
setup_permissions = serializers.SerializerMethodField()
export_permissions = serializers.SerializerMethodField()
assessment_permissions = serializers.SerializerMethodField()
class Meta:
model = ProjectRole
fields = '__all__'
def get_lead_permissions(self, roleobj):
return [
k
for k, v in PROJECT_PERMISSIONS['lead'].items()
if roleobj.lead_permissions & v != 0
]
def get_entry_permissions(self, roleobj):
return [
k
for k, v in PROJECT_PERMISSIONS['entry'].items()
if roleobj.entry_permissions & v != 0
]
def get_setup_permissions(self, roleobj):
return [
k
for k, v in PROJECT_PERMISSIONS['setup'].items()
if roleobj.setup_permissions & v != 0
]
def get_export_permissions(self, roleobj):
return [
k
for k, v in PROJECT_PERMISSIONS['export'].items()
if roleobj.export_permissions & v != 0
]
def get_assessment_permissions(self, roleobj):
return [
k
for k, v in PROJECT_PERMISSIONS['assessment'].items()
if roleobj.assessment_permissions & v != 0
]

views

class ProjectViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticated,
ModifyPermission]
filter_backends = (django_filters.rest_framework.DjangoFilterBackend,
filters.SearchFilter, filters.OrderingFilter)
filterset_class = ProjectFilterSet
search_fields = ('title', 'description',)
def get_queryset(self):
return get_filtered_projects(self.request.user, self.request.GET)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant