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] == ''
# not trying to change the password
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.save
sign_in(@user, bypass: true)
bypass_sign_in(@user)
respond_to do |format|
format.html { redirect_to root_url, notice: 'Settings updated' }
end
else
sign_in(@user, bypass: true)
bypass_sign_in(@user)
respond_to do |format|
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
end

View file

@ -3,7 +3,7 @@ class FollowService
class << self
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)

View file

@ -45,24 +45,22 @@
<%= form.check_box :emails_allowed, class: 'inline' %>
Send Metamaps notifications to my email.
<% end %>
<% if is_tester(@user) %>
<%= fields_for :settings, @user.settings do |settings| %>
<%= settings.label :follow_topic_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_created, class: 'inline' %>
Auto-follow topics you create.
<% end %>
<%= settings.label :follow_topic_on_contributed, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_contributed, class: 'inline' %>
Auto-follow topics you edit.
<% end %>
<%= settings.label :follow_map_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_map_on_created, class: 'inline' %>
Auto-follow maps you create.
<% end %>
<%= settings.label :follow_map_on_contributed, class: 'firstFieldText' do %>
<%= settings.check_box :follow_map_on_contributed, class: 'inline' %>
Auto-follow maps you edit.
<% end %>
<%= fields_for :settings, @user.settings do |settings| %>
<%= settings.label :follow_topic_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_created, class: 'inline' %>
Auto-follow topics you create.
<% end %>
<%= settings.label :follow_topic_on_contributed, class: 'firstFieldText' do %>
<%= settings.check_box :follow_topic_on_contributed, class: 'inline' %>
Auto-follow topics you edit
<% end %>
<%= settings.label :follow_map_on_created, class: 'firstFieldText' do %>
<%= settings.check_box :follow_map_on_created, class: 'inline' %>
Auto-follow maps you create.
<% end %>
<%= settings.label :follow_map_on_contributed, class: 'firstFieldText' do %>
<%= settings.check_box :follow_map_on_contributed, class: 'inline' %>
Auto-follow maps you edit.
<% end %>
<% end %>
</div>

View file

@ -38,7 +38,7 @@ class Menu extends Component {
<ul className='menuItems' style={ style }>
<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> }
{ 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>
</div>
}

View file

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