Skip to content
Snippets Groups Projects
Commit dd20cb6f authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Added equality operators and blacklist/graylist compatibility checks.

parent e2c73166
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,15 @@ class CanvasUser:
username = self.get_username()
return f'@{username}'
def __eq__(self, other):
if isinstance(other, CanvasUser):
return self.get_username() == other.get_username()
else:
return False
def __ne__(self, other):
return not self.__eq__(other)
"""
// A Canvas user, e.g. a student, teacher, administrator, observer, etc.
......
......@@ -48,12 +48,30 @@ class CompositeUser:
def discard_team(self):
self.candidate_teammates = None
def has_blacklist(self):
return len(self.blacklist) > 0
def is_blacklist_compatible(self, other):
return other not in self.blacklist
def is_graylist_compatible(self, other):
return other not in self.graylist
def __repr__(self):
if self.canvas_email == self.gitlab_email:
return f'{self.readable_name} <{self.canvas_email}>'
else:
return f'{self.readable_name} <{self.canvas_email}> <{self.gitlab_email}>'
def __eq__(self, other):
if isinstance(other, CompositeUser):
return self.canvas_username() == other.canvas_username()
else:
return False
def __ne__(self, other):
return not self.__eq__(other)
@staticmethod
def get_user(username_or_email):
return CompositeUser.instances[username_or_email]
......
......@@ -45,6 +45,15 @@ class GitlabUser:
username = self.get_username()
return f'@{username}'
def __eq__(self, other):
if isinstance(other, GitlabUser):
return self.get_username() == other.get_username()
else:
return False
def __ne__(self, other):
return not self.__eq__(other)
class Issue:
def __init__(self, issue):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment