Commit ab84f010179a6a41004b9a2ff7059cb55a31fa80

Authored by Fabio Teixeira
1 parent 382d1404
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: Improving incomplete registration design.

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Fabio Teixeira  <fabio1079@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -150,6 +150,13 @@ 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 def incomplete_registration params
154 161 return if params.nil? or params[:user].nil?
155 162  
... ... @@ -159,21 +166,20 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
159 166 params[:user]
160 167 end
161 168  
  169 + @profile_edit_link = link_to _("Complete your registration"), "/myprofile/#{person.identifier}/profile_editor/edit"
  170 + @profile_empty_fields = profile_required_empty_list person
162 171 @percentege = calc_percentage_registration(person)
  172 +
163 173 if @percentege >= 0 and @percentege <= 100
164 174 expanded_template('mpog_software_plugin_myprofile/_incomplete_registration.html.erb')
165 175 end
166 176 end
167 177  
168 178 def calc_percentage_registration person
169   - empty_fields = 0
170   - required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"]
171   - required_list.each do |field|
172   - if person.send(field).blank?
173   - empty_fields = empty_fields + 1
174   - end
175   - end
176   - percentege = (empty_fields*100)/required_list.count
  179 + required_list = profile_required_list
  180 + empty_fields = profile_required_empty_list person
  181 +
  182 + percentege = (empty_fields.count*100)/required_list.count
177 183 person.percentage_incomplete = percentege
178 184 person.save(validate: false)
179 185 percentege
... ... @@ -182,13 +188,10 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
182 188 def add_link_to_complete_registration person
183 189 #find a better way to do it
184 190 if context.session[:hide_incomplete_percentage] != true
185   - new_url = person.public_profile_url
186   - new_url[:controller] = 'profile_editor'
187   - new_url[:action] = 'edit'
188   -
  191 + _new_url = create_url_to_edit_profile(person)
189 192 Proc::new do
190 193 content_tag(:div,
191   - link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), new_url) +
  194 + link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), _new_url) +
192 195 link_to(image_tag("/images/icon_filter_exclude.png"), "#", :class => "hide-incomplete-percentage", :alt => "Hide Incomplete Percentage"), :class=>"mpog-incomplete-percentage"
193 196 )
194 197 end
... ... @@ -201,6 +204,22 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
201 204  
202 205 protected
203 206  
  207 + def profile_required_list
  208 + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"]
  209 + end
  210 +
  211 + def profile_required_empty_list person
  212 + empty_fields = []
  213 + required_list = profile_required_list
  214 +
  215 + required_list.each do |field|
  216 + if person.send(field).blank?
  217 + empty_fields << field.sub("_"," ")
  218 + end
  219 + end
  220 + empty_fields
  221 + end
  222 +
204 223 def operating_system_transaction
205 224 OperatingSystem.transaction do
206 225 list_operating = OperatingSystemHelper.list_operating_system(context.params[:operating_system])
... ...
views/mpog_software_plugin_myprofile/_incomplete_registration.html.erb
1 1 <div id='incomplete_registration'>
2   - <%= 'Teste' %>
  2 +<span> <%= _("Incomplete registration percentage") %>: <%= @percentege %>%</span>
  3 +
  4 +<div id="profile_empty_fields">
  5 + List with fields to be filled:
  6 + <ul>
  7 + <% @profile_empty_fields.each do |field|%>
  8 + <li>
  9 + <%= field %>
  10 + </li>
  11 + <% end %>
  12 + </ul>
  13 +</div>
  14 +
  15 +<%= @profile_edit_link %>
3 16 </div>
... ...