Skip to content

Commit

Permalink
1.6.1dev: avoid uses of .autoSubmit() when no workflow actions defi…
Browse files Browse the repository at this point in the history
…ned (closes #13621)

git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17753 af82e41b-90c4-0310-8c96-b1721e28e2e2
  • Loading branch information
jomae committed Nov 17, 2023
1 parent eb2c6a1 commit 37df114
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion trac/ticket/templates/ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
var comment_focused = false;
$("#comment").focus(function() { comment_focused = true; })
.blur(function() { comment_focused = false; });
# if not disable_submit:
$("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
var items = $(reply);
// Update ticket box
Expand Down Expand Up @@ -113,8 +114,9 @@
.next("div.comment").html(reply);
comment.toggle(comment.children().length != 0);
}, "#changelog .trac-loading");
# endif

# else:
# elif not disable_submit:
$("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
$('#ticket').replaceWith(reply);
}, "#ticket .trac-loading");
Expand Down
17 changes: 13 additions & 4 deletions trac/ticket/tests/web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def _has_auto_preview(self, req):
in s['attrs']['src']
for s in req.chrome['scripts'])

def _render_fragment(self, req, template, data):
return Chrome(self.env).render_fragment(req, template, data)

def _insert_ticket(self, **kw):
"""Helper for inserting a ticket into the database"""
return insert_ticket(self.env, **kw)
Expand Down Expand Up @@ -702,7 +705,7 @@ def _test_render_time_field(self, format, req, value, expected):
def timefield_text():
self.assertTrue(self.ticket_module.match_request(req))
template, data = self.ticket_module.process_request(req)
content = Chrome(self.env).render_fragment(req, template, data)
content = self._render_fragment(req, template, data)
# select('//td[@headers="h_timefield"') replacement
class TimefieldExtractor(HTMLTransform):
pick_next_text = False
Expand Down Expand Up @@ -870,9 +873,11 @@ def test_newticket_has_auto_preview(self):
req = MockRequest(self.env, method='GET', path_info='/newticket')

self.assertTrue(self.ticket_module.match_request(req))
self.ticket_module.process_request(req)
template, data = self.ticket_module.process_request(req)

self.assertTrue(self._has_auto_preview(req))
content = self._render_fragment(req, template, data)
self.assertIn('.autoSubmit(', content)

def test_newticket_autopreview_disabled_when_no_workflow_actions(self):
"""Newticket autopreview disabled when no workflow actions."""
Expand All @@ -882,11 +887,13 @@ def test_newticket_autopreview_disabled_when_no_workflow_actions(self):
req = MockRequest(self.env, method='GET', path_info='/newticket')

self.assertTrue(self.ticket_module.match_request(req))
data = self.ticket_module.process_request(req)[1]
template, data = self.ticket_module.process_request(req)

self.assertEqual([], data['action_controls'])
self.assertFalse(self._has_auto_preview(req))
self.assertTrue(data['disable_submit'])
content = self._render_fragment(req, template, data)
self.assertNotIn('.autoSubmit(', content)

def test_ticket_autopreview_disabled_when_no_workflow_actions(self):
"""Ticket autopreview disabled when no workflow actions."""
Expand All @@ -898,11 +905,13 @@ def test_ticket_autopreview_disabled_when_no_workflow_actions(self):
req = MockRequest(self.env, method='GET', path_info='/ticket/1')

self.assertTrue(self.ticket_module.match_request(req))
data = self.ticket_module.process_request(req)[1]
template, data = self.ticket_module.process_request(req)

self.assertEqual([], data['action_controls'])
self.assertFalse(self._has_auto_preview(req))
self.assertTrue(data['disable_submit'])
content = self._render_fragment(req, template, data)
self.assertNotIn('.autoSubmit(', content)

def test_new_ticket_without_ticket_edit_cc(self):
"""User without TICKET_EDIT_CC can only add themselves to CC.
Expand Down

0 comments on commit 37df114

Please sign in to comment.