Commit 5dfd54681501c23099a6ca4d4552e632c7bf013e

Authored by Parley
1 parent 5fa4fc17
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Remove validation of name begin with capital letter

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
lib/ext/person.rb
@@ -8,8 +8,6 @@ class Person @@ -8,8 +8,6 @@ class Person
8 8
9 attr_accessible :percentage_incomplete 9 attr_accessible :percentage_incomplete
10 10
11 - validate :validate_full_name  
12 -  
13 scope :search, lambda { |name="", state="", city="", email=""| 11 scope :search, lambda { |name="", state="", city="", email=""|
14 like_sql = "" 12 like_sql = ""
15 values = [] 13 values = []
@@ -59,51 +57,8 @@ class Person @@ -59,51 +57,8 @@ class Person
59 self.user.secondary_email = value unless self.user.nil? 57 self.user.secondary_email = value unless self.user.nil?
60 end 58 end
61 59
62 - def validate_full_name  
63 - full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/  
64 - partial_validation = /[^\w\*\s]/  
65 - invalid = false  
66 -  
67 - return false if self.name.blank?  
68 -  
69 - validation_name = replace_some_special_chars(self.name)  
70 -  
71 - validation_name.split(" ").each do |value|  
72 - invalid = if value.length > 3  
73 - full_validation.match(value)  
74 - else  
75 - partial_validation.match(value)  
76 - end  
77 - end  
78 -  
79 - if invalid  
80 - self.errors.add(:name, _("Should begin with a capital letter and no special characters"))  
81 - return false  
82 - end  
83 - true  
84 - end  
85 -  
86 def software? 60 def software?
87 false 61 false
88 end 62 end
89 63
90 - private  
91 -  
92 - def replace_some_special_chars text  
93 - text.gsub(/([áàâãéèêíïóôõöú])/) do |value|  
94 - if( ["á","à","â","ã"].include?(value) )  
95 - "a"  
96 - elsif( ["é","è","ê"].include?(value) )  
97 - "e"  
98 - elsif( ["í","ï"].include?(value) )  
99 - "i"  
100 - elsif ( ["ó","ô","õ","ö"].include?(value) )  
101 - "o"  
102 - elsif( ["ú"].indexOf(value) )  
103 - "u"  
104 - else  
105 - value  
106 - end  
107 - end  
108 - end  
109 end 64 end
public/mpog-user-validations.js
@@ -209,49 +209,6 @@ @@ -209,49 +209,6 @@
209 }); 209 });
210 } 210 }
211 211
212 - // Sorry, I know its ugly. But I cant get ([^\w\*\s*])|(^|\s)([a-z]|[0-9])  
213 - // to ignore Brazilian not so much special chars in names  
214 - function replace_some_special_chars(text) {  
215 - return text.replace(/([áàâãéèêíïóôõöú])/g, function(value){  
216 - if( ["á","à","â","ã"].indexOf(value) != -1 )  
217 - return "a";  
218 - else if( ["é","è","ê"].indexOf(value) != -1 )  
219 - return "e";  
220 - else if( ["í","ï"].indexOf(value) != -1 )  
221 - return "i";  
222 - else if ( ["ó","ô","õ","ö"].indexOf(value) != -1 )  
223 - return "o";  
224 - else if( ["ú"].indexOf(value) != -1 )  
225 - return "u";  
226 - else  
227 - return value;  
228 - });  
229 - }  
230 -  
231 - function invalid_name_validation(text) {  
232 - if( text.trim().length === 0 ) {  
233 - return true;  
234 - }  
235 -  
236 - var full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/; // no special chars and do not initialize with no capital latter  
237 - var partial_validation = /[^\w\*\s*]/; // no special chars  
238 - text = replace_some_special_chars(text);  
239 - var slices = text.split(" ");  
240 - var invalid = false;  
241 -  
242 - for(var i = 0; i < slices.length; i++) {  
243 - if( slices[i].length > 3 || text.length <= 3 ) {  
244 - invalid = full_validation.test(slices[i]);  
245 - } else {  
246 - invalid = partial_validation.test(slices[i]);  
247 - }  
248 -  
249 - if(invalid) break;  
250 - }  
251 -  
252 - return invalid;  
253 - }  
254 -  
255 // Generic 212 // Generic
256 function show_plugin_error_message(field_selector, hidden_message_id ) { 213 function show_plugin_error_message(field_selector, hidden_message_id ) {
257 var field = jQuery(field_selector); 214 var field = jQuery(field_selector);
@@ -392,7 +349,6 @@ @@ -392,7 +349,6 @@
392 fix_phone_mask_format("#profile_data_comercial_phone"); 349 fix_phone_mask_format("#profile_data_comercial_phone");
393 fix_phone_mask_format("#profile_data_contact_phone"); 350 fix_phone_mask_format("#profile_data_contact_phone");
394 351
395 - addBlurFields("#profile_data_name", "full_name_error", invalid_name_validation);  
396 addBlurFields("#profile_data_email", "email_error", invalid_email_validation); 352 addBlurFields("#profile_data_email", "email_error", invalid_email_validation);
397 addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true); 353 addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true);
398 addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation); 354 addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation);