コード例 #1
0
    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!")
コード例 #2
0
    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!")