def update(self, member: Member, data: dict): if 'firstname' in data: member.firstname = data['firstname'] if 'lastname' in data: member.lastname = data['lastname'] if 'email' in data: member.email = data['email'] try: self._database_session.merge(member) self._database_session.flush() except IntegrityError: raise Error("Error data may be malformed") return member
def update(self, member: Member, data: dict): if 'name' in data: member.firstname = data['name'] if 'description' in data: member.lastname = data['description'] if 'price' in data: member.email = data['price'] try: self._database_session.merge(article) self._database_session.flush() except IntegrityError: raise Error("Error data may be malformed") return member
def update_remove_coach(self, member: Member, data: dict): if 'firstname' in data: member.firstname = data['firstname'] if 'lastname' in data: member.lastname = data['lastname'] if 'email' in data: member.email = data['email'] if 'coach' in data: s = None for sport in member.coached: if sport.name == data['coach']['name']: s = sport if s is not None: member.coached.remove(s) try: self._database_session.merge(member) self._database_session.flush() except IntegrityError: raise Error("Error data may be malformed") return member