diff --git a/dojo/forms.py b/dojo/forms.py index 1dd52671c4..9869af6270 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -2425,7 +2425,7 @@ def clean(self): return self.cleaned_data -class JIRAForm(BaseJiraForm): +class AdvancedJIRAForm(BaseJiraForm): issue_template_dir = forms.ChoiceField(required=False, choices=JIRA_TEMPLATE_CHOICES, help_text="Choose the folder containing the Django templates used to render the JIRA issue description. These are stored in dojo/templates/issue-trackers. Leave empty to use the default jira_full templates.") @@ -2445,8 +2445,11 @@ class Meta: exclude = [""] -class ExpressJIRAForm(BaseJiraForm): +class JIRAForm(BaseJiraForm): issue_key = forms.CharField(required=True, help_text="A valid issue ID is required to gather the necessary information.") + issue_template_dir = forms.ChoiceField(required=False, + choices=JIRA_TEMPLATE_CHOICES, + help_text="Choose the folder containing the Django templates used to render the JIRA issue description. These are stored in dojo/templates/issue-trackers. Leave empty to use the default jira_full templates.") class Meta: model = JIRA_Instance diff --git a/dojo/jira_link/urls.py b/dojo/jira_link/urls.py index 84abc6faef..97295ddea4 100644 --- a/dojo/jira_link/urls.py +++ b/dojo/jira_link/urls.py @@ -8,7 +8,8 @@ re_path(r"^jira/webhook/(?P[\w-]+)$", views.webhook, name="jira_web_hook_secret"), re_path(r"^jira/webhook/", views.webhook, name="jira_web_hook"), re_path(r"^jira/add", views.NewJiraView.as_view(), name="add_jira"), + re_path(r"^jira/advanced", views.AdvancedJiraView.as_view(), name="add_jira_advanced"), re_path(r"^jira/(?P\d+)/edit$", views.EditJiraView.as_view(), name="edit_jira"), re_path(r"^jira/(?P\d+)/delete$", views.DeleteJiraView.as_view(), name="delete_jira"), re_path(r"^jira$", views.ListJiraView.as_view(), name="jira"), - re_path(r"^jira/express", views.ExpressJiraView.as_view(), name="express_jira")] +] diff --git a/dojo/jira_link/views.py b/dojo/jira_link/views.py index 7ab70a1f5a..0461f600de 100644 --- a/dojo/jira_link/views.py +++ b/dojo/jira_link/views.py @@ -22,7 +22,7 @@ from dojo.authorization.authorization import user_has_configuration_permission # Local application/library imports -from dojo.forms import DeleteJIRAInstanceForm, ExpressJIRAForm, JIRAForm +from dojo.forms import AdvancedJIRAForm, DeleteJIRAInstanceForm, JIRAForm from dojo.models import JIRA_Instance, JIRA_Issue, Notes, System_Settings, User from dojo.notifications.helper import create_notification from dojo.utils import add_breadcrumb, add_error_message_to_response, get_setting @@ -285,24 +285,24 @@ def get_custom_field(jira, label): return field -class ExpressJiraView(View): +class NewJiraView(View): def get_template(self): - return "dojo/express_new_jira.html" + return "dojo/new_jira.html" def get_fallback_template(self): - return "dojo/new_jira.html" + return "dojo/new_jira_advanced.html" def get_form_class(self): - return ExpressJIRAForm + return JIRAForm def get_fallback_form_class(self): - return JIRAForm + return AdvancedJIRAForm def get(self, request): if not user_has_configuration_permission(request.user, "dojo.add_jira_instance"): raise PermissionDenied jform = self.get_form_class()() - add_breadcrumb(title="New Jira Configuration (Express)", top_level=False, request=request) + add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) return render(request, self.get_template(), {"jform": jform}) def post(self, request): @@ -391,18 +391,18 @@ def post(self, request): return render(request, self.get_template(), {"jform": jform}) -class NewJiraView(View): +class AdvancedJiraView(View): def get_template(self): - return "dojo/new_jira.html" + return "dojo/new_jira_advanced.html" def get_form_class(self): - return JIRAForm + return AdvancedJIRAForm def get(self, request): if not user_has_configuration_permission(request.user, "dojo.add_jira_instance"): raise PermissionDenied jform = self.get_form_class()() - add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) + add_breadcrumb(title="New Jira Configuration (Advanced)", top_level=False, request=request) return render(request, self.get_template(), {"jform": jform}) def post(self, request): @@ -442,7 +442,7 @@ def get_template(self): return "dojo/edit_jira.html" def get_form_class(self): - return JIRAForm + return AdvancedJIRAForm def get(self, request, jid=None): if not user_has_configuration_permission(request.user, "dojo.change_jira_instance"): diff --git a/dojo/templates/dojo/express_new_jira.html b/dojo/templates/dojo/express_new_jira.html deleted file mode 100644 index 4394c5d6bb..0000000000 --- a/dojo/templates/dojo/express_new_jira.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "base.html"%} -{% block content %} - {{ block.super }} -

Add a JIRA Configuration Express

-
{% csrf_token %} - {% include "dojo/form_fields.html" with form=jform %} -
-
- -
-

- Finding severity mappings and other options can be edited after express configuration is complete. -
-
-
-{% endblock %} diff --git a/dojo/templates/dojo/jira.html b/dojo/templates/dojo/jira.html index a3208648d6..1068cf7c4c 100644 --- a/dojo/templates/dojo/jira.html +++ b/dojo/templates/dojo/jira.html @@ -19,13 +19,13 @@

diff --git a/dojo/templates/dojo/new_jira.html b/dojo/templates/dojo/new_jira.html index 232117681c..6f4cb6e055 100644 --- a/dojo/templates/dojo/new_jira.html +++ b/dojo/templates/dojo/new_jira.html @@ -6,8 +6,11 @@

Add a JIRA Configuration

{% include "dojo/form_fields.html" with form=jform %}
- + +
+

+ Finding severity mappings and other options can be edited after configuration is complete.
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/dojo/templates/dojo/new_jira_advanced.html b/dojo/templates/dojo/new_jira_advanced.html new file mode 100644 index 0000000000..2af3a37c60 --- /dev/null +++ b/dojo/templates/dojo/new_jira_advanced.html @@ -0,0 +1,13 @@ +{% extends "base.html"%} +{% block content %} + {{ block.super }} +

Add a JIRA Configuration (Advanced)

+
{% csrf_token %} + {% include "dojo/form_fields.html" with form=jform %} +
+
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/unittests/test_jira_config_product.py b/unittests/test_jira_config_product.py index ff72f34993..7213a2f5f0 100644 --- a/unittests/test_jira_config_product.py +++ b/unittests/test_jira_config_product.py @@ -49,7 +49,7 @@ def setUp(self): @patch("dojo.jira_link.views.jira_helper.get_jira_connection_raw") def add_jira_instance(self, data, jira_mock): - response = self.client.post(reverse("add_jira"), urlencode(data), content_type="application/x-www-form-urlencoded") + response = self.client.post(reverse("add_jira_advanced"), urlencode(data), content_type="application/x-www-form-urlencoded") # check that storing a new config triggers a login call to JIRA call_1 = call(data["url"], data["username"], data["password"]) call_2 = call(data["url"], data["username"], data["password"])