Пример #1
0
def uzivatele():
    db = database.openDatabase().conn()
    if db == False:
        return render_template('uzivatele.html', db=False)
    row = database.openDatabase().selectUser()
    if row:
        return render_template('uzivatele.html', db=True, row=row)
    else:
        return render_template('uzivatele.html', db=True, row=False)
Пример #2
0
def oprava():
    row = database.openDatabase().selectUser()

    if row:
        return render_template('oprava.html', root=True, row=row, filter=True)
    else:
        return render_template('oprava.html', root=True)
Пример #3
0
def filter():
    global row
    row = database.openDatabase().selectUser()
    if row:
        return render_template('filter.html', root=True, row=row, filter=True)
    else:
        return render_template('filter.html', root=True, row=False)
Пример #4
0
def deluser_post():
    name = request.form['jmeno']
    if request.method == 'POST':
        user = database.openDatabase().delUser(name)
        if user:
            return render_template('deluser.html',
                                   root=True,
                                   create=u'uživatel odstraněn')
Пример #5
0
def newuser_post():
    name = request.form['name']
    if request.method == 'POST':
        if len(name) == 0:
            return render_template('newuser.html',
                                   root=True,
                                   create=u'Pole musíte vyplnit')
        user = database.openDatabase().createUser(name)
        if user == False:
            return render_template('newuser.html',
                                   root=True,
                                   create=u'Uživatel již existuje')
        else:
            return render_template('newuser.html',
                                   root=True,
                                   create=u'Uloženo')
Пример #6
0
def createdb_post():
    passwd = request.form['pass']
    secretepass = '******'
    if request.method == 'POST':
        if len(passwd) == 0:
            return render_template('database.html',
                                   root=True,
                                   create=u'Zadejte platné heslo')
        if passwd != secretepass:
            return render_template('database.html',
                                   root=True,
                                   create=u'Zadané heslo je neplatné')

        create = database.openDatabase().createDb('dochazka.db')
        if create:
            return render_template('database.html',
                                   root=True,
                                   create=u'Databáze obnovena')
Пример #7
0
def named_post():
    currentTime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    currentDate = datetime.now().strftime('%Y-%m-%d')
    import prichody
    names = diakritika(name)
    if request.method == 'POST':
        if request.form.get('submit') == u'příchod':
            stav = 'příchod'
            prichod = prichody.Dochazka()
            prichod.prichod(names, currentTime, stav)
            # database.openDatabase().insertArrive(name,currentTime,stav)
            return render_template('named.html',
                                   root=False,
                                   jmeno=name,
                                   css_time="time",
                                   time=u"Příchod: " + currentTime,
                                   wait="countdown",
                                   odpocet=True)

        elif request.form.get('submit') == 'odchod':
            stav = 'odchod'
            # musíme zjistit zdali uživatel vůbec přišel jinak asi moc odejít nemůže
            row = database.openDatabase().insertLeave(names, currentTime,
                                                      currentDate + '%')
            if row:
                odchod = prichody.Dochazka()
                odchod.odchody(names, currentTime, stav)
                return render_template('named.html',
                                       root=False,
                                       jmeno=name,
                                       css_time="time",
                                       time="Odchod: " + currentTime,
                                       wait="countdown",
                                       odpocet=True)
            else:
                return render_template(
                    'named.html',
                    root=False,
                    jmeno=name,
                    css_time="time",
                    time=u"Není možno odejít před příchodem",
                    wait="countdown",
                    odpocet=False)
Пример #8
0
def Data(od,do):
    import database
    dotaz = database.openDatabase().selectFilter('SELECT prichod,odchod,odpracovano FROM time WHERE prichod BETWEEN :prichod AND :odchod', dict(prichod=od,odchod=do))			
    return dotaz
Пример #9
0
    print
    print "Example:", sys.argv[0],"foreground -r"
    sys.exit(1)


if __name__ == "__main__":
    logger.debug('Software Loading Manager - Initializing')
    pid_file = settings.PID_FILE_DIR + os.path.splitext(os.path.basename(__file__))[0] + '.pid'

    try:  
        opts, args = getopt.getopt(sys.argv[1:], "r")
    except getopt.GetoptError:
        print "Software Loading Manager - Could not parse arguments."
        usage()

    dbstore = database.openDatabase()
    if not dbstore:
        logger.error('Software Loading Manager - Database Error')
        exit(1)

    for o, p in opts:
        if o == "-r":
            logger.debug('Software Loading Manager - Resetting Database')
            database.resetDatabaseSchema(dbstore)
        else:
            print "Unknown option: {} {}".format(o, p)
            usage()
            
    swlm_daemon = SWLMDaemon(dbstore, pid_file, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')
            
    for a in args:
Пример #10
0
 def onStart(self):
     db.openDatabase()
Пример #11
0
    print "Example:", sys.argv[0], "foreground -r"
    sys.exit(1)


if __name__ == "__main__":
    logger.debug('Software Loading Manager - Initializing')
    pid_file = settings.PID_FILE_DIR + os.path.splitext(
        os.path.basename(__file__))[0] + '.pid'

    try:
        opts, args = getopt.getopt(sys.argv[1:], "r")
    except getopt.GetoptError:
        print "Software Loading Manager - Could not parse arguments."
        usage()

    dbstore = database.openDatabase()
    if not dbstore:
        logger.error('Software Loading Manager - Database Error')
        exit(1)

    for o, p in opts:
        if o == "-r":
            logger.debug('Software Loading Manager - Resetting Database')
            database.resetDatabaseSchema(dbstore)
        else:
            print "Unknown option: {} {}".format(o, p)
            usage()

    swlm_daemon = SWLMDaemon(dbstore,
                             pid_file,
                             stdin='/dev/null',
Пример #12
0
def deluser():
    row = database.openDatabase().selectUser()
    if row == False:
        return render_template('deluser.html', root=True, row=False)
    return render_template('deluser.html', root=True, row=row)
Пример #13
0
def post_oprava():
    datum = request.form['date']
    user = request.form['jmeno']
    user = diakritika(user)
    row = database.openDatabase().selectUser()

    zaznamy = database.openDatabase().selectFilter(
        'SELECT id,prichod,odchod FROM time WHERE uzivatel =:user AND prichod like :prichod',
        dict(user=user, prichod=datum + "%"))
    global idZaznamu

    idZaznamu = zaznamy[0][0]

    if validace.Validovat(datum).isEmpty():
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               oznaceni="red",
                               row=row)

    if zaznamy:
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               zaznamy=zaznamy,
                               row=row,
                               od=datum)
    else:
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               zaznamy=False,
                               row=row)

    if request.form.get('opravit') == 'oprava':
        heslo = request.form['heslo']
    prichod = request.form['prichod']
    dchod = request.form['odchod']
    overeni = overeniHesla.OverHeslo(heslo)

    if validace.isEmpty:
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               error="red",
                               row=row,
                               zaznamy=zaznamy,
                               od=datum)

    elif overeni.over():
        import opravaCasu

        update = opravaCasu.OpravaDochazky(prichod, odchod, idZaznamu)
        # hodiny = database.openDatabase().pocetH(idZaznamu)
        update.doRepair()
        update.doRepairCas()
        if len(prichod) == 0 or len(odchod) == 0:
            return render_template('oprava.html',
                                   root=True,
                                   filter=True,
                                   error="red",
                                   row=row,
                                   zaznamy=zaznamy,
                                   od=datum,
                                   update=True,
                                   upd="Neprovedeno")
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               error="red",
                               row=row,
                               zaznamy=zaznamy,
                               od=datum,
                               update=True,
                               upd="Provedeno")
    else:
        return render_template('oprava.html',
                               root=True,
                               filter=True,
                               error="red",
                               row=row,
                               zaznamy=zaznamy,
                               od=datum,
                               update=True,
                               upd=u"Neplatné heslo")
Пример #14
0
def filter_post():
    user = request.form['jmeno']
    user = diakritika(user)
    od = request.form['from']
    do = request.form['to']
    if request.method == 'POST':
        if request.form.get('submit') == u'Filtrovat':
            try:
                if len(od) != 0 and len(do) != 0:
                    dotaz = database.openDatabase().selectFilter(
                        'SELECT uzivatel,prichod,odchod,odpracovano FROM time WHERE prichod BETWEEN :prichod AND :odchod AND uzivatel=:user',
                        dict(prichod=od, odchod=do, user=user))
                    return render_template(
                        'filter.html',
                        root=True,
                        row=row,
                        filter=True,
                        more=dotaz,
                        celkem=database.openDatabase().celkem(dotaz),
                        od=od,
                        do=do,
                        selected=user)

                elif len(od) != 0:
                    dotaz = database.openDatabase().selectFilter(
                        'SELECT uzivatel,prichod,odchod,odpracovano FROM time WHERE prichod LIKE :prichod AND uzivatel=:user',
                        dict(prichod=od + '%', user=user))
                    return render_template(
                        'filter.html',
                        root=True,
                        row=row,
                        filter=True,
                        more=dotaz,
                        celkem=database.openDatabase().celkem(dotaz))
                elif len(do) != 0:
                    dotaz = database.openDatabase().selectFilter(
                        'SELECT uzivatel,prichod,odchod,odpracovano FROM time WHERE odchod LIKE :odchod AND uzivatel=:user',
                        dict(odchod=do + '%', user=user))
                    return render_template(
                        'filter.html',
                        root=True,
                        row=row,
                        filter=True,
                        more=dotaz,
                        celkem=database.openDatabase().celkem(dotaz))
                else:
                    dotaz = database.openDatabase().selectFilter(
                        'SELECT uzivatel,prichod,odchod,odpracovano FROM time WHERE uzivatel=:user',
                        dict(user=user))
                    return render_template(
                        'filter.html',
                        root=True,
                        row=row,
                        filter=True,
                        more=dotaz,
                        celkem=database.openDatabase().celkem(dotaz))
            except NameError:
                redirect('/filter')

        if request.form.get('submit') == 'Exportovat':
            return pdf.pdf(user, od, do)
Пример #15
0
def prehled():
    row = database.openDatabase().selectPristupy()
    if row:
        return render_template('pristup.html', root=True, row=row)
    else:
        return render_template('pristup.html', root=True, row=False)