diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/changelog trac-subcomponents-1.3.1/debian/changelog --- trac-subcomponents-1.2.0+hga86f0413121f/debian/changelog 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/changelog 2018-05-05 23:58:10.000000000 +0000 @@ -1,3 +1,11 @@ +trac-subcomponents (1.3.1-1) unstable; urgency=medium + + * new upstream version + * move repo to salsa.d.o + * bump standards and dh compat + + -- W. Martin Borgert Sat, 05 May 2018 23:58:10 +0000 + trac-subcomponents (1.2.0+hga86f0413121f-4) unstable; urgency=low * Fix UnicodeError exception in Trac query (Closes: #774424). diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/compat trac-subcomponents-1.3.1/debian/compat --- trac-subcomponents-1.2.0+hga86f0413121f/debian/compat 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/compat 2018-05-05 23:56:07.000000000 +0000 @@ -1 +1 @@ -7 +11 diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/control trac-subcomponents-1.3.1/debian/control --- trac-subcomponents-1.2.0+hga86f0413121f/debian/control 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/control 2018-05-05 23:56:48.000000000 +0000 @@ -1,12 +1,12 @@ Source: trac-subcomponents Section: web Priority: optional -Build-Depends: python-all (>= 2.6.6-3~), python-setuptools, debhelper (>= 7.0.50~) +Build-Depends: python-all (>= 2.6.6-3~), python-setuptools, debhelper (>= 11), dh-python Maintainer: Python Applications Packaging Team Uploaders: W. Martin Borgert , Daniel Kahn Gillmor -Standards-Version: 3.9.6 -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/trac-subcomponents.git -Vcs-Git: git://anonscm.debian.org/collab-maint/trac-subcomponents.git +Standards-Version: 4.1.4 +Vcs-Browser: https://salsa.debian.org/python-team/applications/trac-subcomponents +Vcs-Git: https://salsa.debian.org/python-team/applications/trac-subcomponents.git Homepage: http://trac-hacks.org/wiki/SubcomponentsPlugin Package: trac-subcomponents diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/patches/10_fix_unicodeerror.patch trac-subcomponents-1.3.1/debian/patches/10_fix_unicodeerror.patch --- trac-subcomponents-1.2.0+hga86f0413121f/debian/patches/10_fix_unicodeerror.patch 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/patches/10_fix_unicodeerror.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Description: Fixes a UnicodeError exception -Author: W. Martin Borgert -Origin: other, http://trac-hacks.org/ticket/11752#comment:2 -Bug: http://trac-hacks.org/ticket/11752 -Bug-Debian: https://bugs.debian.org/774424 -Last-Update: 2015-01-03 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/subcomponents/web_ui.py -+++ b/subcomponents/web_ui.py -@@ -134,9 +134,8 @@ - stream |= Transformer("//div[@class='field'][1]").after(self._build_renamechildren_field()) - elif req.path_info.startswith('/query'): - # We need to load our script after the initializeFilters() call done by Trac -- html = HTML('') -+ html = tag.script(type='text/javascript', charset='utf-8', -+ src=req.href.chrome('subcomponents/componentselect.js')) - stream |= Transformer('//head').append(html) - return stream - diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/patches/series trac-subcomponents-1.3.1/debian/patches/series --- trac-subcomponents-1.2.0+hga86f0413121f/debian/patches/series 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -10_fix_unicodeerror.patch diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/debian/rules trac-subcomponents-1.3.1/debian/rules --- trac-subcomponents-1.2.0+hga86f0413121f/debian/rules 2015-01-03 00:25:11.000000000 +0000 +++ trac-subcomponents-1.3.1/debian/rules 2018-05-05 23:56:48.000000000 +0000 @@ -1,4 +1,7 @@ #!/usr/bin/make -f +export PYBUILD_NAME=subcomponents +export PYBUILD_SYSTEM=distutils + %: - dh $@ --with python2 --buildsystem=python_distutils + dh $@ --with python2 --buildsystem=pybuild diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/.hg_archival.txt trac-subcomponents-1.3.1/.hg_archival.txt --- trac-subcomponents-1.2.0+hga86f0413121f/.hg_archival.txt 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/.hg_archival.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -repo: af42429a9c52861788a9658c07fd560eebc23ea7 -node: a86f0413121f51f12378922398f199c63227178b -branch: default -latesttag: subcomponents-1.2.0 -latesttagdistance: 2 diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/.hgtags trac-subcomponents-1.3.1/.hgtags --- trac-subcomponents-1.2.0+hga86f0413121f/.hgtags 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/.hgtags 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -e717b06e7a7e37170ba5cd6a20a9b9b9d36c8c8f subcomponents-1.0.0 -198acbdcb18be848b71b383eb5258d5bf5ceffd2 subcomponents-1.1.0 -591c5468817874242ae351f809cbbe565e07572b subcomponents-1.1.1 -fb35c463e72d0b329379bb090ba3e491149028fe subcomponents-1.1.2 -46e3b20788edb6efd57d73988436e33bbad9f400 subcomponents-1.2.0 diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/LICENSE trac-subcomponents-1.3.1/LICENSE --- trac-subcomponents-1.2.0+hga86f0413121f/LICENSE 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/LICENSE 2018-05-05 23:15:54.000000000 +0000 @@ -18,4 +18,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/ReadMe.rst trac-subcomponents-1.3.1/ReadMe.rst --- trac-subcomponents-1.2.0+hga86f0413121f/ReadMe.rst 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/ReadMe.rst 2018-05-05 23:15:54.000000000 +0000 @@ -7,9 +7,9 @@ What is it? ----------- -This plugin alters Trac's behavior so that the interface supports multiple +This plugin alters Trac's behavior so that the interface supports multiple layers of components. In project with lots of components, rearranging these -components into several layers can clear up the list of components. +components into several layers can clear up the list of components. What is it not? --------------- @@ -23,7 +23,7 @@ ------------ To install the module see the TracPlugins page on -http://trac.edgewall.org/wiki/TracPlugins. After activating the plugin in +http://trac.edgewall.org/wiki/TracPlugins. After activating the plugin in the configuration file or through the plugins page, it will be activated without any further configuration. @@ -38,4 +38,4 @@ * ``Web/Backend`` Then the user interface will show the ``Frontend`` and ``Backend`` as a -subcomponent of the ``Web`` component. \ No newline at end of file +subcomponent of the ``Web`` component. diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/setup.py trac-subcomponents-1.3.1/setup.py --- trac-subcomponents-1.2.0+hga86f0413121f/setup.py 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/setup.py 2018-05-05 23:15:54.000000000 +0000 @@ -1,28 +1,30 @@ #!/usr/bin/env python - - # - # Copyright 2009, Niels Sascha Reedijk - # All rights reserved. Distributed under the terms of the MIT License. - # +# -*- coding: utf-8 -*- +# +# Copyright 2009, Niels Sascha Reedijk +# All rights reserved. Distributed under the terms of the MIT License. +# from setuptools import setup setup( - name = 'TracSubcomponents', - version = '1.2.0', - packages = ['subcomponents'], - package_data = { 'subcomponents': ['htdocs/*.js'] }, - - author = 'Niels Sascha Reedijk', - author_email = 'niels.reedijk@gmail.com', - description = 'Provides support for subcomponents in the interface.', - license = 'MIT', - keywords = 'trac plugin ticket query components', - url = 'http://hg.haiku-os.org/trac-subcomponents', - classifiers = [ + name='TracSubcomponents', + version='1.3.1', + packages=['subcomponents'], + package_data={'subcomponents': [ + 'htdocs/*.js', + 'templates/*.html', + ]}, + author='Niels Sascha Reedijk', + author_email='niels.reedijk@gmail.com', + description='Provides support for subcomponents in the interface.', + license='MIT', + keywords='trac plugin ticket query components', + url='https://trac-hacks.org/wiki/SubcomponentsPlugin', + classifiers=[ 'Framework :: Trac', - #'Development Status :: 1 - Planning', - #'Development Status :: 2 - Pre-Alpha', + # 'Development Status :: 1 - Planning', + # 'Development Status :: 2 - Pre-Alpha', # 'Development Status :: 3 - Alpha', # 'Development Status :: 4 - Beta', 'Development Status :: 5 - Production/Stable', @@ -34,11 +36,12 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', ], - - install_requires = ['Trac>=1.0dev',], - entry_points = { + install_requires=['Trac>=1.0dev', ], + + entry_points={ 'trac.plugins': [ + 'subcomponents.components_view = subcomponents.components_view', 'subcomponents.web_ui = subcomponents.web_ui', ] } diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/components_view.py trac-subcomponents-1.3.1/subcomponents/components_view.py --- trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/components_view.py 1970-01-01 00:00:00.000000000 +0000 +++ trac-subcomponents-1.3.1/subcomponents/components_view.py 2018-05-05 23:16:08.000000000 +0000 @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- + +from trac.core import Component, implements +from trac.ticket import model +from trac.util.html import html +from trac.web.chrome import INavigationContributor, ITemplateProvider, \ + add_stylesheet +from trac.perm import IPermissionRequestor +from trac.web import IRequestHandler +from trac.wiki import format_to_html +from trac.mimeview.api import Context + + +class ComponentsViewModule(Component): + """Adds a separate end-user page that lists all components.""" + + implements(INavigationContributor, IPermissionRequestor, + IRequestHandler, ITemplateProvider) + + # IPermissionRequestor methods. + + def get_permission_actions(self): + return ['COMPONENT_VIEW'] + + # INavigationContributor methods + + def get_active_navigation_item(self, req): + return 'components' + + def get_navigation_items(self, req): + if 'COMPONENT_VIEW' in req.perm: + yield ('mainnav', 'components', + html.a('Components', href=req.href.components())) + + # IRequestHandler methods + + def match_request(self, req): + return req.path_info == '/components' + + def process_request(self, req): + req.perm.require('COMPONENT_VIEW') + + component_names = [] + subcomponents = [] + for component in model.Component.select(self.env): + component_names.append(component.name) + active_tickets = 0 + active_tickets_wo_milestone = 0 + + for id_, milestone in self.env.db_query(""" + SELECT id, milestone FROM ticket + WHERE status <> 'closed' AND component=%s + """, (component.name,)): + active_tickets += 1 + if not milestone: + active_tickets_wo_milestone += 1 + + subname, sublevel = \ + self.get_subcomponent_name(component.name, component_names) + description = format_to_html(self.env, Context.from_request(req), + component.description, True) + + subcomponents.append({ + 'name': component.name, + 'subname': subname, + 'subcomponent_level': sublevel, + 'description': description, + 'active_tickets': active_tickets, + 'active_tickets_without_milestone': active_tickets_wo_milestone, + }) + + data = { + 'components': subcomponents, + 'no_milestone': 'no_milestone' in req.args, + 'hide_description': 'hide_description' in req.args + } + add_stylesheet(req, 'subcomponents/subcomponents.css') + + return 'components.html', data, None + + def get_htdocs_dirs(self): + from pkg_resources import resource_filename + return [('usermanual', resource_filename(__name__, 'htdocs'))] + + def get_templates_dirs(self): + from pkg_resources import resource_filename + return [resource_filename(__name__, 'templates')] + + def get_subcomponent_name(self, name, component_names): + subname = name + for component in component_names: + if not name.startswith(component + '/'): + continue + + sub = name[len(component):].lstrip('/') + if len(sub) < len(subname): + subname = sub + + sublevel = name[:-len(subname)].count('/') + return subname, sublevel diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/htdocs/componentselect.js trac-subcomponents-1.3.1/subcomponents/htdocs/componentselect.js --- trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/htdocs/componentselect.js 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/subcomponents/htdocs/componentselect.js 2018-05-05 23:16:29.000000000 +0000 @@ -1,7 +1,7 @@ /* * Copyright 2006, John Drinkwater * Distributed under the terms of the MIT License. - * Please note, this script isn't as DOM friendly as I would like, + * Please note, this script isn't as DOM friendly as I would like, * but IE, as always, has problems with box, replaces it with a hidden input - box, and as many boxes - original: the box and adds as many boxes. + element: the + +

+

+ + +

+
+ +
+ + + + + + + + + + + + + + + + + + + + ${componentrow("even")} + + + ${componentrow("odd")} + + + +
NameTicketsDescription
+ + ${component.subname} + + + + + ${component.active_tickets_without_milestone} + + + ${component.active_tickets} + + + + + add ticket + + + ${component.description} +
+ + + + diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/web_ui.py trac-subcomponents-1.3.1/subcomponents/web_ui.py --- trac-subcomponents-1.2.0+hga86f0413121f/subcomponents/web_ui.py 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/subcomponents/web_ui.py 2018-05-05 23:16:08.000000000 +0000 @@ -1,158 +1,164 @@ - # - # Copyright 2009, Niels Sascha Reedijk - # All rights reserved. Distributed under the terms of the MIT License. - # - -from pkg_resources import resource_filename -from genshi import HTML -from genshi.builder import tag -from genshi.filters.transform import Transformer - -from trac.core import * -from trac.ticket import model -from trac.util.text import unicode_quote_plus -from trac.web.api import IRequestFilter -from trac.web.chrome import ITemplateProvider, ITemplateStreamFilter, add_notice, add_script -from trac.ticket.roadmap import TicketGroupStats -from trac.util.translation import _ - -class SubComponentsModule(Component): - """Implements subcomponents in Trac's interface.""" - - implements(IRequestFilter, ITemplateProvider, ITemplateStreamFilter) - - # IRequestFilter methods - def pre_process_request(self, req, handler): - if req.path_info.startswith('/admin/ticket/components/'): - if req.method == "POST" and 'renamechildren' in req.args: - if req.args.get('renamechildren') != 'on': - return handler # Let trac handle this update - # First process the parent component. - parentcomponentname = req.path_info[25:] - parentcomponent = model.Component(self.env, parentcomponentname) - parentcomponent.name = req.args.get('name') - parentcomponent.owner = req.args.get('owner') - parentcomponent.description = req.args.get('description') - try: - parentcomponent.update() - except self.env.db_exc.IntegrityError: - raise TracError(_('The component "%(name)s" already ' - 'exists.', name=parentcomponentname)) - - # Now update the child components - childcomponents = self._get_component_children(parentcomponentname) - for component in childcomponents: - component.name = component.name.replace(parentcomponentname, req.args.get('name'), 1) - component.update() - add_notice(req, _('Your changes have been saved.')) - req.redirect(req.href.admin('ticket', 'components')) - - return handler - - def post_process_request(self, req, template, data, content_type): - # The /query paths are handled in filter_stream() - if req.path_info.startswith('/ticket/') or \ - req.path_info.startswith('/newticket'): - add_script(req, 'subcomponents/componentselect.js') - - - if template == "query.html": - # Allow users to query for parent components and include all subs - data['modes']['select'].insert(0, {'name': "begins with", 'value': "^"}) - - if template == "milestone_view.html": - # Group components in the milestone view by base component. - if data['grouped_by'] == "component": - componentname = '' - newgroups = [] - newcomponents = [] - for component in data['groups']: - componentname = component['name'].split('/')[0] - if componentname not in newcomponents: - # This component is not yet in the new list of components, add it. - newcomponents.append(componentname) - # Fix URLs to the querys (we use unicode_quote_plus to replace the '/' - # with something URL safe (like the hrefs are) - new_hrefs = [] - for interval_href in component['interval_hrefs']: - new_hrefs.append(interval_href.replace(unicode_quote_plus(component['name']), '^' + componentname)) - component['stats_href'] = component['stats_href'].replace(unicode_quote_plus(component['name']), '^' + componentname) - component['interval_hrefs'] = new_hrefs - # Set the name to the base name (in case this originally - # is a subcomponent. - component['name'] = componentname - - newgroups.append(component) - else: - # This is a subcomponent. Add the stats to the main component. - # Note that above two lists are created. Whenever an - # item is added to one, an analogous one is added to - # the other. This code uses that logic. - corecomponent = newgroups[newcomponents.index(componentname)] - mergedstats = corecomponent['stats'] #TicketGroupStats from trac.ticket.roadmap - newstats = component['stats'] - - # Bear with me as we go to this mess that is the group stats - # (or of course this hack, depending on who's viewpoint). - # First merge the totals - mergedstats.count += newstats.count - - # The stats are divided in intervals, merge these. - i = 0 - for interval in mergedstats.intervals: - newinterval = newstats.intervals[i] - interval['count'] += newinterval['count'] - i += 1 - mergedstats.refresh_calcs() - - # Now store the new milestone component groups - data['groups'] = newgroups - return template, data, content_type - - - # ITemplateProvider methods - def get_htdocs_dirs(self): - """Return the absolute path of a directory containing additional - static resources (such as images, style sheets, etc). - """ - return [('subcomponents', resource_filename(__name__, 'htdocs'))] - - def get_templates_dirs(self): - """Return the absolute path of the directory containing the provided - ClearSilver templates. - """ - return "" - - - # ITemplateStreamFilter methods - def filter_stream(self, req, method, filename, stream, data): - if filename == "admin_components.html": - # If we are at detail editing of a component, and it has - # children, then add a checkbox to rename those. - if data['view'] == 'detail': - if len(self._get_component_children(data['component'].name)) > 0: - stream |= Transformer("//div[@class='field'][1]").after(self._build_renamechildren_field()) - elif req.path_info.startswith('/query'): - # We need to load our script after the initializeFilters() call done by Trac - html = HTML('') - stream |= Transformer('//head').append(html) - return stream - - - # Other functions - def _get_component_children(self, name): - components = model.Component.select(self.env) - result = [] - for component in components: - if component.name.startswith(name) and component.name != name: - result.append(component) - return result - - def _build_renamechildren_field(self): - return tag.div(tag.label(tag.input(_("Also rename children"), \ - type='checkbox', id='renamechildren', \ - name='renamechildren', checked='checked') \ - ), \ - class_='field') +# -*- coding: utf-8 -*- +# +# Copyright 2009, Niels Sascha Reedijk +# All rights reserved. Distributed under the terms of the MIT License. +# + +from pkg_resources import resource_filename +from genshi.filters.transform import Transformer + +from trac.core import * +from trac.ticket import model +from trac.util.html import tag +from trac.util.text import unicode_quote_plus +from trac.web.api import IRequestFilter +from trac.web.chrome import ITemplateProvider, ITemplateStreamFilter, \ + add_notice, add_script +from trac.util.translation import _ + + +class SubComponentsModule(Component): + """Implements subcomponents in Trac's interface.""" + + implements(IRequestFilter, ITemplateProvider, ITemplateStreamFilter) + + # IRequestFilter methods + def pre_process_request(self, req, handler): + if req.path_info.startswith('/admin/ticket/components/'): + if req.method == 'POST' and 'renamechildren' in req.args: + if req.args.get('renamechildren') != 'on': + return handler # Let trac handle this update + # First process the parent component. + parent_component_name = req.path_info[25:] + parent_component = model.Component(self.env, + parent_component_name) + parent_component.name = req.args.get('name') + parent_component.owner = req.args.get('owner') + parent_component.description = req.args.get('description') + try: + parent_component.update() + except self.env.db_exc.IntegrityError: + raise TracError(_('The component "%(name)s" already ' + 'exists.', name=parent_component_name)) + + # Now update the child components + child_components = self._get_component_children( + parent_component_name) + for component in child_components: + component.name = component.name.replace( + parent_component_name, req.args.get('name'), 1) + component.update() + add_notice(req, _("Your changes have been saved.")) + req.redirect(req.href.admin('ticket', 'components')) + + return handler + + def post_process_request(self, req, template, data, content_type): + # The /query paths are handled in filter_stream() + if req.path_info.startswith('/ticket/') or \ + req.path_info.startswith('/newticket'): + add_script(req, 'subcomponents/componentselect.js') + + if template == 'query.html': + # Allow users to query for parent components and include all subs + data['modes']['select'].insert(0, {'name': "begins with", + 'value': "^"}) + + if template == 'milestone_view.html': + # Group components in the milestone view by base component. + if data['grouped_by'] == 'component': + newgroups = [] + newcomponents = [] + for component in data['groups']: + componentname = component['name'].split('/')[0] + if componentname not in newcomponents: + newcomponents.append(componentname) + # Fix URLs to the querys (we use unicode_quote_plus + # to replace the '/' with something URL safe + # (like the hrefs are) + new_hrefs = [] + for interval_href in component['interval_hrefs']: + new_hrefs.append(interval_href.replace( + unicode_quote_plus(component['name']), + '^' + componentname)) + component['stats_href'] = component[ + 'stats_href'].replace( + unicode_quote_plus(component['name']), + '^' + componentname) + component['interval_hrefs'] = new_hrefs + # Set the name to the base name (in case this + # originally is a subcomponent. + component['name'] = componentname + + newgroups.append(component) + else: + # This is a subcomponent. Add the stats to the main + # component. + # Note that above two lists are created. Whenever an + # item is added to one, an analogous one is added to + # the other. This code uses that logic. + corecomponent = newgroups[ + newcomponents.index(componentname)] + mergedstats = corecomponent['stats'] + newstats = component['stats'] + + # Bear with me as we go to this mess that is the + # group stats (or of course this hack, depending + # on who's viewpoint). First merge the totals. + mergedstats.count += newstats.count + + # The stats are divided in intervals, merge these. + for i, interval in enumerate(mergedstats.intervals): + newinterval = newstats.intervals[i] + interval['count'] += newinterval['count'] + mergedstats.refresh_calcs() + + # Now store the new milestone component groups + data['groups'] = newgroups + return template, data, content_type + + # ITemplateProvider methods + + def get_htdocs_dirs(self): + return [('subcomponents', resource_filename(__name__, 'htdocs'))] + + def get_templates_dirs(self): + return "" + + # ITemplateStreamFilter methods + + def filter_stream(self, req, method, filename, stream, data): + if filename == 'admin_components.html': + # If we are at detail editing of a component, and it has + # children, then add a checkbox to rename those. + if data['view'] == 'detail': + if len(self._get_component_children( + data['component'].name)) > 0: + stream |= Transformer('//div[@class=\'field\'][1]').after( + self._build_renamechildren_field()) + elif req.path_info.startswith('/query'): + # We need to load our script after the initializeFilters() call + # done by Trac + html = tag.script(type='text/javascript', charset='utf-8', + src=req.href.chrome( + 'subcomponents/componentselect.js')) + stream |= Transformer('//head').append(html) + return stream + + # Other functions + def _get_component_children(self, name): + components = model.Component.select(self.env) + result = [] + for component in components: + if component.name.startswith(name) and component.name != name: + result.append(component) + return result + + def _build_renamechildren_field(self): + return tag.div(tag.label(tag.input(_("Also rename children"), + type='checkbox', + id='renamechildren', + name='renamechildren', + checked='checked') + ), + class_='field') diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/test/init-test-env.py trac-subcomponents-1.3.1/test/init-test-env.py --- trac-subcomponents-1.2.0+hga86f0413121f/test/init-test-env.py 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/test/init-test-env.py 2018-05-05 23:16:18.000000000 +0000 @@ -11,21 +11,21 @@ admin = TracAdmin(sys.argv[1]) admin.onecmd("initenv \"trac-subcomponents test environment\" sqlite:db/trac.db") admin.onecmd("permission add anonymous TRAC_ADMIN") - - components = ("NoSubcomponents", - "SuperComponent", "SuperComponent/SubComponent1", - "SuperComponent/SubComponent2", + + components = ("NoSubcomponents", + "SuperComponent", "SuperComponent/SubComponent1", + "SuperComponent/SubComponent2", "ForcedSubcomponent/ForcedSub1/ForcedSubSub", "LeafTest", "LeafTest/HasEmptyLeaf", "LeafTest/HasEmptyLeaf/Sub1", "LeafTest/HasEmptyLeaf/Sub2", "LeafTest/NoEmptyLeaf/Sub1", "LeafTest/NoEmptyLeaf/Sub2", "SixSubLevels/s1/s2/s3/s4/s5/s6") for component in components: admin.onecmd("component add %s nobody" % (component,)) - + printout(""" The test environment is set up at %s. You can run tracd to test this environment. Please make sure that the trac-subcomponents plugin is loaded, either by putting the plugin in %s/plugins, by making it available in general or by manipulation PYTHON_PATH. """ % (sys.argv[1], sys.argv[1])) - sys.exit(0) \ No newline at end of file + sys.exit(0) diff -Nru trac-subcomponents-1.2.0+hga86f0413121f/test/Test.rst trac-subcomponents-1.3.1/test/Test.rst --- trac-subcomponents-1.2.0+hga86f0413121f/test/Test.rst 2014-01-19 17:06:51.000000000 +0000 +++ trac-subcomponents-1.3.1/test/Test.rst 2018-05-05 23:16:18.000000000 +0000 @@ -4,7 +4,7 @@ Both the Javascript code and the Trac plugin perform manipulation of the original Trac HTML output. With each new version of Trac the hardcoded -elements need to be tested and verified. +elements need to be tested and verified. Testing of the python code @@ -28,11 +28,11 @@ + This adds the javascript to relevant ticket pages + **Test** if the javascript is actually added - + **Check** if the ticket paths are still correct + + **Check** if the ticket paths are still correct - template is "query.html" - + This adds the option of searching for tickets with a specific parent + + This adds the option of searching for tickets with a specific parent component. This needs the ^ operator + **Check** if the 'begins with' operator actually shows up in the Custom Query page. @@ -80,11 +80,11 @@ + **Check** if the XPath to the batch modify is correct - Query page: existing filters - + + **Check** if the XPath to existing filters is correct - Ticket/Newticket page: component field - + + **Check** if the XPath to the field is correct * convertQueryComponent() @@ -103,4 +103,4 @@ In order to help test the right combination of components and subcomponents it is possible to use the init-test-env.py tool to create a test environment with various default components for testing. The components have a descriptive name -which should give an indication of how it functions. +which should give an indication of how it functions.