Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reading options from the trac.ini file.

Works only with de default trac tields.
  • Loading branch information...
commit e8664a5b0d698c16d4e38c369343d96b900ec318 1 parent f93023e
@daltonmatos authored
View
19 conditionalfields/0.11/conditionalfields/conditionalfields.py
@@ -1,5 +1,6 @@
from trac.core import *
+from trac.config import Option, ListOption
from trac.ticket import TicketSystem
from trac.web.api import ITemplateStreamFilter, IRequestFilter
from trac.web.chrome import add_script, ITemplateProvider
@@ -11,24 +12,34 @@ class ConditionalFields(Component):
implements(ITemplateStreamFilter, IRequestFilter, ITemplateProvider)
base_url = 'cf'
+ config_section = 'conditional-fields'
default_fields = ['priority', 'milestone', 'component', 'version',\
'keywords', 'cc', 'owner'];
-
# ITemplateStreamFilter
def filter_stream(self, req, method, filename, stream, data):
logger = self.env.log
- logger.info(">>> filename=%s" % filename)
if filename == 'ticket.html':
ticket_sys = TicketSystem(self.env)
all_fields = ticket_sys.get_ticket_fields()
+ # The default fields are aways available
script = "<script>\n"
for field_name in self.default_fields:
script += ("all_fields.push('%s');\n" % field_name)
- script += "</script>\n"
+
+
+ i = 1
+ while len(self.config.getlist(self.config_section, ('ticket_type_%d' % i))) > 0 :
+ ticket_type = self.config.getlist(self.config_section, ('ticket_type_%d' % i))
+ visible_fields = self.config.getlist(self.config_section, ('visible_fields_%d' % i))
+ if len(visible_fields) > 0 :
+ script += ("types['%s'] = ['%s'];\n" % ("".join(ticket_type), "','".join(visible_fields)))
+ i += 1
+
+ script += "</script>\n"
stream |= Transformer("//div[@id='footer']").after(MarkupTemplate(script).generate())
return stream
@@ -42,7 +53,7 @@ def post_process_request(self, req, template, data, content_type):
add_script(req, ('%s/conditional-fields.js' % self.base_url))
return template, data, content_type
-
+ #ITemplateProvider
def get_templates_dirs(self):
return []
View
8 conditionalfields/0.11/conditionalfields/htdocs/conditional-fields.js
@@ -27,10 +27,10 @@ types = {};
-types['task'] = ['version', 'cc', 'priority'];
-types['defect'] = ['keywords'];
-types['enhancement'] = ['cc'];
-types['Tipo de téste'] = ['cc', 'keywords', 'priority']
+//types['task'] = ['version', 'cc', 'priority'];
+//types['defect'] = ['keywords'];
+//types['enhancement'] = ['cc'];
+//types['Tipo de téste'] = ['cc', 'keywords', 'priority']
function change_event_handler(){
Please sign in to comment.
Something went wrong with that request. Please try again.