Skip to content

Commit

Permalink
fix rendering of disc. in report
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Nov 19, 2024
1 parent aeb1356 commit f9f4792
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 56 deletions.
38 changes: 0 additions & 38 deletions dojo/db_migrations/0218_system_settings_disclaimer_notif.py

This file was deleted.

37 changes: 27 additions & 10 deletions dojo/db_migrations/0219_system_settings_disclaimer_notif.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# Generated by Django 5.0.8 on 2024-09-12 18:22

from django.db import migrations


def copy_notif_field(apps, schema_editor):
system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get()
if system_settings_model.disclaimer_notifications:
system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications
system_settings_model.save()
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dojo', '0218_system_settings_disclaimer_notif'),
('dojo', '0218_system_settings_enforce_verified_status_and_more'),
]

operations = [
migrations.RunPython(copy_notif_field),
migrations.RenameField(
model_name='system_settings',
old_name='disclaimer',
new_name='disclaimer_notifications',
),
migrations.AlterField(
model_name='system_settings',
name='disclaimer_notifications',
field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on all notifications', max_length=3000, verbose_name='Custom Disclaimer for Notifications'),
),
migrations.AddField(
model_name='system_settings',
name='disclaimer_reports',
field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer on generated reports', max_length=5000, verbose_name='Custom Disclaimer for Reports'),
),
migrations.AddField(
model_name='system_settings',
name='disclaimer_notes',
field=models.TextField(blank=True, default='', help_text='Include this custom disclaimer next to input form for notes', max_length=3000, verbose_name='Custom Disclaimer for Notes'),
),
migrations.AddField(
model_name='system_settings',
name='disclaimer_reports_forced',
field=models.BooleanField(default=False, help_text="Disclaimer will be added to all reports even if user didn't selected 'Include disclaimer'.", verbose_name='Force to add disclaimer reports'),
),
]
21 changes: 21 additions & 0 deletions dojo/db_migrations/0220_system_settings_disclaimer_notif.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.0.8 on 2024-09-12 18:22

from django.db import migrations


def copy_notif_field(apps, schema_editor):
system_settings_model = apps.get_model('dojo', 'System_Settings').objects.get()
if system_settings_model.disclaimer_notifications:
system_settings_model.disclaimer_reports = system_settings_model.disclaimer_notifications
system_settings_model.save()


class Migration(migrations.Migration):

dependencies = [
('dojo', '0219_system_settings_disclaimer_notif'),
]

operations = [
migrations.RunPython(copy_notif_field),
]
9 changes: 8 additions & 1 deletion dojo/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def _set_state(self, request: HttpRequest):
self.host = report_url_resolver(request)
self.selected_widgets = self.get_selected_widgets(request)
self.widgets = list(self.selected_widgets.values())
self.include_disclaimer = get_system_setting("disclaimer_reports_forced", 0)
self.disclaimer = get_system_setting("disclaimer_reports")
if self.include_disclaimer and len(self.disclaimer) == 0:
self.disclaimer = "Please configure in System Settings."

def get_selected_widgets(self, request):
selected_widgets = report_widget_factory(json_data=request.POST["json"], request=request, host=self.host,
Expand Down Expand Up @@ -164,7 +168,10 @@ def get_context(self):
"host": self.host,
"finding_notes": self.finding_notes,
"finding_images": self.finding_images,
"user_id": self.request.user.id}
"user_id": self.request.user.id,
"include_disclaimer": self.include_disclaimer,
"disclaimer": self.disclaimer,
}


def report_findings(request):
Expand Down
6 changes: 6 additions & 0 deletions dojo/templates/dojo/custom_html_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
{% block content %}
{{ block.super }}
<div class="container" id="html_report">
{% if include_disclaimer %}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
{% for widget in widgets %}
{{ widget.get_html }}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/endpoint_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/engagement_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ <h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/finding_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/product_endpoint_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h5>Finding Age</h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/product_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h5>Finding Age</h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/product_type_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h4>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion dojo/templates/dojo/test_pdf_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ <h5>
{% if include_disclaimer%}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; ">
<span style="font-size:16pt; font-family: 'Cambria','times new roman','garamond',serif; color:#ff0000;">Disclaimer</span><br/>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer }}</p>
<p style="font-size:11pt; line-height:10pt; font-family: 'Cambria','times roman',serif;">{{ disclaimer | safe }}</p>
</div>
{% endif %}
<div class="row">
Expand Down

0 comments on commit f9f4792

Please sign in to comment.