Esempio n. 1
0
class Processo(db.Model):
    __tablename__ = 'processos'

    id = db.Column(db.Integer, primary_key=True)
    especie = db.Column(db.String(25, collation='latin1_general_ci'),
                        nullable=False)
    numero = db.Column(db.Integer, unique=True)
    identificacao = db.Column(db.Text(collation='latin1_general_ci'))
    vara = db.Column(db.String(200, collation='latin1_general_ci'))
    link = db.Column(db.String(1000, collation='latin1_general_ci'))
    probabilidade = db.Column(db.String(25, collation='latin1_general_ci'))
    posicao_assistido = db.Column(db.String(25, collation='latin1_general_ci'))
    valor_causa_inicial = db.Column(db.Integer)
    valor_causa_atual = db.Column(db.Integer)
    data_distribuicao = db.Column(db.Date)
    data_transito_em_julgado = db.Column(db.Date)
    obs = db.Column(db.Text(collation='latin1_general_ci'))
    id_caso = db.Column(db.Integer, db.ForeignKey("casos.id"), nullable=False)
    caso = db.relationship("Caso", lazy="joined")
    status = db.Column(db.Boolean, default=True, nullable=False)
    id_criado_por = db.Column(db.Integer,
                              db.ForeignKey('usuarios.id'),
                              nullable=False,
                              default=1)
    criado_por = db.relationship('Usuario', foreign_keys=[id_criado_por])
Esempio n. 2
0
class Arquivo(db.Model):
    __tablename__ = 'arquivos'

    id = db.Column(db.Integer, primary_key=True)
    titulo = db.Column(db.String(150, collation='latin1_general_ci'),
                       nullable=False)
    descricao = db.Column(db.String(8000, collation='latin1_general_ci'))
    nome = db.Column(db.Text(collation='latin1_general_ci'), nullable=False)
Esempio n. 3
0
class Caso(db.Model):
    __tablename__ = 'casos'

    id = db.Column(db.Integer, primary_key=True)

    id_usuario_responsavel = db.Column(db.Integer,
                                       db.ForeignKey('usuarios.id'),
                                       nullable=False)
    usuario_responsavel = db.relationship(
        'Usuario', foreign_keys=[id_usuario_responsavel])

    area_direito = db.Column(db.String(50, collation='latin1_general_ci'),
                             nullable=False)

    clientes = db.relationship('Atendido',
                               secondary=associacao_casos_atendidos,
                               back_populates='casos')

    id_orientador = db.Column(db.Integer, db.ForeignKey('usuarios.id'))
    orientador = db.relationship('Usuario', foreign_keys=[id_orientador])

    id_estagiario = db.Column(db.Integer, db.ForeignKey('usuarios.id'))
    estagiario = db.relationship('Usuario', foreign_keys=[id_estagiario])

    id_colaborador = db.Column(db.Integer, db.ForeignKey('usuarios.id'))
    colaborador = db.relationship('Usuario', foreign_keys=[id_colaborador])

    data_criacao = db.Column(db.DateTime, nullable=False)
    id_criado_por = db.Column(db.Integer,
                              db.ForeignKey('usuarios.id'),
                              nullable=False)
    criado_por = db.relationship('Usuario', foreign_keys=[id_criado_por])

    data_modificacao = db.Column(db.DateTime)
    id_modificado_por = db.Column(db.Integer, db.ForeignKey('usuarios.id'))
    modificado_por = db.relationship('Usuario',
                                     foreign_keys=[id_modificado_por])

    situacao_deferimento = db.Column(db.String(50,
                                               collation='latin1_general_ci'),
                                     nullable=False,
                                     default='aguardando_deferimento')
    justif_indeferimento = db.Column(db.String(280,
                                               collation='latin1_general_ci'),
                                     nullable=True)

    status = db.Column(db.Boolean, default=True, nullable=False)
    descricao = db.Column(db.Text(collation='latin1_general_ci'))
    arquivo = db.Column(db.String(300, collation='latin1_general_ci'))

    numero_ultimo_processo = db.Column(db.Integer, nullable=True)
