diff --git a/.TRACFREEZE.txt b/.TRACFREEZE.txt
index 157c63d..1fd5966 100644
--- a/.TRACFREEZE.txt
+++ b/.TRACFREEZE.txt
@@ -1,4 +1,4 @@
-# generated by traccheck.py on 2024-04-18 14:36:14 with Trac version 1.6
+# generated by traccheck.py on 2024-10-12 11:43:25 with Trac version 1.6
trac.admin.api.admincommandmanager
trac.admin.console.tracadminhelpmacro
trac.admin.web_ui.adminmodule
@@ -66,7 +66,6 @@ trac.ticket.notification.ticketownersubscriber
trac.ticket.notification.ticketpreviousupdaterssubscriber
trac.ticket.notification.ticketreportersubscriber
trac.ticket.notification.ticketupdatersubscriber
-trac.ticket.query.querymodule
trac.ticket.query.ticketquerymacro
trac.ticket.roadmap.defaultticketgroupstatsprovider
trac.ticket.roadmap.milestonemodule
@@ -106,6 +105,7 @@ tracdjangoplugin.plugins.customtheme
tracdjangoplugin.plugins.customwikimodule
tracdjangoplugin.plugins.githubbrowserwithsvnchangesets
tracdjangoplugin.plugins.plainlogincomponent
+tracdjangoplugin.plugins.renamequerytitlecomponent
tracdjangoplugin.plugins.reservedusernamescomponent
tracdragdrop.web_ui.tracdragdropmodule
tracext.github.githubloginmodule
diff --git a/DjangoPlugin/tracdjangoplugin/plugins.py b/DjangoPlugin/tracdjangoplugin/plugins.py
index 94992f2..1dadb30 100644
--- a/DjangoPlugin/tracdjangoplugin/plugins.py
+++ b/DjangoPlugin/tracdjangoplugin/plugins.py
@@ -6,6 +6,7 @@
from trac.web.api import IRequestFilter, IRequestHandler, RequestDone
from trac.web.auth import LoginModule
from trac.wiki.web_ui import WikiModule
+from trac.ticket.query import QueryModule
from trac.util.html import tag
from tracext.github import GitHubLoginModule, GitHubBrowser
@@ -190,3 +191,15 @@ def force_logout_and_redirect(self, req):
def post_process_request(self, req, template, data, metadata):
return template, data, metadata # required by Trac to exist
+
+
+class RenameQueryTitleComponent(QueryModule):
+ """
+ Change the title of the /query page so that the navmenu entry matches the
+ page's
.
+ """
+
+ def display_html(self, req, query):
+ template_name, context = super().display_html(req, query)
+ context["title"] = "View Tickets"
+ return template_name, context
diff --git a/DjangoPlugin/tracdjangoplugin/tests.py b/DjangoPlugin/tracdjangoplugin/tests.py
index e10cec3..3af6fc1 100644
--- a/DjangoPlugin/tracdjangoplugin/tests.py
+++ b/DjangoPlugin/tracdjangoplugin/tests.py
@@ -12,7 +12,10 @@
ReStructuredTextRenderer, # noqa: needed for RSTWikiTestCase to work
)
from trac.test import EnvironmentStub, MockRequest
+from trac.ticket.web_ui import TicketModule # Imported for side effects
+from trac.ticket.query import QueryModule # Imported for side effects
from trac.web.api import RequestDone
+from trac.web.main import RequestDispatcher
from tracdjangoplugin.middlewares import DjangoDBManagementMiddleware
from tracdjangoplugin.plugins import PlainLoginComponent, ReservedUsernamesComponent
@@ -258,3 +261,65 @@ def test_wiki_can_render_rst(self):
str(output),
'
TEST
',
)
+
+
+class _TracRequestWrapper:
+ """
+ Wrap a Trac request object to make it look like a Django response (so it
+ can be used with assertContains)
+ """
+
+ streaming = False
+ charset = "utf8"
+
+ def __init__(self, request):
+ self._request = request
+
+ @property
+ def status_code(self):
+ status_str, _ = self._request._status.split(" ", 1)
+ return int(status_str)
+
+ @property
+ def content(self):
+ return self._request.response_sent.getvalue()
+
+
+class RenameQueryTitleComponentTestCase(TestCase):
+ def setUp(self):
+ self.env = EnvironmentStub(
+ enable=[
+ "trac.ticket.*",
+ "trac.ticket.query.*",
+ "trac.web.*",
+ "tracdjangoplugin.plugins.renamequerytitlecomponent",
+ ],
+ disable=[
+ "trac.ticket.query.querymodule",
+ ],
+ )
+ self.request_factory = partial(MockRequest, self.env)
+ self.dispatcher = RequestDispatcher(self.env)
+
+ def get_response(self, **kwargs):
+ """
+ Build a request using the given kwargs and return a Django-like
+ response object.
+ """
+ request = self.request_factory(**kwargs)
+ self.assertRaises(RequestDone, self.dispatcher.dispatch, request)
+ return _TracRequestWrapper(request)
+
+ def test_new_title(self):
+ response = self.get_response(path_info="/query")
+
+ self.assertContains(
+ response,
+ 'View Tickets (0 matches)
',
+ html=True,
+ )
+ self.assertNotContains(
+ response,
+ 'Custom Query (0 matches)
',
+ html=True,
+ )
diff --git a/trac-env/conf/trac.ini b/trac-env/conf/trac.ini
index d774d0e..e7622e9 100644
--- a/trac-env/conf/trac.ini
+++ b/trac-env/conf/trac.ini
@@ -13,7 +13,8 @@ wiki_format_messages = enabled
trac.about.* = disabled
trac.admin.web_ui.PluginAdminPanel = disabled
trac.ticket.query.* = enabled
-trac.ticket.query.querymodule = enabled
+# replaced by tracdjangoplugin.plugins.RenameQueryTitleComponent
+trac.ticket.query.querymodule = disabled
trac.ticket.query.ticketquerymacro = enabled
trac.ticket.report.* = disabled
trac.ticket.report.reportmodule = disabled