فهرست منبع

feat: markdown support in report's description

* markdown support in report list and report result pages
* Add notes in the documentation regarding markdown
maxime-gerges-external 4 سال پیش
والد
کامیت
e61b2b1fc5
3فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 6 0
      docs/additional-features/reports.md
  2. 1 1
      netbox/templates/extras/report.html
  3. 1 1
      netbox/templates/extras/report_list.html

+ 6 - 0
docs/additional-features/reports.md

@@ -85,6 +85,9 @@ As you can see, reports are completely customizable. Validation logic can be as
 !!! warning
 !!! warning
     Reports should never alter data: If you find yourself using the `create()`, `save()`, `update()`, or `delete()` methods on objects within reports, stop and re-evaluate what you're trying to accomplish. Note that there are no safeguards against the accidental alteration or destruction of data.
     Reports should never alter data: If you find yourself using the `create()`, `save()`, `update()`, or `delete()` methods on objects within reports, stop and re-evaluate what you're trying to accomplish. Note that there are no safeguards against the accidental alteration or destruction of data.
 
 
+!!! note 
+    The `description`attribute support markdown syntax. You can use markdown to print fency description in the report list page.
+
 The following methods are available to log results within a report:
 The following methods are available to log results within a report:
 
 
 * log(message)
 * log(message)
@@ -95,6 +98,9 @@ The following methods are available to log results within a report:
 
 
 The recording of one or more failure messages will automatically flag a report as failed. It is advised to log a success for each object that is evaluated so that the results will reflect how many objects are being reported on. (The inclusion of a log message is optional for successes.) Messages recorded with `log()` will appear in a report's results but are not associated with a particular object or status.
 The recording of one or more failure messages will automatically flag a report as failed. It is advised to log a success for each object that is evaluated so that the results will reflect how many objects are being reported on. (The inclusion of a log message is optional for successes.) Messages recorded with `log()` will appear in a report's results but are not associated with a particular object or status.
 
 
+!!! note 
+    Every `log_`methods support markdown syntax. Thus you can use markdown in the message and it will be printed as such in the report result.
+
 To perform additional tasks, such as sending an email or calling a webhook, after a report has been run, extend the `post_run()` method. The status of the report is available as `self.failed` and the results object is `self.result`.
 To perform additional tasks, such as sending an email or calling a webhook, after a report has been run, extend the `post_run()` method. The status of the report is available as `self.failed` and the results object is `self.result`.
 
 
 Once you have created a report, it will appear in the reports list. Initially, reports will have no results associated with them. To generate results, run the report.
 Once you have created a report, it will appear in the reports list. Initially, reports will have no results associated with them. To generate results, run the report.

+ 1 - 1
netbox/templates/extras/report.html

@@ -29,7 +29,7 @@
     {% endif %}
     {% endif %}
     <h1 class="title">{{ report.name }}</h1>
     <h1 class="title">{{ report.name }}</h1>
     {% if report.description %}
     {% if report.description %}
-        <p class="lead">{{ report.description }}</p>
+        <p class="lead">{{ report.description|render_markdown }}</p>
     {% endif %}
     {% endif %}
 {% endblock %}
 {% endblock %}
 
 

+ 1 - 1
netbox/templates/extras/report_list.html

@@ -29,7 +29,7 @@
                                     <td>
                                     <td>
                                         {% include 'extras/inc/job_label.html' with result=report.result %}
                                         {% include 'extras/inc/job_label.html' with result=report.result %}
                                     </td>
                                     </td>
-                                    <td>{{ report.description|placeholder }}</td>
+                                    <td class="rendered-markdown">{{ report.description|render_markdown|placeholder }}</td>
                                     <td class="text-right">
                                     <td class="text-right">
                                         {% if report.result %}
                                         {% if report.result %}
                                             <a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created }}</a>
                                             <a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created }}</a>