Exemple #1
0
def job_close(request, index):

    # Select prodrptdb db located in views_db
    db, cursor = db_set(request)

    sql = "SELECT whoisonit FROM pr_downtime1 where idnumber='%s'" % (index)
    cursor.execute(sql)
    tmp = cursor.fetchall()
    tmp2 = tmp[0]

    try:
        request.session["tech_comment"]
    except:
        request.session["tech_comment"] = ""

    if request.POST:

        # take comment into tx and ensure no "" exist.  If they do change them to ''

        tx = request.POST.get("comment")
        tx = ' ' + tx
        if (tx.find('"')) > 0:
            #request.session["test_comment"] = tx
            #return out(request)
            ty = list(tx)
            ta = tx.find('"')
            tb = tx.rfind('"')
            ty[ta] = "'"
            ty[tb] = "'"
            tc = "".join(ty)
        else:
            tc = tx
        request.session["tech_comment"] = tc
        t = datetime.datetime.now()

        # Select prodrptdb db located in views_db
        db, cur = db_set(request)

        sql = ('update pr_downtime1 SET remedy="%s" WHERE idnumber="%s"' %
               (tc, index))
        cur.execute(sql)
        db.commit()
        db.close()

        db, cur = db_set(request)
        tql = (
            'update pr_downtime1 SET completedtime="%s" WHERE idnumber="%s"' %
            (t, index))
        cur.execute(tql)
        db.commit()
        db.close()

        return tech(request)

    else:
        form = tech_closeForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render(request, 'tech_close.html', args)
Exemple #2
0
def job_pass(request, index):

    db, cursor = db_set(request)
    sql = "SELECT whoisonit FROM pr_downtime1 where idnumber='%s'" % (index)
    cursor.execute(sql)
    tmp = cursor.fetchall()
    tmp2 = tmp[0]
    db.close()
    try:
        request.session["tech_comment"]
    except:
        request.session["tech_comment"] = ""

    if request.POST:

        tc = request.POST.get("comment")
        request.session["tech_comment"] = tc
        tp = request.POST.get("pass")
        request.session["tech_pass"] = tp
        t = datetime.datetime.now()

        # Select prodrptdb db located in views_db
        db, cur = db_set(request)

        sql = ('update pr_downtime1 SET remedy="%s" WHERE idnumber="%s"' %
               (tc, index))
        cur.execute(sql)
        db.commit()
        db.close()

        db, cur = db_set(request)
        tql = ('update pr_downtime1 SET whoisonit="%s" WHERE idnumber="%s"' %
               (tp, index))
        cur.execute(tql)
        db.commit()
        db.close()

        return tech(request)

    else:
        form = tech_closeForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render(request, 'tech_pass.html', args)