<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete(self, reason=''):
 """Deletes the event chatroom and if necessary the chatroom, too. :param reason: reason for the deletion :return: True if the associated chatroom was also deleted, otherwise False """

        db.session.delete(self)
        db.session.flush()
        if not self.chatroom.events:
            db.session.delete(self.chatroom)
            db.session.flush()
            delete_room(self.chatroom, reason)
            return True
        return False