Skip to content

Instantly share code, notes, and snippets.

@batkinson
Created November 25, 2011 20:20
Show Gist options
  • Save batkinson/1394344 to your computer and use it in GitHub Desktop.
Save batkinson/1394344 to your computer and use it in GitHub Desktop.
Patch for trac-backlog #5
diff -urN trac-backlog-0.2.2/backlog/prefs.py trac-backlog-0.2.2-fc/backlog/prefs.py
--- trac-backlog-0.2.2/backlog/prefs.py 1970-01-01 00:00:00.000000000 +0000
+++ trac-backlog-0.2.2-fc/backlog/prefs.py 2011-11-25 20:06:12.591248563 +0000
@@ -0,0 +1,47 @@
+# Copyright (C) 2009 John Szakmeister
+# All rights reserved.
+#
+# This software is licensed as described in the file LICENSE.txt, which
+# you should have received as part of this distribution.
+
+from trac.core import *
+from trac.prefs import IPreferencePanelProvider
+from trac.util.translation import _
+from trac.web.chrome import add_notice, ITemplateProvider
+
+class BacklogPluginPrefPanel(Component):
+ implements(IPreferencePanelProvider, ITemplateProvider)
+
+ _form_fields = [
+ 'id', 'summary', 'component', 'version', 'type', 'owner', 'status',
+ 'time_created'
+ ]
+
+ # IPreferencePanelProvider methods
+
+ def get_preference_panels(self, req):
+ yield ('backlog', _('Backlog'))
+
+
+ def render_preference_panel(self, req, panel):
+
+ if req.method == 'POST':
+ fields = req.args.get('backlog_fields')
+ req.session['backlog_fields'] = fields
+ add_notice(req,_('Your backlog preferences have been saved.'))
+ req.redirect(req.href.prefs(panel or None))
+
+ return 'prefs_backlog.html', {
+ 'shown_fields': req.session.get('backlog_fields') or self._form_fields
+ }
+
+ # ITemplateProvider methods
+
+ def get_htdocs_dirs(self):
+ from pkg_resources import resource_filename
+ return [('backlog', resource_filename(__name__, 'htdocs'))]
+
+ def get_templates_dirs(self):
+ from pkg_resources import resource_filename
+ return [resource_filename(__name__, 'templates')]
+
diff -urN trac-backlog-0.2.2/backlog/templates/backlog.html trac-backlog-0.2.2-fc/backlog/templates/backlog.html
--- trac-backlog-0.2.2/backlog/templates/backlog.html 2011-10-10 13:09:39.000000000 +0000
+++ trac-backlog-0.2.2-fc/backlog/templates/backlog.html 2011-11-25 19:10:28.694671534 +0000
@@ -167,26 +167,26 @@
<table id="tickets_table" class="listing tickets">
<thead>
<tr>
- <th>Id</th>
- <th>Summary</th>
- <th>Component</th>
- <th>Version</th>
- <th>Type</th>
- <th>Owner</th>
- <th>Status</th>
- <th>Created</th>
+ <th py:if="'id' in shown_fields">Id</th>
+ <th py:if="'summary' in shown_fields">Summary</th>
+ <th py:if="'component' in shown_fields">Component</th>
+ <th py:if="'version' in shown_fields">Version</th>
+ <th py:if="'type' in shown_fields">Type</th>
+ <th py:if="'owner' in shown_fields">Owner</th>
+ <th py:if="'status' in shown_fields">Status</th>
+ <th py:if="'time_created' in shown_fields">Created</th>
</tr>
</thead>
<tbody id="tickets">
<tr py:for="ticket in tickets" id="ticket_${ticket.id}" class="dojoDndItem">
- <td><a href="${base_path}/ticket/${ticket.id}">#$ticket.id</a></td>
- <td><a href="${base_path}/ticket/${ticket.id}">$ticket.summary</a></td>
- <td>$ticket.component</td>
- <td>$ticket.version</td>
- <td>$ticket.type</td>
- <td>$ticket.owner</td>
- <td>$ticket.status</td>
- <td>${format_datetime(ticket.time_created)}</td>
+ <td py:if="'id' in shown_fields"><a href="${base_path}/ticket/${ticket.id}">#$ticket.id</a></td>
+ <td py:if="'summary' in shown_fields"><a href="${base_path}/ticket/${ticket.id}">$ticket.summary</a></td>
+ <td py:if="'component' in shown_fields">$ticket.component</td>
+ <td py:if="'version' in shown_fields">$ticket.version</td>
+ <td py:if="'type' in shown_fields">$ticket.type</td>
+ <td py:if="'owner' in shown_fields">$ticket.owner</td>
+ <td py:if="'status' in shown_fields">$ticket.status</td>
+ <td py:if="'time_created' in shown_fields">${format_date(ticket.time_created)}</td>
</tr>
</tbody>
</table>
diff -urN trac-backlog-0.2.2/backlog/templates/prefs_backlog.html trac-backlog-0.2.2-fc/backlog/templates/prefs_backlog.html
--- trac-backlog-0.2.2/backlog/templates/prefs_backlog.html 1970-01-01 00:00:00.000000000 +0000
+++ trac-backlog-0.2.2-fc/backlog/templates/prefs_backlog.html 2011-11-25 20:00:27.394724359 +0000
@@ -0,0 +1,45 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="prefs.html" />
+ <head>
+ <title>Backlog</title>
+ <style type="text/css">
+ label {
+ padding-right: .5em;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="field">
+ <label>Shown Ticket Fields:</label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="id" checked="${'id' in shown_fields or None}" />Id
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="summary" checked="${'summary' in shown_fields or None}" />Summary
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="component" checked="${'component' in shown_fields or None}" />Component
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="version" checked="${'version' in shown_fields or None}" />Version
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="type" checked="${'type' in shown_fields or None}" />Type
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="owner" checked="${'owner' in shown_fields or None}" />Owner
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="status" checked="${'status' in shown_fields or None}" />Status
+ </label>
+ <label>
+ <input type="checkbox" name="backlog_fields" value="time_created" checked="${'time_created' in shown_fields or None}" />Created
+ </label>
+ </div>
+ </body>
+</html>
diff -urN trac-backlog-0.2.2/backlog/web_ui.py trac-backlog-0.2.2-fc/backlog/web_ui.py
--- trac-backlog-0.2.2/backlog/web_ui.py 2011-10-10 13:09:39.000000000 +0000
+++ trac-backlog-0.2.2-fc/backlog/web_ui.py 2011-11-25 20:15:45.822787373 +0000
@@ -52,6 +52,11 @@
IEnvironmentSetupParticipant, ITemplateProvider,
ITicketChangeListener)
+ _ticket_fields = [
+ 'id', 'summary', 'component', 'version', 'type', 'owner', 'status',
+ 'time_created'
+ ]
+
# IEnvironmentSetupParticipant
def environment_created(self):
connector, args = DatabaseManager(self.env)._get_connector()
@@ -197,6 +202,7 @@
data['form_token'] = req.form_token
data['active_milestones'] = self._get_active_milestones(milestone)
data['base_path'] = req.base_path
+ data['shown_fields'] = req.session.get('backlog_fields') or self._ticket_fields
if 'TICKET_MODIFY' in req.perm:
data['allow_sorting'] = True
diff -urN trac-backlog-0.2.2/setup.py trac-backlog-0.2.2-fc/setup.py
--- trac-backlog-0.2.2/setup.py 2011-10-10 13:09:39.000000000 +0000
+++ trac-backlog-0.2.2-fc/setup.py 2011-11-25 17:56:01.734651294 +0000
@@ -19,8 +19,11 @@
'scripts/*'
]},
entry_points={
- 'trac.plugins': ['backlog = backlog.web_ui']
- },
+ 'trac.plugins': [
+ 'backlog = backlog.web_ui',
+ 'backlog_prefs = backlog.prefs',
+ ]
+ },
install_requires=[
'simplejson>=2.0',
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment