Beispiel #1
0
def message():
    h = HaysHours()
    h.set_db(p)
    lastHourSaved = h.getLastSaved()
    if len(lastHourSaved) > 0:
        return render_template("form.html",
                               lastHourSaved=lastHourSaved,
                               stateful_type=stateful_type)
    else:
        return render_template("form.html", stateful_type=stateful_type)
Beispiel #2
0
 def testSaveOneDate_andLastEmpty(self):
     """Should return the pre-last non-empty"""
     h = HaysHours()
     h.set_db(self.p)
     endHour = h.getEnd("6.3")
     h.getEnd("")
     lastHourSaved = h.getLastSaved()
     self.assertEqual(endHour, lastHourSaved)
 def testSaveOneDate_andLastEmpty(self):
     '''Should return the pre-last non-empty'''
     h = HaysHours()
     h.set_db(self.p)
     endHour = h.getEnd('6.3')
     h.getEnd('')
     lastHourSaved = h.getLastSaved()
     self.assertEqual(endHour, lastHourSaved)
Beispiel #4
0
def calc():
    if request.method == "POST":
        req = request.form
        h = HaysHours()
        h.set_db(p)
        lastHourSaved = h.getLastSaved()
        elapsed = req.get("elapsed")
        endHour = h.getEnd(elapsed)
        if len(elapsed) == 0:
            err_msg = "No end-time because no elapsed time given."
            return render_template("form.html",
                                   err_msg=err_msg,
                                   stateful_type=stateful_type)
        if lastHourSaved:
            return render_template(
                "form.html",
                endHour=endHour,
                elapsed=elapsed,
                lastHourSaved=lastHourSaved,
                stateful_type=stateful_type,
            )
        else:
            return render_template(
                "form.html",
                endHour=endHour,
                elapsed=elapsed,
                stateful_type=stateful_type,
            )
    else:
        lastHourSaved = p.readLast()
        if lastHourSaved:
            return render_template("form.html",
                                   lastHourSaved=lastHourSaved,
                                   stateful_type=stateful_type)
        else:
            return render_template("form.html", stateful_type=stateful_type)
Beispiel #5
0
 def testEmptySring(self):
     h = HaysHours()
     endHour = h.getEnd('')
     self.assertEqual(endHour, '')
Beispiel #6
0
 def testGetEndHour6_3(self):
     h = HaysHours()
     endHour = h.getEnd('6.3')
     self.assertEqual(endHour, "14:03:00")
Beispiel #7
0
 def testGetEndHour8(self):
     h = HaysHours()
     endHour = h.getEnd('8')
     self.assertEqual(endHour, "16:00:00")
Beispiel #8
0
 def testGetEndHour10_5(self):
     h = HaysHours()
     endHour = h.getEnd('10.5')
     self.assertEqual(endHour, "19:00:00")
Beispiel #9
0
 def testGetEndHour9_2(self):
     h = HaysHours()
     endHour = h.getEnd('9.2')
     self.assertEqual(endHour, "17:42:00")
Beispiel #10
0
 def testGetEndHour7_2(self):
     h = HaysHours()
     endHour = h.getEnd('7.2')
     self.assertEqual(endHour, "15:12:00")
Beispiel #11
0
 def testGetEndHour8_6(self):
     h = HaysHours()
     endHour = h.getEnd('8.6')
     self.assertEqual(endHour, "17:06:00")
Beispiel #12
0
 def testGetEndHour8_4(self):
     h = HaysHours()
     endHour = h.getEnd('8.4')
     self.assertEqual(endHour, "16:24:00")
Beispiel #13
0
def end_hour(elapsed):
    h = HaysHours()
    h.set_db(p)
    endHour = h.getEnd(elapsed)
    return endHour
Beispiel #14
0
 def testNoSavedData(self):
     h = HaysHours()
     h.set_db(self.p)
     h.getEnd("")
     lastHourSaved = h.getLastSaved()
     self.assertEqual("", lastHourSaved)
Beispiel #15
0
 def testGetEndHour6_3(self):
     h = HaysHours()
     h.set_db(self.p)
     endHour = h.getEnd("6.3")
     lastHourSaved = h.getLastSaved()
     self.assertEqual(lastHourSaved, endHour)