def save(self): cpf_check = User.check_cpf(self.cpf) if cpf_check: self.password = User.hash_password(self.password) organization = Organization(cpf_cnpj=self.cpf, description=self.fullname) organization.save() # creates an User. db.session.add(self) db.session.commit() else: raise Exception("CPF Inválido!")
def register(self): cpf_check = True # User.check_cpf(self.cpf) if cpf_check: self.password = User.hash_password(self.password) organization = Organization(cpf_cnpj=self.cpf, description=self.fullname) organization.save() self.organization = organization self.fk_organizations_id = organization.id # creates an User. db.session.add(self) db.session.commit() else: raise Exception("CPF Inválido!")