Add public interests validation and show interests on user profile

This commit is contained in:
taitus
2017-06-30 15:34:27 +02:00
committed by Senén Rodero Rodríguez
parent bce28afe36
commit 19820e4432
11 changed files with 142 additions and 2 deletions

View File

@@ -25,8 +25,8 @@ 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, :official_position_badge)
params.require(:account).permit(:username, :public_activity, :public_interests, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
end
end
end
end

View File

@@ -7,6 +7,7 @@ class UsersController < ApplicationController
def show
load_filtered_activity if valid_access?
load_interest if valid_interest_access?
end
private
@@ -62,10 +63,18 @@ class UsersController < ApplicationController
@budget_investments = Budget::Investment.where(author_id: @user.id).order(created_at: :desc).page(params[:page])
end
def load_interest
@interests = Follow.interests_by(@user)
end
def valid_access?
@user.public_activity || authorized_current_user?
end
def valid_interest_access?
@user.public_interests || authorized_current_user?
end
def author?
@author ||= current_user && (current_user == @user)
end