Commit 6b03fc9c46969a3a0fe06765ffceca7e0cb5074b
1 parent
cefdc01f
Exists in
master
and in
5 other branches
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>
Showing
4 changed files
with
28 additions
and
38 deletions
Show diff stats
lib/mpog_software_plugin.rb
| @@ -136,7 +136,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -136,7 +136,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 136 | end | 136 | end |
| 137 | 137 | ||
| 138 | def js_files | 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 | end | 140 | end |
| 141 | 141 | ||
| 142 | def add_new_organization_button | 142 | def add_new_organization_button |
| @@ -150,12 +150,6 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -150,12 +150,6 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 150 | person.has_permission_without_plugins?(permission, target) | 150 | person.has_permission_without_plugins?(permission, target) |
| 151 | end | 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 | def incomplete_registration params | 154 | def incomplete_registration params |
| 161 | return if params.nil? or params[:user].nil? | 155 | return if params.nil? or params[:user].nil? |
| @@ -170,11 +164,18 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -170,11 +164,18 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 170 | @profile_empty_fields = profile_required_empty_list person | 164 | @profile_empty_fields = profile_required_empty_list person |
| 171 | @percentege = calc_percentage_registration(person) | 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 | expanded_template('mpog_software_plugin_myprofile/_incomplete_registration.html.erb') | 168 | expanded_template('mpog_software_plugin_myprofile/_incomplete_registration.html.erb') |
| 175 | end | 169 | end |
| 176 | end | 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 | def calc_percentage_registration person | 179 | def calc_percentage_registration person |
| 179 | required_list = profile_required_list | 180 | required_list = profile_required_list |
| 180 | empty_fields = profile_required_empty_list person | 181 | empty_fields = profile_required_empty_list person |
| @@ -185,25 +186,13 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -185,25 +186,13 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 185 | percentege | 186 | percentege |
| 186 | end | 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 | end | 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 | def profile_required_list | 196 | def profile_required_list |
| 208 | required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] | 197 | required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] |
| 209 | end | 198 | end |
| @@ -0,0 +1,13 @@ | @@ -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,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 | jQuery(document).ready(function(){ | 76 | jQuery(document).ready(function(){ |
| 87 | jQuery('#secondary_email_field').blur( | 77 | jQuery('#secondary_email_field').blur( |
| 88 | validate_email_format | 78 | validate_email_format |
| @@ -92,8 +82,6 @@ jQuery(document).ready(function(){ | @@ -92,8 +82,6 @@ jQuery(document).ready(function(){ | ||
| 92 | put_brazil_based_on_email | 82 | put_brazil_based_on_email |
| 93 | ); | 83 | ); |
| 94 | 84 | ||
| 95 | - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | ||
| 96 | - | ||
| 97 | jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); | 85 | jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); |
| 98 | jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); }); | 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,7 +21,7 @@ | ||
| 21 | <%= @profile_edit_link %> | 21 | <%= @profile_edit_link %> |
| 22 | </td> | 22 | </td> |
| 23 | <td> | 23 | <td> |
| 24 | - <a href="#"><%= _("Hide this message") %></a> | 24 | + <%= link_to _("Hide this message"), "#", :class=>"hide-incomplete-percentage" %></a> |
| 25 | </td> | 25 | </td> |
| 26 | </tr> | 26 | </tr> |
| 27 | </table> | 27 | </table> |