On Thursday, April 2, 2015 at 8:38:13 AM UTC-5, pineapplehandler wrote:
>
> I was trying to incorporate the changes made by Dan Winslow in this 
> comment <https://groups.google.com/forum/#!topic/trac-users/P-Zwu85rEOM>. 
> The end-goal is to trigger the error when the field hasn't been moved from 
> the default value. The fields are pre-populated with a dropdown list...So 
> we'd like to query to be sure the user moved the default from "--- Please 
> choose a state ---" 
>

We ended up pushing this through by modifying the code within core.py for 
 the Ticket Validator plugin 
<http://trac-hacks.org/wiki/TicketValidatorPlugin>. To correct the error 
message we had to create field_name_alias to feed the updated field names 
into the error function. Here's the code we changed in 
/usr/local/lib/python2.7/dist-packages/ticketvalidator/core.py:
         field_name_alias = {}                             

        for field_name_temp in required_fields:                
            if (field_name_temp == "type"):                
                field_name_alias[field_name_temp] = "State"
            elif field_name_temp == "component":            
                field_name_alias[field_name_temp] = "Table"
            else:                                     
                field_name_alias[field_name_temp] = field_name_temp

        errors = [(field_name_alias[field_name], '%s is required' % 
field_name_alias[field_name])
                  for field_name in required_fields 
                  if (not ticket[field_name]) or (ticket[field_name] == '--- 
Please choose a state ---') or (ticket[field_name] == '--- Please select a 
table ---')]

        return errors

Added the fields to /etc/trac/svn-MyProject.ini:
[ticketvalidator]
new.required = type,component

In hindsight it would have been cleaner and easier to simply hide the Type 
and Component fields and created our own custom fields in the trac.ini file.

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to