diff --git a/apps/project/admin.py b/apps/project/admin.py index 0499a8497f..c8cce7d97a 100644 --- a/apps/project/admin.py +++ b/apps/project/admin.py @@ -25,7 +25,6 @@ ProjectOrganization, ProjectChangeLog, ProjectPinned, - ProjectJoinRequest ) TRIGGER_LIMIT = 5 @@ -230,14 +229,12 @@ def get_readonly_fields(self, request, obj=None): return self.readonly_fields - @admin.register(ProjectJoinRequest) class ProjectJoinAdmin(admin.ModelAdmin): search_fields = ['project__title'] autocomplete_fields = ('requested_by', 'responded_by', 'project') list_display = ['project', 'requested_by', 'responded_by', 'status'] - def get_readonly_fields(self, request, obj=None): # editing an existing object if obj: diff --git a/apps/project/mutation.py b/apps/project/mutation.py index a97b314aa9..d91782f0eb 100644 --- a/apps/project/mutation.py +++ b/apps/project/mutation.py @@ -51,7 +51,6 @@ UserPinnedProjectSerializer, BulkProjectPinnedSerializer, UserProjectLeaveSerializer - ) from .schema import ( ProjectDetailType, @@ -359,11 +358,13 @@ class LeaveProject(ProjectScopeMixin, graphene.Mutation): @classmethod def mutate(cls, root, info, **kwargs): project = info.context.active_project - serializer = UserProjectLeaveSerializer(data ={} ,context={'request': info.context.request}) + serializer = UserProjectLeaveSerializer(data={}, context={'request': info.context.request}) if serializer.is_valid(): serializer.save() return LeaveProject(ok=True, result=project) return LeaveProject(ok=False, errors=serializer.errors) + + class ProjectMutationType( # --Begin Project Scoped Mutation LeadMutation, @@ -395,7 +396,6 @@ class Meta: assisted_tagging = graphene.Field(AssistedTaggingMutationType) leave_project = LeaveProject.Field() - @staticmethod def get_custom_node(_, info, id): try: @@ -473,7 +473,6 @@ def mutate(root, info, id): return DeleteUserPinnedProject(result=root, errors=None, ok=True) - class Mutation(object): project_create = CreateProject.Field() join_project = CreateProjectJoin.Field() diff --git a/apps/project/serializers.py b/apps/project/serializers.py index f6b122aa60..c43f3afed5 100644 --- a/apps/project/serializers.py +++ b/apps/project/serializers.py @@ -53,7 +53,6 @@ from .activity import project_activity_log - class SimpleProjectSerializer(RemoveNullFieldsMixin, serializers.ModelSerializer): class Meta: @@ -970,11 +969,11 @@ def validate(self, data): ) if membership.count() == 1: raise serializers.ValidationError('Cannot leave the project') - if membership.filter(role == ProjectRole.get_owner_role()).count() == 1: + if membership.filter(role=ProjectRole.get_owner_role()).count() == 1: raise serializers.ValidationError('Cannot leave the project') return data - + def create(self, data): ProjectJoinRequest.objects.filter(project=self.project, requested_by=self.current_user).delete() ProjectMembership.objects.filter(project=self.project, member=self.current_user).delete() - return data \ No newline at end of file + return data