Re: [Trac] Re: Validate custom field before saving ticket

2015-04-14 Thread RjOllos
On Monday, April 13, 2015 at 2:31:13 PM UTC-7, hasienda wrote:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA1 
>
> On 12.04.2015 22:52, RjOllos wrote: 
> > Another approach would be to have TicketValidatorPlugin add a label on 
> > an empty field, and an empty field in the case that the field doesn't 
> > allow the empty value. This would avoid creating dummy values like your 
> > Component "--- Please choose a state ---" 
>
> Nice idea. I've often seen trailing (red) star behind a required input 
> field label as visual sign for required input. If others agree, that 
> this is sufficiently common, it could become a Trac default visual style 
> too. 
>
> Steffen Hoffmann 
>

That sounds good. The BatchModifyPlugin had that behavior:
http://trac-hacks.org/ticket/10029#comment:1

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


Re: [Trac] Re: Validate custom field before saving ticket

2015-04-13 Thread Steffen Hoffmann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 12.04.2015 22:52, RjOllos wrote:
> Another approach would be to have TicketValidatorPlugin add a label on
> an empty field, and an empty field in the case that the field doesn't
> allow the empty value. This would avoid creating dummy values like your
> Component "--- Please choose a state ---"

Nice idea. I've often seen trailing (red) star behind a required input
field label as visual sign for required input. If others agree, that
this is sufficiently common, it could become a Trac default visual style
too.

Steffen Hoffmann
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlUsNZEACgkQ31DJeiZFuHf+sgCg0bUNtKvgtIhLgbGbljbg5yV0
5h4An20zyk+wYO7KJN76Mahww4Gdpjbw
=Bnz0
-END PGP SIGNATURE-

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


Re: [Trac] Re: Validate custom field before saving ticket

2015-04-12 Thread RjOllos


On Friday, April 3, 2015 at 9:14:48 AM UTC-4, pineapplehandler wrote:
>
>
>
> 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 . 
>> 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 
> . 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.
>

It sounds like your use case is similar to the request in #11666. Rather 
than validating a field to be non-empty, we could validate the field to not 
be some specified value.
http://trac-hacks.org/ticket/11666

Another approach would be to have TicketValidatorPlugin add a label on an 
empty field, and an empty field in the case that the field doesn't allow 
the empty value. This would avoid creating dummy values like your Component 
"--- Please choose a state ---"

- Ryan 

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


Re: [Trac] Re: Validate custom field before saving ticket

2015-04-03 Thread pineapplehandler


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 . 
> 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 
. 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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


Re: [Trac] Re: Validate custom field before saving ticket

2015-04-02 Thread pineapplehandler
On Wednesday, April 1, 2015 at 11:38:53 PM UTC-5, RjOllos wrote:
>
> I'm not sure which plugin the [fieldscheck] section applies to. It isn't 
> defined by TicketValidatorPlugin:
> http://trac-hacks.org/wiki/TicketValidatorPlugin
>

I was trying to incorporate the changes made by Dan Winslow in this comment 
. 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:
# trac-admin /var/www/projects/svn-OurProject ticket_type list

Possible Values  
-
--- Please choose a state ---
01 Alabama   
04 Arizona   
05 Arkansas  
06 California
08 Colorado  
...

So we'd like to query to be sure the user moved the default from "--- 
Please choose a state ---" 
 

> As for using it with your custom field, I can confirm the following works:
>
> [ticket-custom]
> the_custom = select
> the_custom.options = |one|two|thr|fou
>
> [ticketvalidator]
> new.required = the_custom
>
> [image: Inline image 2]
>

I guess I went a different route. Is it possible to replace the text "--- 
Please choose a state ---" with null? Seems like that should resolve this. 
I've tried several methods but it doesn't seem legal. Do we need to define 
the values in the ini file like you did above rather than populating them 
via trac-admin?

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


Re: [Trac] Re: Validate custom field before saving ticket

2015-04-01 Thread Ryan Ollos
On Tue, Mar 31, 2015 at 2:38 PM, pineapplehandler 
wrote:

> Say I want to use the Ticket Validator plugin, and I want to test
> the Component and Type fields for specific values. Is this the correct
> format to enter the field names in the .ini? I'm totally guessing on the
> 'str' part here:
> [fieldscheck]
> type = str
> component = str
>

I'm not sure which plugin the [fieldscheck] section applies to. It isn't
defined by TicketValidatorPlugin:
http://trac-hacks.org/wiki/TicketValidatorPlugin


> And does this look right for the next section?
> [ticketvalidator]
> new.required = type,component
>

Neither type nor component can have an empty value in Trac < 1.1.2. The
[ticket] optional_fields option was added in Trac 1.1.2:
http://trac.edgewall.org/wiki/TracIni#ticket-section

I tested with 0.2dev-r14386 of TicketValidatorPlugin. Using two fields that
allow an empty value, I can confirm that the plugin works correctly with
Trac 1.0-stable.

[ticketvalidator]
new.required = version, milestone

[image: Inline image 1]


As for using it with your custom field, I can confirm the following works:

[ticket-custom]
the_custom = select
the_custom.options = |one|two|thr|fou

[ticketvalidator]
new.required = the_custom

[image: Inline image 2]

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.


[Trac] Re: Validate custom field before saving ticket

2015-03-31 Thread pineapplehandler
Say I want to use the Ticket Validator plugin, and I want to test 
the Component and Type fields for specific values. Is this the correct 
format to enter the field names in the .ini? I'm totally guessing on the 
'str' part here:
[fieldscheck]
type = str
component = str

And does this look right for the next section?
[ticketvalidator]
new.required = type,component


-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.