Exemple #1
0
 def create(self, data: dict):
     try:
         member = Member(firstname=data.get('firstname'),
                         lastname=data.get('lastname'),
                         email=data.get('email'))
         print(member.to_dict())
         self._database_session.add(member)
         self._database_session.flush()
     except IntegrityError as e:
         print(e)
         raise Error("Member already exists")
     return member
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 def create(self, data: dict):
     member = Member(firstname=data.get('firstname').lower(),
                     lastname=data.get('lastname').lower(),
                     email=data.get('email'),
                     medical_certificate=data.get('medical_certificate',
                                                  False))
     if 'address' in data.keys():
         address = data['address']
         member.set_address(address['street'],
                            address['postal_code'], address['city'],
                            address.get('country', 'FRANCE'))
     self._database_session.add(member)
     self._database_session.flush()
     return member
Exemple #5
0
 def update(self, member: Member, data: dict):
     if 'email' in data:
         member.email = data['email']
     if 'pseudo' in data:
         member.pseudo = data['pseudo']
     if 'mot_de_passe' in data:
         member.mot_de_passe = data['mot_de_passe']
     if 'genre' in data:
         member.genre = data['genre']
     try:
         self._database_session.merge(member)
         self._database_session.flush()
     except IntegrityError:
         raise Error("Error data may be malformed")
     return member
Exemple #6
0
 def create(self, data: dict):
     try:
         member = Member(firstname=data.get('firstname'), lastname=data.get('lastname'), email=data.get('email'),
                       medical_certificate=data.get('medical_certificate'))
         self._database_session.add(member)
         self._database_session.flush()
     except IntegrityError:
         raise Error("Member already exists.")
     return member
Exemple #7
0
 def create(self, data: dict):
     try:
         member = Member(name=data.get('name'),
                         description=data.get('description'),
                         price=data.get('price'))
         self._database_session.add(article)
         self._database_session.flush()
     except IntegrityError:
         raise Error("Article already exists")
     return member
Exemple #8
0
 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
Exemple #9
0
 def create(self, data: dict):
     try:
         member = Member(email=data.get('email'),
                         pseudo=data.get('pseudo'),
                         mot_de_passe=data.get('mot_de_passe'),
                         genre=data.get('genre'))
         self._database_session.add(member)
         self._database_session.flush()
     except IntegrityError:
         raise Error("Member already exists")
     return member
Exemple #10
0
    def update(self, member: Member, data: dict):
        # Update Person data
        super().update(member, data)

        # Update Member data
        if 'medical_certificate' in data:
            member.medical_certificate = data['medical_certificate']

        self._database_session.merge(member)
        self._database_session.flush()

        return member