Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c375036
Showing
18 changed files
with
2,095 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*~ | ||
*.pyc | ||
.#* | ||
#* | ||
*# | ||
*.egg-info | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from setuptools import find_packages, setup | ||
|
||
version='0.1' | ||
|
||
try: | ||
long_description = open("README.txt").read() | ||
except: | ||
long_description = '' | ||
|
||
setup(name='trac-WorkflowActionButtons', | ||
version=version, | ||
description="Adds one-click buttons to Trac tickets for workflow operations (closing, reassigning, commenting)", | ||
long_description=long_description, | ||
author='Ethan Jucovy', | ||
author_email='ejucovy@gmail.com', | ||
url='http://trac-hacks.org/wiki/WorkflowActionButtonsPlugin', | ||
keywords='trac plugin', | ||
license="BSD", | ||
packages=find_packages(exclude=['ez_setup', 'examples', 'tests*']), | ||
include_package_data=True, | ||
package_data={ 'workflow_actionbuttons': ['templates/*', 'htdocs/*'] }, | ||
zip_safe=False, | ||
entry_points = """ | ||
[trac.plugins] | ||
workflow_actionbuttons = workflow_actionbuttons | ||
""", | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from workflow_actionbuttons.web_ui import WebUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from genshi.builder import tag | ||
from genshi.core import Markup | ||
from genshi.template import MarkupTemplate | ||
from trac.ticket.api import TicketSystem | ||
from trac.config import ConfigSection | ||
from trac.core import Component | ||
|
||
class WorkflowManager(Component): | ||
|
||
config_section = ConfigSection('ticket-workflow-action-buttons', '') | ||
|
||
@property | ||
def action_controllers(self): | ||
return TicketSystem(self.env).action_controllers | ||
|
||
def allowed_actions(self, allowed, req, ticket): | ||
return [action for action in | ||
TicketSystem(self.env).get_available_actions(req, ticket) | ||
if allowed is None or action in allowed] | ||
|
||
def controllers_for_action(self, req, ticket, action): | ||
return [controller for controller in self.action_controllers | ||
if action in [i[1] for i in controller.get_ticket_actions(req, ticket)]] | ||
|
||
def render_action_control(self, req, ticket, action): | ||
first_label = None | ||
widgets = [] | ||
hints = [] | ||
for controller in self.controllers_for_action(req, ticket, action): | ||
print controller, action | ||
label, widget, hint = controller.render_ticket_action_control( | ||
req, ticket, action) | ||
if first_label is None: | ||
first_label = label | ||
widgets.append(widget) | ||
hints.append(hint) | ||
return first_label, tag(*widgets), (hints and '. '.join(hints) or '') | ||
|
||
def render_action_button(self, req, ticket, action): | ||
template = """ | ||
<label class="button" style="%(css)s"> | ||
<input type="hidden" name="action" value="%(action)s" /> | ||
<a %(comment_required)s name="act"><i class='fa %(icon)s'></i> %(title)s</a> | ||
""" | ||
data = { | ||
"action": action, | ||
"css": self.config_section.get("%s.css" % action) or "", | ||
"comment_required": (self.config_section.get("%s.comment" % action) == "required" | ||
and 'data-comment="required"' or ""), | ||
"icon": self.config_section.get("%s.icon" % action) or "", | ||
"title": self.config_section.get("%s.title" % action, action.title()), | ||
} | ||
markup = template % data | ||
|
||
supplemental_form = "" | ||
label, widgets, hints = self.render_action_control(req, ticket, action) | ||
if widgets.children: | ||
supplemental_form = "<div class='supplemental'><div class='supplemental-form'>%s %s <span class='hint'>%s</span><textarea style='width:95%%' rows='5' name='comment' placeholder='Enter your comment'></textarea><input type='submit' /></div></div>" % (action.title(), str(widgets), hints) | ||
markup = markup + supplemental_form + "</label>" | ||
return Markup(markup) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
*.pyc | ||
*.egg-info | ||
*.db | ||
*.db.old | ||
*.swp | ||
*.db-journal | ||
|
||
.coverage | ||
.DS_Store | ||
.installed.cfg | ||
_gh_pages/* | ||
|
||
.idea/* | ||
.svn/* | ||
src/website/static/* | ||
src/website/media/* | ||
|
||
bin | ||
cfcache | ||
develop-eggs | ||
dist | ||
downloads | ||
eggs | ||
parts | ||
tmp | ||
.sass-cache | ||
node_modules | ||
|
||
src/website/settingslocal.py | ||
stunnel.log | ||
|
||
.ruby-version |
Oops, something went wrong.