def new(animal_id): animal = animal_repository.select(animal_id) dh = DateHelper() current_time = dh.print_datetime_local(datetime.datetime.now()) return render_template( "records/new.html", title="New Record", animal=animal, current_time=current_time, )
def total(self, duration): dh = DateHelper() times = dh.list_delta(duration) string = "" if times[0] > 0: string += f"{times[0]} days" if times[1] > 0: if string != "": string += ", " string += f"{times[1]} hrs" if string != "": string += ", " string += f"{times[2]} mins" return string
def setUp(self): self.dh = DateHelper() self.vet = Vet("Mark", "Bridges", 3) self.address = Address("9", "Big Road", "Vatican City", "PO1 1PE") self.owner = Owner("Kevin", "Stevens", self.address, "015825536874", "*****@*****.**") self.animal = Animal( "Fluff", self.dh.make_date("2018-01-04"), "Dog", "Greyhound", self.owner, self.vet, self.dh.make_datetime("2020-08-09 13:52:01"), ) self.now = self.dh.make_datetime("2020-08-10 12:20:52")
def where(self, treatment): dh = DateHelper() now = dh.now() if treatment is None: self.checked_in = False self.location = "" return elif now < treatment.start + treatment.duration: self.checked_in = True self.location = "treatment" return elif now < treatment.start + treatment.duration + treatment.recovery: self.checked_in = True self.location = "recovery" return else: self.checked_in = False self.location = "" return
from flask import Flask, Blueprint, render_template, request, redirect import datetime from models.treatment import Treatment from models.date_helper import DateHelper import repositories.treatment_repository as treatment_repository import repositories.owner_repository as owner_repository import repositories.animal_repository as animal_repository dh = DateHelper() treatment_blueprint = Blueprint("treatments", __name__) # don't need index @treatment_blueprint.route("/treatments/<id>") def show(id): treatment = treatment_repository.select(id) return render_template("treatments/show.html", title="Treatment", treatment=treatment) @treatment_blueprint.route("/treatments/new/<animal_id>") def new(animal_id): animal = animal_repository.select(animal_id) return render_template("treatments/new.html", title="New Treatment", animal=animal)
def print_date(self, which): dh = DateHelper() return getattr(dh, which)(self.date)
def print_recovery(self): dh = DateHelper() recovery_time = self.start + self.duration + self.recovery return dh.print_nice(recovery_time)
def print_duration(self): dh = DateHelper() treatment_time = self.start + self.duration return dh.print_nice(treatment_time)
def print_start(self): dh = DateHelper() start_time = dh.print_nice(self.start) return start_time
def start_treatment(self, time=None): if time is None: dh = DateHelper() self.start = dh.now() else: self.start = time
def print_registered(self, which): dh = DateHelper() return getattr(dh, which)(self.date_registered)
def setUp(self): self.dh = DateHelper() self.date_str = "1999-08-01" self.datetime_str = "1998-05-02 14:08:00" self.date_obj = self.dh.make_date(self.date_str) self.datetime_obj = self.dh.make_datetime(self.datetime_str)