Skip to content

Commit

Permalink
Add disclaimer_notes to form_fields.html
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Oct 18, 2024
1 parent a726115 commit c9a2893
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
('dojo', '0215_webhooks_notifications'),
('dojo', '0217_jira_project_enabled'),
]

operations = [
Expand Down
21 changes: 21 additions & 0 deletions dojo/db_migrations/0219_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', '0218_system_settings_disclaimer_notif'),
]

operations = [
migrations.RunPython(copy_notif_field),
]
23 changes: 14 additions & 9 deletions dojo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ class RiskAcceptanceForm(EditRiskAcceptanceForm):
help_text=("Active, verified findings listed, please select to add findings."))
notes = forms.CharField(required=False, max_length=2400,
widget=forms.Textarea,
label="Notes")
label="Notes") # TODO: here as well?

class Meta:
model = Risk_Acceptance
Expand Down Expand Up @@ -1545,7 +1545,7 @@ class FindingBulkUpdateForm(forms.ModelForm):
# unlink_from_jira = forms.BooleanField(required=False)
push_to_github = forms.BooleanField(required=False)
tags = TagField(required=False, autocomplete_tags=Finding.tags.tag_model.objects.all().order_by("name"))
notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"}))
notes = forms.CharField(required=False, max_length=1024, widget=forms.TextInput(attrs={"class": "form-control"})) # TODO: Here as well?

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -1689,12 +1689,17 @@ class Meta:

class NoteForm(forms.ModelForm):
entry = forms.CharField(max_length=2400, widget=forms.Textarea(attrs={"rows": 4, "cols": 15}),
label="Notes:")
label="Notes:") # TODO: Here

class Meta:
model = Notes
fields = ["entry", "private"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if disclaimer := get_system_setting("disclaimer_notes"):
self.disclaimer = disclaimer.strip()


class TypedNoteForm(NoteForm):

Expand Down Expand Up @@ -1723,7 +1728,7 @@ class CloseFindingForm(forms.ModelForm):
widget=forms.Textarea, label="Notes:",
error_messages={"required": ("The reason for closing a finding is "
"required, please use the text area "
"below to provide documentation.")})
"below to provide documentation.")}) # TODO: here as well

mitigated = forms.DateField(required=False, help_text="Date and time when the flaw has been fixed", widget=forms.TextInput(attrs={"class": "datepicker", "autocomplete": "off"}))
mitigated_by = forms.ModelChoiceField(required=False, queryset=Dojo_User.objects.none())
Expand Down Expand Up @@ -1792,7 +1797,7 @@ class DefectFindingForm(forms.ModelForm):
widget=forms.Textarea, label="Notes:",
error_messages={"required": ("The reason for closing a finding is "
"required, please use the text area "
"below to provide documentation.")})
"below to provide documentation.")}) # TODO: Here as well

class Meta:
model = Notes
Expand All @@ -1806,7 +1811,7 @@ class ClearFindingReviewForm(forms.ModelForm):
widget=forms.Textarea, label="Notes:",
error_messages={"required": ("The reason for clearing a review is "
"required, please use the text area "
"below to provide documentation.")})
"below to provide documentation.")}) # TODO: here as well?

class Meta:
model = Finding
Expand All @@ -1826,7 +1831,7 @@ class ReviewFindingForm(forms.Form):
widget=forms.Textarea, label="Notes:",
error_messages={"required": ("The reason for requesting a review is "
"required, please use the text area "
"below to provide documentation.")})
"below to provide documentation.")}) # TODO: here as well?
allow_all_reviewers = forms.BooleanField(
required=False,
label="Allow All Eligible Reviewers",
Expand Down Expand Up @@ -2293,7 +2298,7 @@ def __init__(self, *args, **kwargs):
if get_system_setting("disclaimer_reports_forced"):
self.fields["include_disclaimer"].disabled = True
self.fields["include_disclaimer"].initial = "1" # represents yes
self.fields["include_disclaimer"].help_text="Administrator of the system enforced placement of disclaimer in all reports. You are not able exclude disclaimer from this report."
self.fields["include_disclaimer"].help_text = "Administrator of the system enforced placement of disclaimer in all reports. You are not able exclude disclaimer from this report."


class CustomReportOptionsForm(forms.Form):
Expand Down Expand Up @@ -2721,7 +2726,7 @@ class Meta:
class EngagementPresetsForm(forms.ModelForm):

notes = forms.CharField(widget=forms.Textarea(attrs={}),
required=False, help_text="Description of what needs to be tested or setting up environment for testing")
required=False, help_text="Description of what needs to be tested or setting up environment for testing") # TODO: here as well?

scope = forms.CharField(widget=forms.Textarea(attrs={}),
required=False, help_text="Scope of Engagement testing, IP's/Resources/URL's)")
Expand Down
7 changes: 7 additions & 0 deletions dojo/templates/dojo/form_fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
{{ field }}
{% endfor %}

{% if form.disclaimer %}
<div style="background-color:#DADCE2; border:1px #003333; padding:.8em; margin:.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;">{{ form.disclaimer }}</p>
</div>
{% endif %}

{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}">
{% if field|is_checkbox %}
Expand Down

0 comments on commit c9a2893

Please sign in to comment.