Skip to content

Commit

Permalink
Merge pull request #39 from it3s/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
andersoncardoso committed Jun 11, 2014
2 parents d60d5d6 + a0814ba commit 6259b31
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 36 deletions.
11 changes: 11 additions & 0 deletions app/controllers/concerns/contributions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Contributions
extend ActiveSupport::Concern

def contributions
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.js
end
end

end
8 changes: 1 addition & 7 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class UsersController < ApplicationController
include Contributions
include PasswordResets

before_action :require_login, :only => [:edit, :update]
Expand Down Expand Up @@ -49,13 +50,6 @@ def update
end
end

def contributions
respond_to do |format|
format.html { render :layout => !request.xhr? }
format.js
end
end

private

def user_params
Expand Down
14 changes: 1 addition & 13 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
module ApplicationHelper
include Concerns::ContactsHelper

def i18n_language_names
{
:en => 'English',
:'pt-BR' => 'Português'
}
end

def current_translations
I18n.backend.send(:init_translations) unless I18n.backend.initialized?
@translations ||= I18n.backend.send(:translations)
(@translations[I18n.locale] || {}).with_indifferent_access
end
include Concerns::I18nHelper

def javascript_exists?(script)
script = "#{Rails.root}/app/assets/javascripts/#{script}.js"
Expand Down
18 changes: 18 additions & 0 deletions app/helpers/concerns/i18n_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Concerns
module I18nHelper
extend ActiveSupport::Concern

def i18n_language_names
{
:en => 'English',
:'pt-BR' => 'Português'
}
end

def current_translations
I18n.backend.send(:init_translations) unless I18n.backend.initialized?
@translations ||= I18n.backend.send(:translations)
(@translations[I18n.locale] || {}).with_indifferent_access
end
end
end
8 changes: 8 additions & 0 deletions app/models/concerns/contributable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Contributable
extend ActiveSupport::Concern

def contributors_count
#TODO return a real value
0
end
end
8 changes: 8 additions & 0 deletions app/models/concerns/contributor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Contributor
extend ActiveSupport::Concern

def contributions_count
#TODO return a real value
0
end
end
8 changes: 8 additions & 0 deletions app/models/concerns/followable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Followable
extend ActiveSupport::Concern

def followers_count
#TODO return a real value
0
end
end
12 changes: 2 additions & 10 deletions app/models/geo_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class GeoData < ActiveRecord::Base
include Contacts
include Geometry
include Taggable
include Followable
include Contributable

geojson_field :location
searchable_tags :tags
Expand All @@ -16,14 +18,4 @@ def maps_count
#TODO refactor to concern
0
end

def followers_count
#TODO refactor to concern
0
end

def contributors_count
#TODO refactor to concern
0
end
end
7 changes: 2 additions & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class User < ActiveRecord::Base
include Contacts
include Contributor
include Geometry
include Taggable
include Followable

authenticates_with_sorcery! do |config|
config.authentications_class = Authentication
Expand Down Expand Up @@ -39,11 +41,6 @@ def geojson_properties
{:name => name, :id => id}
end

def followers_count
#TODO refactor to concern
0
end

def maps_count
#TODO refactor to concern
0
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/header/_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</a>
</div>
<div class="menu-item data <%= 'active' if params[:controller] == 'geo_data' %>">
<a href="<%= url_for :controller => 'geo_data' %>">
<a href="<%= geo_data_path %>">
<%= icon "map-marker", t('header.menu.data') %>
</a>
</div>
Expand Down

0 comments on commit 6259b31

Please sign in to comment.