Exemple #1
0
 def add_friend(self, other):
     if self != other:
         if other not in self.friends:
             self.friends.append(other)
         if self not in other.friends:
             other.friends.append(self)
     db_session.flush()
Exemple #2
0
 def remove_friend(self, other):
     if other.best_friend == self:
         other.best_friend = None
         # Needed to avoid sqlalchemy.exc.CircularDependencyError
         db_session.flush()
     if self.best_friend == other:
         self.best_friend = None
     if self not in other.friends:
         raise Exception
     self.friends.remove(other)
     other.friends.remove(self)
     db_session.flush()
Exemple #3
0
 def make_best_friend(self, other):
     if other not in self.friends:
         raise Exception
     self.best_friend = other
     db_session.flush()