diff --git a/dojo/db_migrations/0218_system_settings_disclaimer_notif.py b/dojo/db_migrations/0218_system_settings_disclaimer_notif.py deleted file mode 100644 index 6d966e414a0..00000000000 --- a/dojo/db_migrations/0218_system_settings_disclaimer_notif.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 5.0.8 on 2024-09-12 18:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dojo', '0217_jira_project_enabled'), - ] - - operations = [ - 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'), - ), - ] diff --git a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py index 84aeffe4b03..4f57cad2f13 100644 --- a/dojo/db_migrations/0219_system_settings_disclaimer_notif.py +++ b/dojo/db_migrations/0219_system_settings_disclaimer_notif.py @@ -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'), + ), ] diff --git a/dojo/db_migrations/0220_system_settings_disclaimer_notif.py b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py new file mode 100644 index 00000000000..ceb126d6ab3 --- /dev/null +++ b/dojo/db_migrations/0220_system_settings_disclaimer_notif.py @@ -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), + ] diff --git a/dojo/reports/views.py b/dojo/reports/views.py index 0d6d571c38d..e5ae59a0020 100644 --- a/dojo/reports/views.py +++ b/dojo/reports/views.py @@ -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, @@ -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): diff --git a/dojo/templates/dojo/custom_html_report.html b/dojo/templates/dojo/custom_html_report.html index de89837f747..db7b4e3c070 100644 --- a/dojo/templates/dojo/custom_html_report.html +++ b/dojo/templates/dojo/custom_html_report.html @@ -3,6 +3,12 @@ {% block content %} {{ block.super }}
{{ disclaimer | safe }}
+{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}
{{ disclaimer }}
+{{ disclaimer | safe }}