Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2270505 - No way to print the current time along with current date while generating a report template in Red Hat Satellite 6
Summary: No way to print the current time along with current date while generating a r...
Keywords:
Status: ON_DEV
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Reporting
Version: 6.14.2
Hardware: All
OS: All
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-03-20 15:50 UTC by Sayan Das
Modified: 2024-04-25 19:21 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 37282 0 Normal Ready For Testing Add current time macro 2024-03-20 16:07:03 UTC
Red Hat Issue Tracker SAT-24064 0 None None None 2024-03-20 16:22:20 UTC
Red Hat Issue Tracker SAT-24088 0 None None None 2024-03-21 14:15:14 UTC

Description Sayan Das 2024-03-20 15:50:03 UTC
Description of problem:

For some end-users it might be needed to print the report generation time and date both in the report itself. 

We have a global macro present for printing the date only i.e. current_date . We also have a macro present to format the time if a valid time input present i.e. forman_time but none of them can give me the Full date and time.

The end-result always is just Date or else Date with broken time.


Version-Release number of selected component (if applicable):

Any version of Red Hat Satellite 6 ( Tested on 6.14 )


How reproducible:

100%


Steps to Reproduce:
1. Create a report template by name test and just add these lines

<%= current_date + "\n" -%>
<%= format_time(current_date) + "\n" -%>

2. Preview\Render the template

3. Check in the Help tab for a current_time macro to work with


Actual results:

3. No such macro exists

2. Rendering results:

2024-03-20
2024-03-20  0:00:00 +0530

The time is wrong


Expected results:

There should be a macro present to print the current time as well. 

Additional info:

NA

Comment 1 Sayan Das 2024-03-20 15:51:17 UTC
This fixes the issue:

# git diff
diff --git a/app/services/foreman/renderer/configuration.rb b/app/services/foreman/renderer/configuration.rb
index 4d8b65e..db7744f 100644
--- a/app/services/foreman/renderer/configuration.rb
+++ b/app/services/foreman/renderer/configuration.rb
@@ -58,6 +58,7 @@ module Foreman
         :shell_escape,
         :join_with_line_break,
         :current_date,
+        :current_time,
         :truthy?,
         :falsy?,
         :previous_revision,
diff --git a/app/services/foreman/renderer/scope/macros/helpers.rb b/app/services/foreman/renderer/scope/macros/helpers.rb
index f91f54a..1d4cf58 100644
--- a/app/services/foreman/renderer/scope/macros/helpers.rb
+++ b/app/services/foreman/renderer/scope/macros/helpers.rb
@@ -109,6 +109,15 @@ module Foreman
             Time.zone.today.strftime(format)
           end
 
+          apipie :method, 'Returns current time' do
+            keyword :format, String, desc: 'Format string to format time according to the directives in this string', default: '%T %z'
+            returns String
+            example '<%= current_time %> #=> "21:05:09 +0530"'
+          end
+          def current_time(format: '%T %z')
+            Time.zone.now.strftime(format)
+          end
+
           apipie :method, 'Checks whether a value is truthy or not' do
             optional :value, Object, desc: 'Value to check'
             returns one_of: [true, false], desc: 'Returns true if the value can be considered as truthy, false otherwise'



And now I can use this i.e. 

<%= current_date + ' ' + current_time + "\n" -%>

which will print 

2024-03-20 21:20:56 +0530


I will send a upstream PR about it

Comment 2 Sayan Das 2024-03-20 16:06:52 UTC
Connecting:

Feature #37282: Add current time macro - Foreman
https://projects.theforeman.org/issues/37282

Fixes #37282 - Adding the current_time macro by sayan3296 · Pull Request #10105 · theforeman/foreman
https://github.com/theforeman/foreman/pull/10105

Comment 3 Bryan Kearney 2024-03-21 16:07:38 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/37282 has been resolved.


Note You need to log in before you can comment on or make changes to this bug.