-
Notifications
You must be signed in to change notification settings - Fork 78
Conversation
Codecov Report
@@ Coverage Diff @@
## master #360 +/- ##
==========================================
- Coverage 98.27% 98.23% -0.05%
==========================================
Files 154 154
Lines 4178 4189 +11
Branches 181 181
==========================================
+ Hits 4106 4115 +9
- Misses 52 54 +2
Partials 20 20
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #360 +/- ##
==========================================
+ Coverage 98.28% 98.28% +<.01%
==========================================
Files 155 155
Lines 4194 4202 +8
Branches 178 178
==========================================
+ Hits 4122 4130 +8
Misses 52 52
Partials 20 20
Continue to review full report at Codecov.
|
foodsaving/groups/models.py
Outdated
@@ -44,3 +44,6 @@ def add_member(self, user, history_payload=None): | |||
def remove_member(self, user): | |||
pre_group_leave.send(sender=self.__class__, group=self, user=user) | |||
self.members.remove(user) | |||
|
|||
def is_member(self, user): | |||
return user in self.members.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.members.filter(user=user).exists()
? Otherwise it's instantiating model objects for all the users (unless python/django allows something fancy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. oh, forgot to mark it as review comment. This one is now.
Looks good to me (with minor inline comment). |
foodsaving/groups/models.py
Outdated
@@ -44,3 +44,6 @@ def add_member(self, user, history_payload=None): | |||
def remove_member(self, user): | |||
pre_group_leave.send(sender=self.__class__, group=self, user=user) | |||
self.members.remove(user) | |||
|
|||
def is_member(self, user): | |||
return user in self.members.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. oh, forgot to mark it as review comment. This one is now.
I thought it makes sense to have the status checks (=predicates) inside the model.
Probably also helpful to have them at one place if we are going to use django-rules #353