From 974cf8cbb124e4ee6288c535adbe94d4c617c250 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 1 Oct 2018 22:08:12 +0100 Subject: [PATCH] Update view to separation of prep and cook time --- blocks/ORB/View.pm | 19 +++++++++++++++++-- lang/en/view.lang | 5 ++++- templates/default/view/content.tem | 12 ++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/blocks/ORB/View.pm b/blocks/ORB/View.pm index a7f457c..f954807 100644 --- a/blocks/ORB/View.pm +++ b/blocks/ORB/View.pm @@ -154,14 +154,29 @@ sub _generate_view { pathinfo => [ $recipe -> {"id"} ]), }); + my $preptime = $recipe -> {"preptime"} ? $self -> {"template"} -> humanise_seconds($recipe -> {"preptime"} * 60) + : "{L_VIEW_NOTSET}"; + my $cooktime = $recipe -> {"cooktime"} ? $self -> {"template"} -> humanise_seconds($recipe -> {"cooktime"} * 60) + : "{L_VIEW_NOTSET}"; + + my $totaltime = $recipe -> {"preptime"} + $recipe -> {"cooktime"}; + my $timereq = $totaltime ? $self -> {"template"} -> humanise_seconds($totaltime * 60) + : "{L_VIEW_NOTSET}"; + + # Mark the recipe as viewed + $self -> {"system"} -> {"recipe"} -> set_viewed($rid, $self -> {"session"} -> get_session_userid()); + $self -> log("recipe:view", "Recipe $rid viewed by user ".$self -> {"session"} -> get_session_userid()); + # and build the page itself my $body = $self -> {"template"} -> load_template("view/content.tem", { "%(name)s" => $title, "%(source)s" => $source, "%(yield)s" => $recipe -> {"yield"}, - "%(timereq)s" => $recipe -> {"timereq"}, - "%(timemins)s" => $self -> {"template"} -> humanise_seconds($recipe -> {"timemins"} * 60), + "%(prepinfo)s" => $recipe -> {"prepinfo"}, + "%(preptime)s" => $preptime, + "%(cooktime)s" => $cooktime, + "%(timereq)s" => $timereq, "%(temp)s" => $recipe -> {"temp"} ? $recipe -> {"temp"} : "", "%(temptype)s" => $recipe -> {"temptype"} // "", "%(type)s" => $recipe -> {"type"}, diff --git a/lang/en/view.lang b/lang/en/view.lang index 6d9500a..2d7c6e1 100644 --- a/lang/en/view.lang +++ b/lang/en/view.lang @@ -2,7 +2,10 @@ VIEW_NAME = Name VIEW_SOURCE = Source VIEW_YIELD = Yield VIEW_PREPINFO = Prep info +VIEW_PREPTIME = Prep time +VIEW_COOKTIME = Cook time VIEW_TIMEREQ = Time required +VIEW_NOTSET = Not set VIEW_OVENTEMP = Oven preheat VIEW_TYPE = Type VIEW_STATUS = Status @@ -17,4 +20,4 @@ VIEW_CLONE = Clone VIEW_DELETE = Delete VIEW_ERROR_FATAL = View error -VIEW_ERROR_NORECIPE = No matching recipe found \ No newline at end of file +VIEW_ERROR_NORECIPE = No matching recipe found diff --git a/templates/default/view/content.tem b/templates/default/view/content.tem index 39d71e6..a2e69ec 100644 --- a/templates/default/view/content.tem +++ b/templates/default/view/content.tem @@ -11,11 +11,19 @@
{L_VIEW_PREPINFO}
-
%(timereq)s
+
%(prepinfo)s
+
+
+
{L_VIEW_PREPTIME}
+
%(preptime)s
+
+
+
{L_VIEW_COOKTIME}
+
%(cooktime)s
{L_VIEW_TIMEREQ}
-
%(timemins)s
+
%(timereq)s
{L_VIEW_OVENTEMP}