[Git][noosfero/noosfero][api] 4 commits: Remove eager_load
Rodrigo Souto
gitlab at gitlab.com
Fri Sep 11 14:15:32 BRT 2015
Rodrigo Souto pushed to branch api at Noosfero / noosfero
Commits:
efc9e642 by Arthur Del Esposte at 2015-09-08T15:03:53Z
Remove eager_load
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
- - - - -
7863adab by Arthur Del Esposte at 2015-09-08T15:05:26Z
Load session model into session initializer
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
- - - - -
ef7c2df9 by Arthur Del Esposte at 2015-09-08T21:51:51Z
Fix broken functional tests when dont have user.
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr at gmail.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
- - - - -
8e78f277 by Thiago Ribeiro at 2015-09-11T13:11:39Z
Fix broken tests in sniffer plugin.
Using method in lib/noosfero/geo_ref.rb instead of old method.
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
- - - - -
6 changed files:
- app/views/profile_editor/_person.html.erb
- app/views/profile_editor/_person_form.html.erb
- − config/initializers/eager_load.rb
- config/initializers/session.rb
- plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
- plugins/sniffer/lib/sniffer_plugin/helper.rb
Changes:
=====================================
app/views/profile_editor/_person.html.erb
=====================================
--- a/app/views/profile_editor/_person.html.erb
+++ b/app/views/profile_editor/_person.html.erb
@@ -18,6 +18,14 @@
<%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %>
+ <div class="formfieldline">
+ <%= label_tag("private_token", _("Private Token")) %>
+ <div class="formfield type-text">
+ <%= text_field_tag("a", @profile.user.private_token, :size => 30) %>
+ </div>
+ </div>
+ <%= link_to("Reset token", {:controller => :profile_editor, :action => :reset_private_token, :id => @profile.id}, :class => "button with-text") %>
+
<%= render :partial => 'person_form', :locals => {:f => f} %>
<h2><%= _('Notification options') %></h2>
=====================================
app/views/profile_editor/_person_form.html.erb
=====================================
--- a/app/views/profile_editor/_person_form.html.erb
+++ b/app/views/profile_editor/_person_form.html.erb
@@ -1,14 +1,5 @@
<% @person ||= @profile %>
-<div class="formfieldline">
- <%= label_tag("private_token", _("Private Token")) %>
- <div class="formfield type-text">
- <%= text_field_tag("a", @profile.user.private_token, :size => 30) %>
- </div>
-</div>
-
-<%= link_to("Reset token", {:controller => :profile_editor, :action => :reset_private_token, :id => @person.id}, :class => "button with-text") %>
-
<% optional_field(@person, 'nickname') do %>
<%= f.text_field(:nickname, :maxlength => 16, :size => 30, :rel => _('Nickname')) %>
<div>
=====================================
config/initializers/eager_load.rb deleted
=====================================
--- a/config/initializers/eager_load.rb
+++ /dev/null
@@ -1 +0,0 @@
-Rails.application.eager_load!
=====================================
config/initializers/session.rb
=====================================
--- a/config/initializers/session.rb
+++ b/config/initializers/session.rb
@@ -1,4 +1,5 @@
ActionDispatch::Reloader.to_prepare do
+ require_relative '../../app/models/session'
ActiveRecord::SessionStore.session_class = Session
end
=====================================
plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
=====================================
--- a/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
+++ b/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
@@ -38,7 +38,7 @@ class SnifferPluginMyprofileController < MyProfileController
response[:enterprises] = product_category.sniffer_plugin_enterprises.enabled.visible.map do |enterprise|
profile_data = filter_visible_attr_profile(enterprise)
profile_data[:balloonUrl] = url_for :controller => :sniffer_plugin_myprofile, :action => :map_balloon, :id => enterprise[:id], :escape => false
- profile_data[:sniffer_plugin_distance] = distance_between_profiles(@profile, enterprise)
+ profile_data[:sniffer_plugin_distance] = Noosfero::GeoRef.dist(@profile.lat, @profile.lng, enterprise.lat, enterprise.lng)
profile_data[:suppliersProducts] = filter_visible_attr_suppliers_products(
enterprise.products.sniffer_plugin_products_from_category(product_category)
)
@@ -109,7 +109,7 @@ class SnifferPluginMyprofileController < MyProfileController
profiles = Profile.all :conditions => {:id => products.map { |p| target_profile_id(p) }}
profiles_by_id = {}
profiles.each do |p|
- p[:sniffer_plugin_distance] = distance_between_profiles(@profile, p)
+ p[:sniffer_plugin_distance] = Noosfero::GeoRef.dist(@profile.lat, @profile.lng, p.lat, p.lng)
profiles_by_id[p.id] ||= p
end
profiles_by_id
=====================================
plugins/sniffer/lib/sniffer_plugin/helper.rb
=====================================
--- a/plugins/sniffer/lib/sniffer_plugin/helper.rb
+++ b/plugins/sniffer/lib/sniffer_plugin/helper.rb
@@ -2,13 +2,6 @@ module SnifferPlugin::Helper
include Noosfero::GeoRef
- def distance_between_profiles(source, target)
- Math.sqrt(
- (KM_LAT * ((target.lat || 0) - (source.lat || 0)))**2 +
- (KM_LNG * ((target.lng || 0) - (source.lng || 0)))**2
- )
- end
-
def filter_visible_attr_profile(profile)
filtered_profile = {}
visible_attributes = [:id, :name, :lat, :lng, :sniffer_plugin_distance]
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/57b5f5bf85354f8908bda8d8ed5787d1399b6705...8e78f277356f11caa0ad19f9e4b38c8bc41ae45e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150911/8db34230/attachment.html>
More information about the Noosfero-dev
mailing list