Esempio n. 4
0
class Usuario(db.Model, UserMixin):
    bcrypt = Bcrypt()

    __tablename__ = 'usuarios'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(80, collation='latin1_general_ci'),
                      unique=True,
                      nullable=False)
    senha = db.Column(db.String(60, collation='latin1_general_ci'),
                      nullable=False)
    urole = db.Column(db.String(50, collation='latin1_general_ci'),
                      nullable=False)
    nome = db.Column(db.String(60, collation='latin1_general_ci'),
                     nullable=False)
    sexo = db.Column(db.String(60, collation='latin1_general_ci'),
                     nullable=False)
    rg = db.Column(db.String(18, collation='latin1_general_ci'),
                   nullable=False)
    cpf = db.Column(db.String(14, collation='latin1_general_ci'),
                    nullable=False)
    profissao = db.Column(db.String(45, collation='latin1_general_ci'),
                          nullable=False)
    estado_civil = db.Column(db.String(45, collation='latin1_general_ci'),
                             nullable=False)
    nascimento = db.Column(db.Date, nullable=False)
    telefone = db.Column(db.String(18, collation='latin1_general_ci'))
    celular = db.Column(db.String(18, collation='latin1_general_ci'),
                        nullable=False)
    oab = db.Column(db.String(30, collation='latin1_general_ci'))
    obs = db.Column(db.Text(collation='latin1_general_ci'))
    data_entrada = db.Column(db.Date, nullable=False)
    data_saida = db.Column(db.Date, nullable=True)
    criado = db.Column(db.DateTime, nullable=False)
    modificado = db.Column(db.DateTime)
    criadopor = db.Column(db.Integer, nullable=False)
    matricula = db.Column(db.String(45, collation='latin1_general_ci'))
    modificadopor = db.Column(db.Integer)
    bolsista = db.Column(db.Boolean, nullable=False)
    tipo_bolsa = db.Column(db.String(50, collation='latin1_general_ci'))
    #TODO: Analisar necessidade de separar dia/horário de atendimento
    #dia_atendimento     = db.Column(db.String(255, collation = 'latin1_general_ci')) #!!!
    horario_atendimento = db.Column(
        db.String(30, collation='latin1_general_ci'))  #!!!
    suplente = db.Column(db.String(30, collation='latin1_general_ci'))
    #TODO: Ver qual é o Input de Ferias se é data ou só um status
    ferias = db.Column(db.String(150, collation='latin1_general_ci'))
    status = db.Column(db.Boolean, nullable=False)

    cert_atuacao_DAJ = db.Column(db.String(3, collation='latin1_general_ci'),
                                 nullable=False,
                                 default="nao")
    inicio_bolsa = db.Column(db.DateTime)
    fim_bolsa = db.Column(db.DateTime)
    endereco_id = db.Column(db.Integer, db.ForeignKey("enderecos.id"))
    endereco = db.relationship("Endereco", lazy="joined")

    def setSenha(self, senha):
        self.senha = self.bcrypt.generate_password_hash(senha).decode('utf-8')

    def checa_senha(self, senha):
        return self.bcrypt.check_password_hash(self.senha, senha)

    def atualizaCamposModificao(self, modificadoPor):
        self.modificado = datetime.now()
        self.modificadopor = modificadoPor

    def setCamposBolsista(self, bolsista, tipo_bolsa, inicio_bolsa, fim_bolsa):
        self.bolsista = bolsista
        if self.bolsista == True:
            self.inicio_bolsa = inicio_bolsa
            self.fim_bolsa = fim_bolsa
            self.tipo_bolsa = tipo_bolsa
        else:
            self.inicio_bolsa = null()
            self.fim_bolsa = null()
            self.tipo_bolsa = null()
