diff --git a/canvas_classes.py b/canvas_classes.py index a9366dd0e22d06b26d9e396baa13fa1049453e2b..03f52a937fd52e325a11a6fec0c545de83ffdd8c 100644 --- a/canvas_classes.py +++ b/canvas_classes.py @@ -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. diff --git a/composite_user.py b/composite_user.py index 49bfb05fc83a41161a5cda31e79409b25f11154a..bf2d485f10f9ce5b185006dfefc78a47b5d057e1 100644 --- a/composite_user.py +++ b/composite_user.py @@ -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] diff --git a/gitlab_classes.py b/gitlab_classes.py index 7469f46aa8deea9f316679597ba0a895b9d2a5ed..cc3d2cf965dee3e032febadd731ece09aad78cda 100644 --- a/gitlab_classes.py +++ b/gitlab_classes.py @@ -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):