Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add country field in profiles table #396 #469

Merged
merged 12 commits into from Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -29,6 +29,8 @@ gem 'auto_html', github: 'dejan/auto_html'
gem 'postmark-rails', '>= 0.10.0'
gem 'simple_form', '~> 3.0.2'

gem 'country_select'

gem 'globalize', '~> 4.0.2'

gem 'font-awesome-rails', '~> 4.3.0.0'
Expand Down
17 changes: 16 additions & 1 deletion Gemfile.lock
Expand Up @@ -74,9 +74,16 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
countries (1.2.5)
currencies (~> 0.4.2)
i18n_data (~> 0.7.0)
country_select (2.5.2)
countries (~> 1.2.0)
sort_alphabetical (~> 1.0)
css_parser (1.2.6)
addressable
rdoc
currencies (0.4.2)
database_cleaner (1.2.0)
deadweight (0.2.2)
css_parser (~> 1.2.6)
Expand Down Expand Up @@ -227,6 +234,7 @@ GEM
hashie (3.4.2)
hike (1.2.3)
i18n (0.7.0)
i18n_data (0.7.0)
inflecto (0.0.2)
ipaddress (0.8.0)
jquery-rails (3.1.3)
Expand Down Expand Up @@ -380,6 +388,8 @@ GEM
actionpack (~> 4.0)
activemodel (~> 4.0)
slop (3.6.0)
sort_alphabetical (1.0.2)
unicode_utils (>= 1.2.2)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -403,6 +413,7 @@ GEM
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode_utils (1.4.0)
unicorn (4.9.0)
kgio (~> 2.6)
rack
Expand All @@ -427,6 +438,7 @@ DEPENDENCIES
capybara (~> 2.4.1)
carrierwave
coffee-rails (~> 4.0.1)
country_select
database_cleaner (~> 1.2.0)
deadweight
devise (~> 3.1.1)
Expand Down Expand Up @@ -466,5 +478,8 @@ DEPENDENCIES
uglifier (>= 1.0.3)
unicorn

RUBY VERSION
ruby 2.2.3p173

BUNDLED WITH
1.11.2
1.12.5
1 change: 1 addition & 0 deletions app/controllers/profiles_controller.rb
Expand Up @@ -83,6 +83,7 @@ def profile_params
:password_confirmation,
:remember_me,
:city,
:country,
:languages,
:firstname,
:lastname,
Expand Down
1 change: 1 addition & 0 deletions app/models/profile.rb
Expand Up @@ -121,6 +121,7 @@ def as_json(_options = {})
'firstname',
'lastname',
'city',
'country',
'twitter',
'created_at',
'updated_at',
Expand Down
9 changes: 9 additions & 0 deletions app/views/profiles/show.html.erb
Expand Up @@ -62,6 +62,15 @@
<%= @profile.city %></span>
</p>
<% end %>

<% if @profile.country.present? %>
<h2 class="delta sans-serif mb-">
<%= t(:country, scope: 'profiles.profile') %>
</h2>
<p class="bb pb">
<%= @profile.country %></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change the displayed information into the country name of the corresponding locale? Currently if I chose "Germany" as a country in the profile show action "DE" is displayed. It would be cool if I would see "Deutschland" in the german locale, "Germany" in the english and "Alemanha" (in the future Portuguese locale)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still looking the same. You might have to add that to the Profile Model: https://github.com/stefanpenner/country_select#getting-the-country-name-from-the-countries-gem

</p>
<% end %>
</div><!--

--><div class="layout__item 1/6 palm-1/1">
Expand Down
2 changes: 2 additions & 0 deletions app/views/shared/_profile_formfields.html.erb
Expand Up @@ -6,6 +6,8 @@
<%= f.input :email, input_html: { class: "mb input--width-100" } %>
<%= f.input :twitter, placeholder: '@', input_html: { class: "mb input--width-100" } %>
<%= f.input :city, input_html: { class: "mb input--width-100" } %>
<%= f.label :country %>
<%= f.country_select :country, label: t(:country, scope: 'activerecord.attributes.profile').html_safe, input_html: { class: "mb input--width-100" } %>
<%= f.input :languages, label: t(:languages, scope: 'activerecord.attributes.profile').html_safe, input_html: { class: "mb input--width-100" } %>
<%= f.input :website, placeholder: 'http://', input_html: { class: "mb input--width-100" } %>
<%= f.input :topic_list, label: t(:topic_list, scope: 'activerecord.attributes.profile').html_safe, input_html: { class: "mb input--width-100" } %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Expand Up @@ -187,6 +187,7 @@ en:
contact: "Contact"
website: "My website/blog:"
city: "My city:"
country: "My country"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also please add that field to the German locale? country: "Land"

twitter: "My twitter handle:"
show: "Show"
edit: "Edit profile"
Expand All @@ -207,6 +208,7 @@ en:
twitter: "Twitter"
topics: "Topics"
city: "City"
country: "Country"
language: "Language"
new:
new_profile: "New Profile"
Expand Down Expand Up @@ -252,6 +254,7 @@ en:
talks: "Talks"
languages: "Languages<br><small>Please add programming languages in 'Topics', not here</small>"
city: "City"
country: "Country"
twitter: "Twitter"
picture: "Picture"
translation: "<strong>You can fill in your maintopic and your bio both in German and English:</strong>"
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160728194836_add_column_to_profiles.rb
@@ -0,0 +1,5 @@
class AddColumnToProfiles < ActiveRecord::Migration
def change
add_column :profiles, :country, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160418192104) do
ActiveRecord::Schema.define(version: 20160728194836) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -124,6 +124,7 @@
t.string "website"
t.text "admin_comment"
t.string "slug"
t.string "country"
end

add_index "profiles", ["confirmation_token"], name: "index_profiles_on_confirmation_token", unique: true, using: :btree
Expand Down
2 changes: 2 additions & 0 deletions spec/views/profile_spec.rb
Expand Up @@ -9,6 +9,7 @@
main_topic: 'first computer programm',
bio: 'first programmer',
city: 'London',
country: 'UK',
languages: 'english, french',
topic_list: 'algorithm, mathematic'
)) }
Expand All @@ -28,6 +29,7 @@
expect(page).to have_content('Lovelace')
expect(page).to have_content('@alove')
expect(page).to have_content('London')
expect(page).to have_content('UK')
expect(page).to have_content('first programmer')
expect(page).to have_content('first computer programm')
expect(page).to have_content('algorithm')
Expand Down
1 change: 1 addition & 0 deletions test/unit/profile_test.rb
Expand Up @@ -84,6 +84,7 @@ class ProfileTest < ActiveSupport::TestCase
'lastname' => 'Lovelace',
#'languages' => 'Deutsch',
'city' => 'New York',
'country' => nil,
'twitter' => 'alove',
'created_at' => '2014-12-06T15:04:13.000Z',
'updated_at' => '2014-12-06T15:04:20.000Z',
Expand Down