def add_contact(self, name, surname, email, phone, role, id_field): contact = Contact(name, surname, email, phone, role, id_field) dB.add(contact) try: dB.commit() return contact.serialize() except Exception as e: dB.rollback() return None
def add_user(self, name, surname, role, email, password, is_admin): user = User(name, surname, role, email, password, is_admin == 1) dB.add(user) try: dB.commit() return True except Exception as e: dB.rollback() return False
def add_field_v2(self, name, description, descriptor, website): field = Field(name, description, descriptor, website) dB.add(field) try: dB.commit() return field.id except Exception as e: dB.rollback() return -1
def add_field(self, name, description, descriptor, website): field = Field(name, description, descriptor, website) dB.add(field) try: dB.commit() return field.serialize() except Exception as e: dB.rollback() return None
def add_team(self, id_prediction, id_field, nb_members): team = Team(id_prediction, id_field, nb_members) dB.add(team) try: dB.commit() return True except Exception as e: dB.rollback() return False
def add_offer_v2(self, title, content, descriptor, id_user): offer = Offer(title, content, descriptor, id_user) dB.add(offer) try: dB.commit() return offer.id except Exception as e: dB.rollback() return -1
def add_prediction_v2(self, mark, inbase, id_offer): date = datetime.datetime.now() prediction = Prediction(mark, inbase == 1, date, id_offer) dB.add(prediction) try: dB.commit() return prediction.id except Exception as e: dB.rollback() return -1