more format for the table plus supress links when no database saved

This commit is contained in:
Brian Read 2024-07-01 08:54:19 +01:00
parent ae0e133918
commit 4997bbffa2
2 changed files with 28 additions and 9 deletions

View File

@ -60,12 +60,27 @@
<td tal:condition="repeat.row.index == 25" tal:attributes="class python:'col-percent'" tal:content="'PERCENT'">Percent</td> <td tal:condition="repeat.row.index == 25" tal:attributes="class python:'col-percent'" tal:content="'PERCENT'">Percent</td>
<td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td> <td tal:condition="repeat.row.index < 24" tal:content="string:${reporting_date}, ${repeat.row.index}">Hour</td>
<td tal:repeat="cell row" tal:attributes="class python: 'col-' + str(repeat.cell.index)"> <td tal:repeat="cell row" tal:attributes="class python: 'col-' + str(repeat.cell.index)">
<!-- Exclude the PERCENT column from generating links and apply the logic to rows 0 to 23 --> <!-- Check if 'nolinks' is true. If not, generate links for rows 0 to 23 except 'PERCENT' column -->
<tal:condition tal:condition="repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16"> <tal:case tal:condition="not: nolinks">
<a tal:attributes="href string:./showSummaryLogs.php?hour=${repeat.row.index}" tal:content="cell">Cell</a> <tal:case tal:condition="repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16">
</tal:condition> <a tal:attributes="href string:./showSummaryLogs.php?hour=${repeat.row.index}">
<!-- For PERCENT column or other rows, just display the cell content --> <!-- Check if cell value is zero and print "-" -->
<tal:condition tal:condition="not (repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16)" tal:content="cell">Cell</tal:condition> <tal:case tal:condition="cell != 0" tal:content="cell">Cell</tal:case>
<tal:case tal:condition="cell == 0" tal:content="'-'">-</tal:case>
</a>
</tal:case>
<!-- For 'PERCENT' column or other rows, just display the cell content -->
<tal:case tal:condition="not (repeat.row.index >= 0 and repeat.row.index < 24 and repeat.cell.index != 16)">
<!-- Check if cell value is zero and print "-" -->
<tal:case tal:condition="cell != 0" tal:content="cell">Cell</tal:case>
<tal:case tal:condition="cell == 0" tal:content="'-'">-</tal:case>
</tal:case>
</tal:case>
<tal:case tal:condition="nolinks">
<!-- Display cell content without link if 'nolinks' is true -->
<tal:case tal:condition="cell != 0" tal:content="cell">Cell</tal:case>
<tal:case tal:condition="cell == 0" tal:content="'-'">-</tal:case>
</tal:case>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -777,6 +777,7 @@ if __name__ == "__main__":
print(f"Unable to connect to {DBName} on {DBHost} port {DBPort} error ({e}) ") print(f"Unable to connect to {DBName} on {DBHost} port {DBPort} error ({e}) ")
saveData = False saveData = False
nolinks = not saveData
# Not sure we need these... # Not sure we need these...
# if (ConfigDB,"qpsmtpd","RHSBL").lower() == 'enabled': # if (ConfigDB,"qpsmtpd","RHSBL").lower() == 'enabled':
# RBLList = get_value(ConfigDB,"qpsmtpd","RBLList") # RBLList = get_value(ConfigDB,"qpsmtpd","RBLList")
@ -1120,7 +1121,10 @@ if __name__ == "__main__":
template = PageTemplate(template_content) template = PageTemplate(template_content)
# Render the template with the 2D array data and column headers # Render the template with the 2D array data and column headers
try: try:
rendered_html = template(array_2d=columnCounts_2d, column_headers=columnHeaders, reporting_date=analysis_date, title=hello_string, version=version_string) rendered_html = template(array_2d=columnCounts_2d, column_headers=columnHeaders,
reporting_date=analysis_date, title=hello_string,
version=version_string,
nolinks=nolinks)
except Exception as e: except Exception as e:
print(f"Chameleon template Exception {e}") print(f"Chameleon template Exception {e}")
except Exception as e: except Exception as e: