Title validation -

17 views
Skip to first unread message

Miroslav (Code for Croatia, ImamoPravoZnati.org)

unread,
Apr 7, 2022, 2:54:21 AMApr 7
to Alaveteli Dev
Hello,
I found that some Pro users are persistent by adding "Zahtjev za pravo zna pristup informacijama" (translated: "Freedom of information request") in the title of their bulk requests.

I see that core already has validation in title but it's restricted only to English terms:

Is it possible to add this validation but for Croatian terms in the theme? If yes, what is the proper way to do it, in which folder script should be added, does it then override complete title_validation.rb from the core?

Thanks,
Miroslav

Gareth Rees

unread,
Apr 11, 2022, 5:07:05 AMApr 11
to Alaveteli Dev
Hey Miroslav,

In your theme, in model_patches.rb, you can override the method like [1]:

InfoRequest::TitleValidation.module_eval do
  def generic_foi_title?
    title =~ /^(FOI|Freedom of Information)\s*requests?$/i
  end
end

You can then replace the regular expression with something that works better in your context.

As you can see, there's an "OR" conditional, so we match:

* FOI requests
* Freedom of Information requests

I think you'd change the regexp to something like:

    title =~ /^zahtjev.*(PPI|pravo zna pristup informacijama)?$/i

FYI, the trailing `/i` makes the match case insensitive.

I've created an issue [2] to note that this isn't easily translatable.

Best,

[1] I think this is what you need, given InfoRequest::TitleValidation is a module not a class. If it doesn't work we'll take a closer look.

Miroslav (Code for Croatia, ImamoPravoZnati.org)

unread,
Apr 12, 2022, 12:52:16 PMApr 12
to Alaveteli Dev
Hi Gareth,
Thanks! 

I have tried and added as instructed, but I still don't see that validation is applied (I wrote "Zahtjev za pravo na pristup informacijama" and when I confirmed to go to 2nd step - preview, I didn't get any error message).

My change is visible here:

Did I wrote everything correctly?

Cheers,
Miroslav

Miroslav Schlossberg

unread,
Apr 23, 2022, 8:48:22 AMApr 23
to alavet...@googlegroups.com
Hi Gareth,
Managed to get it working. Thank you!


Best regards,
Miroslav

-- 
Q: Why is this email [hopefully] three sentences or less?



Code for Croatia brine o zaštiti Vaše privatnosti. Molimo vas da ograničite dijeljenje svojih osobnih podataka putem elektroničke pošte.
Vodite računa o okolišu. Ne tiskajte ovu poruku ako nije neophodno.

--
You received this message because you are subscribed to a topic in the Google Groups "Alaveteli Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/alaveteli-dev/uYPeOW7WbIo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to alaveteli-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/alaveteli-dev/785673fa-a4bd-4756-940b-13aba6dafb45n%40googlegroups.com.

Code for Croatia brine o zaštiti Vaše privatnosti. Molimo vas da ograničite dijeljenje svojih osobnih podataka putem elektroničke pošte.
Vodite računa o okolišu. Ne tiskajte ovu poruku ako nije neophodno.

Gareth Rees

unread,
Apr 25, 2022, 5:06:42 AMApr 25
to Alaveteli Dev
Nice!

Obviously my regexp skills are a little rusty 🙈
Reply all
Reply to author
Forward
0 new messages