Enable 'Recommended debates' setting for users
This commit is contained in:
@@ -28,7 +28,7 @@ class AccountController < ApplicationController
|
||||
else
|
||||
[:username, :public_activity, :public_interests, :email_on_comment,
|
||||
:email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter,
|
||||
:official_position_badge]
|
||||
:official_position_badge, :recommended_debates]
|
||||
end
|
||||
params.require(:account).permit(*attributes)
|
||||
end
|
||||
|
||||
@@ -59,6 +59,8 @@ class DebatesController < ApplicationController
|
||||
end
|
||||
|
||||
def debates_recommendations
|
||||
return unless current_user.recommended_debates
|
||||
@recommended_debates = Debate.recommendations(current_user).sort_by_random.limit(3)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -151,7 +151,7 @@ class Debate < ActiveRecord::Base
|
||||
|
||||
def self.debates_orders(user)
|
||||
orders = %w{hot_score confidence_score created_at relevance}
|
||||
orders << "recommendations" if user.present?
|
||||
orders
|
||||
orders << "recommendations" if user&.recommended_debates
|
||||
return orders
|
||||
end
|
||||
end
|
||||
|
||||
@@ -112,6 +112,19 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if feature?("user.recommendations") %>
|
||||
<h2><%= t("account.show.recommendations") %></h2>
|
||||
|
||||
<% if feature?("user.recommendations_on_debates") %>
|
||||
<div>
|
||||
<%= f.check_box :recommended_debates, title: t("account.show.show_debates_recommendations"), label: false %>
|
||||
<span class="checkbox">
|
||||
<%= t("account.show.show_debates_recommendations") %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= f.submit t("account.show.save_changes_submit"), class: "button margin-top" %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<%= render "shared/section_header", i18n_namespace: "debates.index.section_header", image: "debates" %>
|
||||
<% end %>
|
||||
|
||||
<% if feature?("user.recommendations_on_debates") && @recommended_debates.present? %>
|
||||
<% if @recommended_debates.present? %>
|
||||
<%= render "shared/recommended_index", recommended: @recommended_debates %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ en:
|
||||
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
|
||||
recommendations: Recommendations
|
||||
show_debates_recommendations: Show debates recommendations
|
||||
title: My account
|
||||
user_permission_debates: Participate on debates
|
||||
user_permission_info: With your account you can...
|
||||
|
||||
@@ -20,6 +20,8 @@ es:
|
||||
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
|
||||
recommendations: Recomendaciones
|
||||
show_debates_recommendations: Mostrar recomendaciones en el listado de debates
|
||||
title: Mi cuenta
|
||||
user_permission_debates: Participar en debates
|
||||
user_permission_info: Con tu cuenta ya puedes...
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddRecommendedDebatesSettingToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
change_table :users do |t|
|
||||
t.boolean :recommended_debates, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1156,6 +1156,7 @@ ActiveRecord::Schema.define(version: 20180519132610) do
|
||||
t.integer "failed_email_digests_count", default: 0
|
||||
t.text "former_users_data_log", default: ""
|
||||
t.boolean "public_interests", default: false
|
||||
t.boolean "recommended_debates", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
|
||||
Reference in New Issue
Block a user