make notifs and follows work for all users

This commit is contained in:
Connor Turland 2017-09-03 09:07:29 -04:00
parent 3482e799fd
commit d87bb7c75c
5 changed files with 22 additions and 24 deletions

View file

@ -23,15 +23,15 @@ class UsersController < ApplicationController
if user_params[:password] == '' && user_params[:password_confirmation] == '' if user_params[:password] == '' && user_params[:password_confirmation] == ''
# not trying to change the password # not trying to change the password
if @user.update_attributes(user_params.except(:password, :password_confirmation)) if @user.update_attributes(user_params.except(:password, :password_confirmation))
update_follow_settings(@user, params[:settings]) if is_tester(@user) update_follow_settings(@user, params[:settings])
@user.image = nil if params[:remove_image] == '1' @user.image = nil if params[:remove_image] == '1'
@user.save @user.save
sign_in(@user, bypass: true) bypass_sign_in(@user)
respond_to do |format| respond_to do |format|
format.html { redirect_to root_url, notice: 'Settings updated' } format.html { redirect_to root_url, notice: 'Settings updated' }
end end
else else
sign_in(@user, bypass: true) bypass_sign_in(@user)
respond_to do |format| respond_to do |format|
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] } format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
end end

View file

@ -3,7 +3,7 @@ class FollowService
class << self class << self
def follow(entity, user, reason) def follow(entity, user, reason)
return unless user && is_tester(user) return unless user
return if (reason == 'created' || reason == 'contributed') && !should_auto_follow(entity, user, reason) return if (reason == 'created' || reason == 'contributed') && !should_auto_follow(entity, user, reason)

View file

@ -45,7 +45,6 @@
<%= form.check_box :emails_allowed, class: 'inline' %> <%= form.check_box :emails_allowed, class: 'inline' %>
Send Metamaps notifications to my email. Send Metamaps notifications to my email.
<% end %> <% end %>
<% if is_tester(@user) %>
<%= fields_for :settings, @user.settings do |settings| %> <%= fields_for :settings, @user.settings do |settings| %>
<%= settings.label :follow_topic_on_created, class: 'firstFieldText' do %> <%= settings.label :follow_topic_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_created, class: 'inline' %> <%= settings.check_box :follow_topic_on_created, class: 'inline' %>
@ -53,7 +52,7 @@
<% end %> <% end %>
<%= settings.label :follow_topic_on_contributed, class: 'firstFieldText' do %> <%= settings.label :follow_topic_on_contributed, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_contributed, class: 'inline' %> <%= settings.check_box :follow_topic_on_contributed, class: 'inline' %>
Auto-follow topics you edit. Auto-follow topics you edit
<% end %> <% end %>
<%= settings.label :follow_map_on_created, class: 'firstFieldText' do %> <%= settings.label :follow_map_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_map_on_created, class: 'inline' %> <%= settings.check_box :follow_map_on_created, class: 'inline' %>
@ -64,7 +63,6 @@
Auto-follow maps you edit. Auto-follow maps you edit.
<% end %> <% end %>
<% end %> <% end %>
<% end %>
</div> </div>
<div class="changePass" onclick="Metamaps.Account.showPass()">Change Password</div> <div class="changePass" onclick="Metamaps.Account.showPass()">Change Password</div>
<div class="toHide"> <div class="toHide">

View file

@ -38,7 +38,7 @@ class Menu extends Component {
<ul className='menuItems' style={ style }> <ul className='menuItems' style={ style }>
<li className='star' onClick={ () => { this.toggle() && onStar(map) }}>Star Map</li> <li className='star' onClick={ () => { this.toggle() && onStar(map) }}>Star Map</li>
{ !map.authorizeToEdit(currentUser) && <li className='request' onClick={ () => { this.toggle() && onRequest(map) }}>Request Access</li> } { !map.authorizeToEdit(currentUser) && <li className='request' onClick={ () => { this.toggle() && onRequest(map) }}>Request Access</li> }
{ Util.isTester(currentUser) && <li className='follow' onClick={ () => { this.toggle() && onMapFollow(map) }}>{isFollowing ? 'Unfollow' : 'Follow'}</li> } <li className='follow' onClick={ () => { this.toggle() && onMapFollow(map) }}>{isFollowing ? 'Unfollow' : 'Follow'}</li>
</ul> </ul>
</div> </div>
} }

View file

@ -53,7 +53,7 @@ class ReactTopicCard extends Component {
authorizedToEdit={authorizedToEdit} authorizedToEdit={authorizedToEdit}
updateTopic={wrappedUpdateTopic} updateTopic={wrappedUpdateTopic}
/> />
{Util.isTester(currentUser) && <Follow isFollowing={isFollowing} onTopicFollow={wrappedTopicFollow} />} <Follow isFollowing={isFollowing} onTopicFollow={wrappedTopicFollow} />
<div className="clearfloat"></div> <div className="clearfloat"></div>
</div> </div>
</div> </div>