Esempio n. 5
0
class Atendido(db.Model):

    __tablename__ = 'atendidos'

    id = db.Column(db.Integer, primary_key=True)
    orientacoesJuridicas = db.relationship(
        "OrientacaoJuridica", secondary="atendido_xOrientacaoJuridica")
    casos = db.relationship("Caso",
                            secondary=associacao_casos_atendidos,
                            back_populates='clientes')

    #Dados básicos
    nome = db.Column(db.String(80, collation='latin1_general_ci'),
                     nullable=False)
    data_nascimento = db.Column(db.Date, nullable=False)
    cpf = db.Column(db.String(14, collation='latin1_general_ci'),
                    nullable=False)
    cnpj = db.Column(db.String(18, collation='latin1_general_ci'))
    endereco_id = db.Column(db.Integer, db.ForeignKey("enderecos.id"))
    endereco = db.relationship("Endereco", lazy="joined")
    telefone = db.Column(db.String(18, collation='latin1_general_ci'))
    celular = db.Column(db.String(18, collation='latin1_general_ci'),
                        nullable=False)
    email = db.Column(db.String(80, collation='latin1_general_ci'),
                      unique=True,
                      nullable=False)
    estado_civil = db.Column(db.String(80, collation='latin1_general_ci'),
                             nullable=False)

    #antiga Área_demanda
    area_juridica = db.Column(db.String(80, collation='latin1_general_ci'),
                              nullable=False)
    como_conheceu = db.Column(db.String(80, collation='latin1_general_ci'),
                              nullable=False)
    indicacao_orgao = db.Column(db.String(80, collation='latin1_general_ci'))
    procurou_outro_local = db.Column(db.String(80,
                                               collation='latin1_general_ci'),
                                     nullable=False)
    procurou_qual_local = db.Column(
        db.String(80, collation='latin1_general_ci'))
    obs = db.Column(db.Text(collation='latin1_general_ci'))
    pj_constituida = db.Column(db.String(80, collation='latin1_general_ci'),
                               nullable=False)
    repres_legal = db.Column(db.Boolean)
    nome_repres_legal = db.Column(db.String(80, collation='latin1_general_ci'))
    cpf_repres_legal = db.Column(db.String(14, collation='latin1_general_ci'))
    contato_repres_legal = db.Column(
        db.String(18, collation='latin1_general_ci'))
    rg_repres_legal = db.Column(db.String(50, collation='latin1_general_ci'))
    nascimento_repres_legal = db.Column(db.Date)
    pretende_constituir_pj = db.Column(
        db.String(80, collation='latin1_general_ci'))
    status = db.Column(db.Integer, nullable=False)

    def setIndicacao_orgao(self, indicacao_orgao, como_conheceu):
        if como_conheceu == como_conheceu_daj['ORGAOSPUBLICOS'][0]:
            self.indicacao_orgao = indicacao_orgao
        else:
            self.indicacao_orgao = null()

    def setCnpj(self, pj_constituida, cnpj, repres_legal):
        if pj_constituida:
            self.cnpj = cnpj
            self.repres_legal = repres_legal
        else:
            self.cnpj = null()
            self.repres_legal = null()

    def setRepres_legal(self, repres_legal, pj_constituida, nome_repres_legal,
                        cpf_repres_legal, contato_repres_legal,
                        rg_repres_legal, nascimento_repres_legal):
        if (repres_legal == False) and pj_constituida:
            self.nome_repres_legal = nome_repres_legal
            self.cpf_repres_legal = cpf_repres_legal
            self.contato_repres_legal = contato_repres_legal
            self.rg_repres_legal = rg_repres_legal
            self.nascimento_repres_legal = nascimento_repres_legal
        else:
            self.nome_repres_legal = null()
            self.cpf_repres_legal = null()
            self.contato_repres_legal = null()
            self.rg_repres_legal = null()
            self.nascimento_repres_legal = null()

    def setProcurou_qual_local(self, procurou_outro_local,
                               procurou_qual_local):
        if procurou_outro_local:
            self.procurou_qual_local = procurou_qual_local
        else:
            self.procurou_qual_local = null()

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

    def __repr__(self):
        return f"Nome:{self.nome}"