diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 9212eb4fa..c3d814b38 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -25,7 +25,7 @@ class AccountController < ApplicationController
if @account.organization?
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name])
else
- params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter)
+ params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
end
end
diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb
index 98987626d..deaa4c889 100644
--- a/app/views/account/show.html.erb
+++ b/app/views/account/show.html.erb
@@ -87,6 +87,17 @@
<% end %>
+
+ <%= f.label :official_position_badge do %>
+ <%= f.check_box :official_position_badge,
+ title: t('account.show.official_position_badge_label'),
+ label: false %>
+
+ <%= t("account.show.official_position_badge_label") %>
+
+ <% end %>
+
+
<%= f.submit t("account.show.save_changes_submit"), class: "button" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b16f1092a..608e0efab 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -17,6 +17,7 @@ en:
subscription_to_website_newsletter_label: Receive by email website relevant information
email_on_direct_message_label: Receive emails about direct messages
email_digest_label: Receive a summary of proposal notifications
+ official_position_badge_label: Show official position badge
title: My account
user_permission_debates: Participate on debates
user_permission_info: With your account you can...
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 620499ace..9678ed5c1 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -17,6 +17,7 @@ es:
subscription_to_website_newsletter_label: Recibir emails con información interesante sobre la web
email_on_direct_message_label: Recibir emails con mensajes privados
email_digest_label: Recibir resumen de notificaciones sobre propuestas
+ official_position_badge_label: Mostrar etiqueta de tipo de usuario
title: Mi cuenta
user_permission_debates: Participar en debates
user_permission_info: Con tu cuenta ya puedes...
diff --git a/db/migrate/20160617172616_add_badge_to_users.rb b/db/migrate/20160617172616_add_badge_to_users.rb
new file mode 100644
index 000000000..2f634aa49
--- /dev/null
+++ b/db/migrate/20160617172616_add_badge_to_users.rb
@@ -0,0 +1,5 @@
+class AddBadgeToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :official_position_badge, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f5671b3a3..6932611e4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160614160949) do
+ActiveRecord::Schema.define(version: 20160617172616) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -462,6 +462,7 @@ ActiveRecord::Schema.define(version: 20160614160949) do
t.boolean "email_on_proposal_notification", default: true
t.boolean "email_digest", default: true
t.boolean "email_on_direct_message", default: true
+ t.boolean "official_position_badge", default: false
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb
index 0d5da38b2..604872a58 100644
--- a/spec/features/account_spec.rb
+++ b/spec/features/account_spec.rb
@@ -37,6 +37,7 @@ feature 'Account' do
check 'account_email_on_comment_reply'
uncheck 'account_email_digest'
uncheck 'account_email_on_direct_message'
+ check 'account_official_position_badge'
click_button 'Save changes'
expect(page).to have_content "Changes saved"
@@ -48,6 +49,7 @@ feature 'Account' do
expect(find("#account_email_on_comment_reply")).to be_checked
expect(find("#account_email_digest")).to_not be_checked
expect(find("#account_email_on_direct_message")).to_not be_checked
+ expect(find("#account_official_position_badge")).to be_checked
end
scenario 'Edit Organization' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 143053c77..41455eb1d 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -95,6 +95,12 @@ describe User do
expect(subject.email_on_direct_message).to eq(true)
end
end
+
+ describe 'official_position_badge' do
+ it 'should be false by default' do
+ expect(subject.official_position_badge).to eq(false)
+ end
+ end
end
describe "administrator?" do