diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 463fe02..b0287f4 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -861,3 +861,6 @@ a.nav-link.btn{ color:#777; border:0; } + + + diff --git a/pagure/templates/new_issue.html b/pagure/templates/new_issue.html index 9245c1e..9b72690 100644 --- a/pagure/templates/new_issue.html +++ b/pagure/templates/new_issue.html @@ -33,131 +33,174 @@ issueid=issueid) }}" method="post" enctype="multipart/form-data"> {% endif %} + {{form.csrf_token}}
+ {% if (g.repo_user and not type) or (g.repo_user and type == 'new') %} +
+

New Issue

+
-
-
- {% if not type or type == 'new' %} - New issue - {% elif type and type == 'edit' %} - Edit issue #{{ issueid }} - {% endif %} -
-
- {{ render_bootstrap_field(form.title, field_description="Gist of your issue") }} + {% else %} +
+ {% if not type or type == 'new' %} +

New Issue

+ {% elif type and type == 'edit' %} +

Edit Issue

+ {% endif %} + {% endif %} +
{% if type == 'edit' %} - {{ render_bootstrap_field(form.status, field_description="bug status") }} + {{ form.status(class_="hidden") }} +
+

+

#{{issue.id}}

{% endif %} - {% if types %} -
- - -
- Ticket type + {{ form.title(class_="form-control", placeholder="Issue Title", required="required")|safe }} + {% if form.title.errors %} + + + {% for error in form.title.errors %} + {{ error }}  + {% endfor %} + + + {% endif %} + {% if type == 'edit' %}
-
{% endif %} - {{ render_bootstrap_field(form.private, field_description="Do you want to keep the issue private?") }} -
- - - Preview - - -
- {% if form.issue_content.errors %} - - - {% for error in form.issue_content.errors %} - {{ error }}  - {% endfor %} - - - {% endif %} -
-
-
-
- Attach file +
+
+
+
+
+
+ {% if types %} + {% if (types | length == 1 and not default) or (types | length > 1)%} +
+ + +
+ {% else %} + {% set notemplates = True %} + {% endif %} + {% else %} + {% set notemplates = True %} + {% endif %} + -

- {% if not type or type == 'new' %} - - {% elif type and type == 'edit' %} - - {% endif %} - - {{ form.csrf_token }} - Markdown Syntax -

+
+
+
+
+ + {% if form.issue_content.errors %} + + + {% for error in form.issue_content.errors %} + {{ error }}  + {% endfor %} + + + {% endif %} +
+
+
+ + +
+
+ +
-
{% if g.repo_user and not type or type == 'new' %}
-
-
+
+
+
Metadata
+
+ +
+ + +
- +
+ {% if repo.priorities %}
- - -
- - {{ render_bootstrap_field(form.priority) }} - {{ render_bootstrap_field(form.milestone) }} + + {{form.priority}} + + {% endif %} -
+ {% if repo.milestones %} +
+ + {{form.milestone}} +
+ {% endif %}
{% endif %}
- - {% if g.authenticated and g.repo_committer and type and type == 'edit' %} -
- - {{ form.csrf_token }} -
- {% endif %} {% endblock %} {% block jscripts %} @@ -221,7 +264,7 @@ $(document).ready(function() { var json_url = '{{ url_for("static", filename="vendor/emojione/emoji_strategy.json") }}'; emoji_complete(json_url, folder); - $("#type").on("change", function() { + $(".issue-template").on("click", function() { if ( !confirm('Do you want to load the new template?')){ return false; } @@ -278,9 +321,9 @@ $(document).ready(function() { $(function() { $( "#preview" ).hide(); + $( "#previewinmarkdown" ).click( function(event, ui) { - if ($( "#previewinmarkdown" ).hasClass("inactive")){ var _text = $( "#issue_content" ).val(); var _url = "{{ url_for('ui_ns.markdown_preview', repo=repo.name, @@ -297,8 +340,8 @@ $(function() { success: function(res) { var preview = emojione.toImage(res); $( "#preview" ).html(preview); - $( "#previewinmarkdown" ).removeClass("inactive"); - $( "#previewinmarkdown" ).addClass("active"); + $( "#previewinmarkdown" ).toggleClass("active"); + $( "#editinmarkdown" ).toggleClass("active"); $( "#issue_content" ).hide(); $( "#preview" ).show(); }, @@ -307,12 +350,15 @@ $(function() { } }); return false; - } else if ($( "#previewinmarkdown" ).hasClass("active")){ - $( "#previewinmarkdown" ).addClass("inactive"); - $( "#previewinmarkdown" ).removeClass("active"); - $( "#issue_content" ).show(); - $( "#preview" ).hide(); - } + } + ); + + $( "#editinmarkdown" ).click( + function(event, ui) { + $( "#editinmarkdown" ).toggleClass("active"); + $( "#previewinmarkdown" ).toggleClass("active"); + $( "#issue_content" ).show(); + $( "#preview" ).hide(); } ); }); diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index 83c6855..3274747 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -67,7 +67,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/new_issue') self.assertEqual(output.status_code, 200) self.assertIn( - '
\n New issue', + 'New Issue', output.get_data(as_text=True)) csrf_token = self.get_csrf(output=output) @@ -80,7 +80,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertEqual(output_text.count( 'This field is required.'), 2) @@ -90,7 +90,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertEqual(output_text.count( 'This field is required.'), 1) @@ -101,7 +101,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertEqual(output_text.count( 'This field is required.'), @@ -164,7 +164,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/new_issue') self.assertEqual(output.status_code, 200) self.assertIn( - '
\n New issue', + '

New Issue

\n', output.get_data(as_text=True)) csrf_token = self.get_csrf() @@ -255,7 +255,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/somenamespace/test3/new_issue') self.assertEqual(output.status_code, 200) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output.get_data(as_text=True)) csrf_token = self.get_csrf() @@ -309,7 +309,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/new_issue') self.assertEqual(output.status_code, 200) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output.get_data(as_text=True)) csrf_token = self.get_csrf() @@ -374,7 +374,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/somenamespace/test3/new_issue') self.assertEqual(output.status_code, 200) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output.get_data(as_text=True)) csrf_token = self.get_csrf() @@ -438,13 +438,13 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertIn( - '', + 'Tags', output_text) self.assertIn( - '', + 'Assignee', output_text) def test_new_issue_metadata_not_user(self): @@ -464,13 +464,13 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertNotIn( - '', + 'Tags', output_text) self.assertNotIn( - '', + 'Assignee', output_text) @patch('pagure.lib.git.update_git', MagicMock(return_value=True)) @@ -498,13 +498,13 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertIn( - '', + 'Tags', output_text) self.assertIn( - '', + 'Assignee', output_text) csrf_token = self.get_csrf(output=output) @@ -568,13 +568,13 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertNotIn( - '', + 'Tags', output_text) self.assertNotIn( - '', + 'Assignee', output_text) csrf_token = self.get_csrf(output=output) @@ -2626,8 +2626,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/issue/1/edit') self.assertEqual(output.status_code, 200) self.assertTrue( - '
\n Edit ' - 'issue #1\n
' in output.get_data(as_text=True)) + 'Edit Issue' in output.get_data(as_text=True)) csrf_token = self.get_csrf(output=output) @@ -2639,14 +2638,9 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n Edit ' - 'issue #1\n
' in output_text) + 'Edit Issue' in output_text) self.assertEqual(output_text.count( - '\n This field is required. \n' - ' '), 1) - self.assertEqual(output_text.count( - '\n Not a valid choice ' - '\n '), 1) + 'This field is required.'), 1) data['status'] = 'Open' data['title'] = 'Test issue #1' @@ -2654,14 +2648,11 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n Edit ' - 'issue #1\n
' in output_text) + 'Edit Issue' in output_text) self.assertEqual(output_text.count( - '\n This field is required. \n' - ' '), 0) + 'This field is required.'), 0) self.assertEqual(output_text.count( - '\n Not a valid choice ' - '\n '), 0) + 'Not a valid choice'), 0) data['csrf_token'] = csrf_token output = self.app.post( @@ -2716,8 +2707,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/issue/1/edit') self.assertEqual(output.status_code, 200) self.assertTrue( - '
\n Edit ' - 'issue #1\n
' in output.get_data(as_text=True)) + 'Edit Issue' in output.get_data(as_text=True)) csrf_token = self.get_csrf(output=output) diff --git a/tests/test_pagure_flask_ui_issues_templates.py b/tests/test_pagure_flask_ui_issues_templates.py index ea1a544..b3e6e3e 100644 --- a/tests/test_pagure_flask_ui_issues_templates.py +++ b/tests/test_pagure_flask_ui_issues_templates.py @@ -145,13 +145,10 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - '
\n New issue', + '

New Issue

\n', output_text) self.assertNotIn( - '', - output_text) - self.assertNotIn( - '', + 'Issue Templates', output_text) self.assertIn( - '', + 'RFE', output_text) self.assertIn( - '', + '2018-bid', output_text) self.assertIn( - '', + 'default', output_text) def test_get_ticket_template_no_csrf(self): diff --git a/tests/test_pagure_flask_ui_priorities.py b/tests/test_pagure_flask_ui_priorities.py index afc55b9..214aeb2 100644 --- a/tests/test_pagure_flask_ui_priorities.py +++ b/tests/test_pagure_flask_ui_priorities.py @@ -55,7 +55,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output_text) csrf_token = output_text.split( @@ -108,7 +108,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output_text) csrf_token = output_text.split( diff --git a/tests/test_pagure_flask_ui_roadmap.py b/tests/test_pagure_flask_ui_roadmap.py index 3f7b387..d7cd731 100644 --- a/tests/test_pagure_flask_ui_roadmap.py +++ b/tests/test_pagure_flask_ui_roadmap.py @@ -55,7 +55,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output_text) csrf_token = output_text.split( @@ -106,7 +106,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output_text) csrf_token = output_text.split( @@ -427,7 +427,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertTrue( - '
\n New issue' + '

New Issue

\n' in output_text) csrf_token = output_text.split(