Commit 6b03fc9c46969a3a0fe06765ffceca7e0cb5074b

Authored by Fabio Teixeira
1 parent cefdc01f
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

incomplete_registration: Using session to hide the percentage message

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Fabio Teixeira  <fabio1079@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -136,7 +136,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
136 136 end
137 137  
138 138 def js_files
139   - ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js"]
  139 + ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js"]
140 140 end
141 141  
142 142 def add_new_organization_button
... ... @@ -150,12 +150,6 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
150 150 person.has_permission_without_plugins?(permission, target)
151 151 end
152 152  
153   - def create_url_to_edit_profile person
154   - new_url = person.public_profile_url
155   - new_url[:controller] = 'profile_editor'
156   - new_url[:action] = 'edit'
157   - new_url
158   - end
159 153  
160 154 def incomplete_registration params
161 155 return if params.nil? or params[:user].nil?
... ... @@ -170,11 +164,18 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
170 164 @profile_empty_fields = profile_required_empty_list person
171 165 @percentege = calc_percentage_registration(person)
172 166  
173   - if @percentege >= 0 and @percentege <= 100
  167 + if @percentege >= 0 and @percentege <= 100 and context.session[:hide_incomplete_percentage] != true
174 168 expanded_template('mpog_software_plugin_myprofile/_incomplete_registration.html.erb')
175 169 end
176 170 end
177 171  
  172 +
  173 + def manage_software
  174 + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}]
  175 + end
  176 +
  177 + protected
  178 +
178 179 def calc_percentage_registration person
179 180 required_list = profile_required_list
180 181 empty_fields = profile_required_empty_list person
... ... @@ -185,25 +186,13 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
185 186 percentege
186 187 end
187 188  
188   - def add_link_to_complete_registration person
189   - #find a better way to do it
190   - if context.session[:hide_incomplete_percentage] != true
191   - _new_url = create_url_to_edit_profile(person)
192   - Proc::new do
193   - content_tag(:div,
194   - link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), _new_url) +
195   - link_to(image_tag("/images/icon_filter_exclude.png"), "#", :class => "hide-incomplete-percentage", :alt => "Hide Incomplete Percentage"), :class=>"mpog-incomplete-percentage"
196   - )
197   - end
198   - end
  189 + def create_url_to_edit_profile person
  190 + new_url = person.public_profile_url
  191 + new_url[:controller] = 'profile_editor'
  192 + new_url[:action] = 'edit'
  193 + new_url
199 194 end
200 195  
201   - def manage_software
202   - [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}]
203   - end
204   -
205   - protected
206   -
207 196 def profile_required_list
208 197 required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"]
209 198 end
... ...
public/mpog-incomplete-registration.js 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +function hide_incomplete_percentage(evt) {
  2 + evt.preventDefault();
  3 +
  4 + jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){
  5 + if( response == true )
  6 + jQuery("#incomplete_registration").fadeOut();
  7 + });
  8 +}
  9 +
  10 +
  11 +jQuery(document).ready(function(){
  12 + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage);
  13 +});
... ...
public/mpog-user-validations.js
... ... @@ -73,16 +73,6 @@ function institution_autocomplete() {
73 73 }
74 74  
75 75  
76   -function hide_incomplete_percentage(evt) {
77   - evt.preventDefault();
78   - var link_div = jQuery(this).parent();
79   -
80   - jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){
81   - if( response == true )
82   - link_div.hide();
83   - });
84   -}
85   -
86 76 jQuery(document).ready(function(){
87 77 jQuery('#secondary_email_field').blur(
88 78 validate_email_format
... ... @@ -92,8 +82,6 @@ jQuery(document).ready(function(){
92 82 put_brazil_based_on_email
93 83 );
94 84  
95   - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage);
96   -
97 85 jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); });
98 86 jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); });
99 87  
... ...
views/mpog_software_plugin_myprofile/_incomplete_registration.html.erb
... ... @@ -21,7 +21,7 @@
21 21 <%= @profile_edit_link %>
22 22 </td>
23 23 <td>
24   - <a href="#"><%= _("Hide this message") %></a>
  24 + <%= link_to _("Hide this message"), "#", :class=>"hide-incomplete-percentage" %></a>
25 25 </td>
26 26 </tr>
27 27 </table>
... ...