include ability to unfollow from email
This commit is contained in:
parent
013e3c7f21
commit
2b34d84715
14 changed files with 69 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class MapsController < ApplicationController
|
class MapsController < ApplicationController
|
||||||
before_action :require_user, only: [:create, :update, :destroy, :events, :follow, :unfollow]
|
before_action :require_user, only: [:create, :update, :destroy, :events, :follow, :unfollow]
|
||||||
before_action :set_map, only: [:show, :conversation, :update, :destroy, :contains, :events, :export, :follow, :unfollow]
|
before_action :set_map, only: [:show, :conversation, :update, :destroy, :contains, :events, :export, :follow, :unfollow, :unfollow_from_email]
|
||||||
after_action :verify_authorized
|
after_action :verify_authorized
|
||||||
|
|
||||||
# GET maps/:id
|
# GET maps/:id
|
||||||
|
@ -164,6 +164,17 @@ class MapsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET maps/:id/unfollow_from_email
|
||||||
|
def unfollow_from_email
|
||||||
|
FollowService.unfollow(@map, current_user)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
redirect_to map_path(@map), notice: 'You are no longer following this map'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_map
|
def set_map
|
||||||
|
|
|
@ -3,7 +3,9 @@ class TopicsController < ApplicationController
|
||||||
include TopicsHelper
|
include TopicsHelper
|
||||||
|
|
||||||
before_action :require_user, only: [:create, :update, :destroy, :follow, :unfollow]
|
before_action :require_user, only: [:create, :update, :destroy, :follow, :unfollow]
|
||||||
before_action :set_topic, only: [:show, :update, :relative_numbers, :relatives, :network, :destroy, :follow, :unfollow]
|
before_action :set_topic, only: [:show, :update, :relative_numbers,
|
||||||
|
:relatives, :network, :destroy,
|
||||||
|
:follow, :unfollow, :unfollow_from_email]
|
||||||
after_action :verify_authorized, except: :autocomplete_topic
|
after_action :verify_authorized, except: :autocomplete_topic
|
||||||
|
|
||||||
respond_to :html, :js, :json
|
respond_to :html, :js, :json
|
||||||
|
@ -185,6 +187,17 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET topics/:id/unfollow_from_email
|
||||||
|
def unfollow_from_email
|
||||||
|
FollowService.unfollow(@topic, current_user)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
redirect_to topic_path(@topic), notice: 'You are no longer following this topic'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_topic
|
def set_topic
|
||||||
|
|
0
app/views/map_mailer/_unfollow.html.erb
Normal file
0
app/views/map_mailer/_unfollow.html.erb
Normal file
0
app/views/map_mailer/_unfollow.text.erb
Normal file
0
app/views/map_mailer/_unfollow.text.erb
Normal file
4
app/views/topic_mailer/_unfollow.html.erb
Normal file
4
app/views/topic_mailer/_unfollow.html.erb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<hr>
|
||||||
|
<% topic = @entity || entity %>
|
||||||
|
You are receiving this email because you are following this topic.
|
||||||
|
<%= link_to 'Unfollow', unfollow_from_email_topic_url(topic) %>
|
3
app/views/topic_mailer/_unfollow.text.erb
Normal file
3
app/views/topic_mailer/_unfollow.text.erb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<% topic = @entity || entity %>
|
||||||
|
You are receiving this email because you are following this topic.
|
||||||
|
To unfollow, go to: <%= unfollow_from_email_topic_url(topic) %>
|
|
@ -9,3 +9,5 @@
|
||||||
|
|
||||||
<%= link_to 'Go to Topic', topic_url(topic), style: button_style %>
|
<%= link_to 'Go to Topic', topic_url(topic), style: button_style %>
|
||||||
<%= link_to 'Go to Map', map_url(event.map), style: button_style %>
|
<%= link_to 'Go to Map', map_url(event.map), style: button_style %>
|
||||||
|
|
||||||
|
<%= render :partial => 'topic_mailer/unfollow' %>
|
|
@ -4,3 +4,5 @@
|
||||||
|
|
||||||
topic_url(topic)
|
topic_url(topic)
|
||||||
map_url(event.map)
|
map_url(event.map)
|
||||||
|
|
||||||
|
<%= render :partial => 'topic_mailer/unfollow' %>
|
|
@ -13,3 +13,5 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<%= link_to 'View the connection', topic_url(topic1), style: button_style %>
|
<%= link_to 'View the connection', topic_url(topic1), style: button_style %>
|
||||||
|
|
||||||
|
<%= render :partial => 'topic_mailer/unfollow' %>
|
|
@ -6,3 +6,5 @@
|
||||||
<%= synapse.desc.length > 0 ? ' with the description' + synapse.desc : '' %>
|
<%= synapse.desc.length > 0 ? ' with the description' + synapse.desc : '' %>
|
||||||
|
|
||||||
<%= topic_url(topic1) %>
|
<%= topic_url(topic1) %>
|
||||||
|
|
||||||
|
<%= render :partial => 'topic_mailer/unfollow' %>
|
|
@ -50,6 +50,7 @@ Metamaps::Application.routes.draw do
|
||||||
post :unstar, to: 'stars#destroy', default: { format: :json }
|
post :unstar, to: 'stars#destroy', default: { format: :json }
|
||||||
post :follow, default: { format: :json }
|
post :follow, default: { format: :json }
|
||||||
post :unfollow, default: { format: :json }
|
post :unfollow, default: { format: :json }
|
||||||
|
get :unfollow_from_email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ Metamaps::Application.routes.draw do
|
||||||
get :relatives
|
get :relatives
|
||||||
post :follow, default: { format: :json }
|
post :follow, default: { format: :json }
|
||||||
post :unfollow, default: { format: :json }
|
post :unfollow, default: { format: :json }
|
||||||
|
get :unfollow_from_email
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :autocomplete_topic
|
get :autocomplete_topic
|
||||||
|
|
|
@ -6,12 +6,12 @@ class MapMailerPreview < ActionMailer::Preview
|
||||||
MapMailer.invite_to_edit(user_map)
|
MapMailer.invite_to_edit(user_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def access_request_email
|
def access_request
|
||||||
request = AccessRequest.first
|
request = AccessRequest.first
|
||||||
MapMailer.access_request(request)
|
MapMailer.access_request(request)
|
||||||
end
|
end
|
||||||
|
|
||||||
def access_approved_email
|
def access_approved
|
||||||
request = AccessRequest.first
|
request = AccessRequest.first
|
||||||
MapMailer.access_approved(request)
|
MapMailer.access_approved(request)
|
||||||
end
|
end
|
||||||
|
|
16
spec/mailers/previews/topic_mailer_preview.rb
Normal file
16
spec/mailers/previews/topic_mailer_preview.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
# Preview all emails at http://localhost:3000/rails/mailers/topic_mailer
|
||||||
|
class TopicMailerPreview < ActionMailer::Preview
|
||||||
|
def added_to_map
|
||||||
|
event = Event.where(kind: 'topic_added_to_map').first
|
||||||
|
user = User.first
|
||||||
|
TopicMailer.added_to_map(event, user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def connected
|
||||||
|
synapse = Synapse.first
|
||||||
|
topic = synapse.topic1
|
||||||
|
user = User.first
|
||||||
|
TopicMailer.connected(synapse, topic, user)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue