Skip to content

Commit

Permalink
Fix System Settings Required Fields (Enable Jira Integration) (#8623)
Browse files Browse the repository at this point in the history
* Fix checkbox disappear findings (windows resize)

* fix checkboxes disappear in all project

* fix 500 error when attempting to order tags

* fix flake8 issue

* Fix Bulk edit drop-down bug

* trivy parser Includes causeMetadata in the findings description

* Revert "trivy parser Includes causeMetadata in the findings description"

This reverts commit da493b9.

* fix enable jira integration bugfix

* remove change from PR

* restore model and validate from clean method

---------

Co-authored-by: Felix Hernandez <[email protected]>
  • Loading branch information
FelixHernandez and felixhernandez15 authored Sep 7, 2023
1 parent d4d67c1 commit 5244e38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 11 additions & 0 deletions dojo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,11 +2537,22 @@ class Meta:


class SystemSettingsForm(forms.ModelForm):
jira_webhook_secret = forms.CharField(required=False)

def __init__(self, *args, **kwargs):
super(SystemSettingsForm, self).__init__(*args, **kwargs)
self.fields['default_group_role'].queryset = get_group_member_roles()

def clean(self):
cleaned_data = super().clean()
enable_jira_value = cleaned_data.get('enable_jira')
jira_webhook_secret_value = cleaned_data.get('jira_webhook_secret').strip()

if enable_jira_value and not jira_webhook_secret_value:
self.add_error('jira_webhook_secret', 'This field is required when enable Jira Integration is True')

return cleaned_data

class Meta:
model = System_Settings
exclude = ['product_grade']
Expand Down
4 changes: 1 addition & 3 deletions dojo/system_settings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
import logging
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.urls import reverse
from django.shortcuts import render
from dojo.models import System_Settings, enable_disable_auditlog
from dojo.utils import (add_breadcrumb,
get_celery_worker_status)
from dojo.forms import SystemSettingsForm
from django.conf import settings
from django.http import HttpResponseRedirect

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -79,7 +77,7 @@ def system_settings(request):
messages.SUCCESS,
'Settings saved.',
extra_tags='alert-success')
return HttpResponseRedirect(reverse('system_settings', ))
return render(request, 'dojo/system_settings.html', {'form': form})

else:
# Celery needs to be set with the setting: CELERY_RESULT_BACKEND = 'db+sqlite:///dojo.celeryresults.sqlite'
Expand Down

0 comments on commit 5244e38

Please sign in to comment.