File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from django .db import models
77
88from files .models import UserFile
9- from projects .models import Project
109
1110User = get_user_model ()
1211
@@ -87,7 +86,7 @@ class ProjectChat(BaseChat):
8786
8887 id = models .PositiveIntegerField (primary_key = True , unique = True )
8988 project = models .ForeignKey (
90- Project , on_delete = models .CASCADE , related_name = "project_chats"
89+ "projects. Project" , on_delete = models .CASCADE , related_name = "project_chats"
9190 )
9291
9392 def get_users (self ):
Original file line number Diff line number Diff line change 11from django .contrib .auth .models import AbstractUser
22from django .db import models
3+ from chats .models import ProjectChat
34
45from users .constants import (
56 ADMIN ,
@@ -133,14 +134,19 @@ def calculate_ordering_score(self) -> int:
133134 score += 7
134135 return score
135136
136- def get_project_chats (self ) -> list :
137- collaborations = self .collaborations .prefetch_related (
138- "project__project_chats"
139- ).all ()
140- projects = []
141- for collaboration in collaborations :
142- projects .extend (list (collaboration .project .project_chats .all ()))
143- return projects
137+ def get_project_chats (self ):
138+ # collaborations = self.collaborations.prefetch_related(
139+ # "project__project_chats"
140+ # ).all()
141+
142+ # return queryset of project chats
143+ return ProjectChat .objects .filter (
144+ project__collaborations__user_id = self .id
145+ ).distinct ()
146+ # projects = []
147+ # for collaboration in collaborations:
148+ # projects.extend(list(collaboration.project.project_chats.all()))
149+ # return projects
144150
145151 def get_key_skills (self ) -> list [str ]:
146152 return [skill .strip () for skill in self .key_skills .split ("," ) if skill .strip ()]
You can’t perform that action at this time.
0 commit comments