Ejemplo n.º 1
0
def delete_contact(request):
    if request.method == 'POST':
        id = request.POST['data[FIELDS][ID]']
        conexao = funcoes.conectar('Tupan', 'l1gu3scPT', 'Estmonial!Uhh663913Ty')
        cursor = conexao.cursor()

        cursor.execute(f"DELETE FROM CONTACT WHERE ID={id}")

        conexao.commit()
        conexao.close()
        return render(request, 'get.html')
Ejemplo n.º 2
0
def get_deal(request):
    if request.method == 'POST':
        id = request.POST['data[FIELDS][ID]']
        obj = funcoes.consumir_api(f'https://tupan.bitrix24.com/rest/1/xnyq2k0ybltcum07/crm.deal.get?ID={id}')
        conexao = funcoes.conectar('Tupan', 'l1gu3scPT', 'Estmonial!Uhh663913Ty')
        cursor = conexao.cursor()

        cursor.execute(f"SELECT count(*) FROM DEAL WHERE ID={obj['result']['ID']};")
        linhas = cursor.fetchall()
        if linhas[0][0] == 0:
            cursor.execute(funcoes.inserir_deals(obj['result']))

        else:
            cursor.execute(funcoes.atualizar_deals(obj['result']))

        conexao.commit()
        conexao.close()
        return render(request, 'get.html')
Ejemplo n.º 3
0
def deals():
    obj = funcoes.consumir_api(
        "https://staffmobi.bitrix24.com/rest/1/a69xicp1xnmi8ope/crm.deal.list")
    conexao = funcoes.conectar('bitrix', 'root', 'Luigi3107')
    cursor = conexao.cursor()

    for a in obj['result']:
        cursor.execute(f"SELECT ID FROM deals;")
        tlinhas = cursor.rowcount
        if tlinhas > len(obj['result']):
            cursor.execute(funcoes.deletar('deals'))

        cursor.execute(f"SELECT count(*) FROM deals WHERE ID={a['ID']};")
        linhas = cursor.fetchall()
        if linhas[0][0] == 0:
            cursor.execute(funcoes.inserir_deals(a))

        else:
            cursor.execute(funcoes.atualizar_deals(a))

    conexao.commit()
    conexao.close()
Ejemplo n.º 4
0
def deals(request):
    obj = funcoes.consumir_api("https://staffmobi.bitrix24.com/rest/1/a69xicp1xnmi8ope/crm.deal.list")
    conexao = funcoes.conectar('testeluigi', 'l1gu3scPT', 'Estmonial!Uhh663913Ty')
    cursor = conexao.cursor()

    for a in obj['result']:
        cursor.execute(f"SELECT ID FROM deals;")
        tlinhas = cursor.rowcount
        if tlinhas > len(obj['result']):
            cursor.execute(funcoes.deletar('deals'))

        cursor.execute(f"SELECT count(*) FROM deals WHERE ID={a['ID']};")
        linhas = cursor.fetchall()
        if linhas[0][0] == 0:
            cursor.execute(funcoes.inserir_deals(a))

        else:
            cursor.execute(funcoes.atualizar_deals(a))

    conexao.commit()
    conexao.close()
    return render(request, 'deals.html')
Ejemplo n.º 5
0
def ajustes(request):
    obj1 = funcoes.consumir_api('https://tupan.bitrix24.com/rest/1/xnyq2k0ybltcum07/crm.status.list')
    conexao = funcoes.conectar('Tupan', 'l1gu3scPT', 'Estmonial!Uhh663913Ty')
    cursor = conexao.cursor()

    cursor.execute("DELETE FROM ajustes")
    cursor.execute("DELETE FROM pipeline")

    x = 0
    while x < len(obj1['result']):
        tipo = obj1['result'][x]['ENTITY_ID']
        original = obj1['result'][x]['STATUS_ID']
        final = obj1['result'][x]['NAME']

        cursor.execute("INSERT INTO ajustes (tipo, original, final) "
                       f"VALUES ('{tipo}', '{original}', '{final}')")
        x+=1

    print("estou atualizando ajustes")

    obj2 = funcoes.consumir_api('https://tupan.bitrix24.com/rest/1/xnyq2k0ybltcum07/crm.dealcategory.list')
    x = 0
    while x < len(obj2['result']):
        id = obj2['result'][x]['ID']
        nome = obj2['result'][x]['NAME']

        cursor.execute("INSERT INTO pipeline (id, nome) "
                       f"VALUES ('{id}', '{nome}')")

        x += 1
    print('estou atualizando ajustes')

    conexao.commit()
    conexao.close()

    return render(request, 'get.html')