users now can enable/disable some privacy settings
This commit is contained in:
parent
b3348dbfff
commit
bc94a729a6
|
@ -10,6 +10,7 @@ class UserController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# region Account settings
|
||||
def edit
|
||||
end
|
||||
|
||||
|
@ -25,11 +26,26 @@ class UserController < ApplicationController
|
|||
end
|
||||
redirect_to edit_user_profile_path
|
||||
end
|
||||
# endregion
|
||||
|
||||
def privacy
|
||||
|
||||
# region Privacy settings
|
||||
def edit_privacy
|
||||
end
|
||||
|
||||
def update_privacy
|
||||
user_attributes = params.require(:user).permit(:privacy_allow_anonymous_questions,
|
||||
:privacy_allow_public_timeline,
|
||||
:privacy_allow_stranger_answers,
|
||||
:privacy_show_in_search)
|
||||
if current_user.update_attributes(user_attributes)
|
||||
flash[:success] = 'Your privacy settings have been updated!'
|
||||
else
|
||||
flash[:error] = 'An error occurred. ;_;'
|
||||
end
|
||||
redirect_to edit_user_privacy_path
|
||||
end
|
||||
# endregion
|
||||
|
||||
def followers
|
||||
@title = 'Followers'
|
||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%ul.nav.nav-pills.nav-stacked
|
||||
= nav_entry "Account", edit_user_registration_path
|
||||
= nav_entry "Profile", edit_user_profile_path
|
||||
= nav_entry "Privacy", privacy_settings_path
|
||||
= nav_entry "Privacy", edit_user_privacy_path
|
||||
= nav_entry "Sharing", services_path
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
.container.j2-page
|
||||
= render 'settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
= render 'layouts/messages'
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
= bootstrap_form_for(current_user, url: {action: "edit_privacy"}, method: "patch") do |f|
|
||||
|
||||
= f.check_box :privacy_allow_anonymous_questions, label: "Allow anonymous questions"
|
||||
= f.check_box :privacy_allow_public_timeline, label: "Show your answers in the public timeline"
|
||||
= f.check_box :privacy_allow_stranger_answers, label: "Allow other people to answer your questions"
|
||||
|
||||
= f.submit "Save settings", class: 'btn btn-primary'
|
|
@ -1,6 +0,0 @@
|
|||
.container.j2-page
|
||||
= render 'settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
= render 'layouts/messages'
|
||||
.panel.panel-default
|
||||
.panel-body
|
|
@ -57,7 +57,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
match '/settings/privacy', to: 'user#privacy', via: :get, as: :privacy_settings
|
||||
match '/settings/privacy', to: 'user#edit_privacy', via: :get, as: :edit_user_privacy
|
||||
match '/settings/privacy', to: 'user#update_privacy', via: :patch, as: :update_user_privacy
|
||||
|
||||
namespace :ajax do
|
||||
match '/ask', to: 'question#create', via: :post, as: :ask
|
||||
|
|
Loading…
Reference in New Issue