removed last_edited from map model, and set up code to update map updated_at column whenever certain events happen that update the map
This commit is contained in:
parent
c9aea733ad
commit
2cf04f96cb
7 changed files with 23 additions and 16 deletions
|
@ -25,6 +25,7 @@ class MappingsController < ApplicationController
|
||||||
if params[:map]
|
if params[:map]
|
||||||
if params[:map][:id]
|
if params[:map][:id]
|
||||||
@map = Map.find(params[:map][:id])
|
@map = Map.find(params[:map][:id])
|
||||||
|
@map.touch(:updated_at)
|
||||||
@mapping.map = @map
|
@mapping.map = @map
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -217,6 +217,7 @@ class MapsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@map.arranged = true
|
@map.arranged = true
|
||||||
|
@map.touch(:updated_at)
|
||||||
@map.save
|
@map.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,6 +41,8 @@ class SynapsesController < ApplicationController
|
||||||
|
|
||||||
if params[:synapse][:map]
|
if params[:synapse][:map]
|
||||||
@map = Map.find(params[:synapse][:map])
|
@map = Map.find(params[:synapse][:map])
|
||||||
|
@map.touch(:updated_at)
|
||||||
|
|
||||||
@mapping = Mapping.new()
|
@mapping = Mapping.new()
|
||||||
@mapping.category = "Synapse"
|
@mapping.category = "Synapse"
|
||||||
@mapping.user = @user
|
@mapping.user = @user
|
||||||
|
@ -104,12 +106,14 @@ class SynapsesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST mappings/:map_id/:synapse_id/removefrommap
|
# POST synapses/:map_id/:synapse_id/removefrommap
|
||||||
def removefrommap
|
def removefrommap
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
||||||
@mapping = Mapping.find_by_synapse_id_and_map_id(params[:synapse_id],params[:map_id])
|
@mapping = Mapping.find_by_synapse_id_and_map_id(params[:synapse_id],params[:map_id])
|
||||||
|
|
||||||
|
Map.find(params[:map_id]).touch(:updated_at)
|
||||||
|
|
||||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||||
@mapping.message 'destroy',@user.id
|
@mapping.message 'destroy',@user.id
|
||||||
|
|
||||||
|
@ -126,6 +130,9 @@ class SynapsesController < ApplicationController
|
||||||
@synapse = Synapse.find(params[:id]).authorize_to_edit(@current)
|
@synapse = Synapse.find(params[:id]).authorize_to_edit(@current)
|
||||||
|
|
||||||
@synapse.mappings.each do |m|
|
@synapse.mappings.each do |m|
|
||||||
|
|
||||||
|
m.map.touch(:updated_at)
|
||||||
|
|
||||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||||
m.message 'destroy',@current.id
|
m.message 'destroy',@current.id
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ class TopicsController < ApplicationController
|
||||||
@mapping = nil
|
@mapping = nil
|
||||||
if params[:topic][:map]
|
if params[:topic][:map]
|
||||||
@map = Map.find(params[:topic][:map])
|
@map = Map.find(params[:topic][:map])
|
||||||
|
@map.touch(:updated_at)
|
||||||
|
|
||||||
@mapping = Mapping.new()
|
@mapping = Mapping.new()
|
||||||
@mapping.category = "Topic"
|
@mapping.category = "Topic"
|
||||||
|
@ -150,12 +151,13 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET mappings/:map_id/:topic_id/removefrommap
|
# POST topics/:map_id/:topic_id/removefrommap
|
||||||
def removefrommap
|
def removefrommap
|
||||||
@current = current_user
|
@current = current_user
|
||||||
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
|
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
|
||||||
|
|
||||||
@map = Map.find(params[:map_id])
|
@map = Map.find(params[:map_id])
|
||||||
|
@map.touch(:updated_at)
|
||||||
@topic = Topic.find(params[:topic_id])
|
@topic = Topic.find(params[:topic_id])
|
||||||
@mappings = @map.mappings.select{|m|
|
@mappings = @map.mappings.select{|m|
|
||||||
if m.synapse != nil
|
if m.synapse != nil
|
||||||
|
@ -194,6 +196,10 @@ class TopicsController < ApplicationController
|
||||||
|
|
||||||
@synapses.each do |synapse|
|
@synapses.each do |synapse|
|
||||||
synapse.mappings.each do |m|
|
synapse.mappings.each do |m|
|
||||||
|
|
||||||
|
@map = m.map
|
||||||
|
@map.touch(:updated_at)
|
||||||
|
|
||||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||||
m.message 'destroy',@current.id
|
m.message 'destroy',@current.id
|
||||||
|
|
||||||
|
@ -204,6 +210,10 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@mappings.each do |mapping|
|
@mappings.each do |mapping|
|
||||||
|
|
||||||
|
@map = mapping.map
|
||||||
|
@map.touch(:updated_at)
|
||||||
|
|
||||||
#push notify to anyone viewing a map with this topic in realtime (see mapping.rb to understand the 'message' action)
|
#push notify to anyone viewing a map with this topic in realtime (see mapping.rb to understand the 'message' action)
|
||||||
mapping.message 'destroy',@current.id
|
mapping.message 'destroy',@current.id
|
||||||
|
|
||||||
|
|
|
@ -33,18 +33,6 @@ end
|
||||||
return contributors
|
return contributors
|
||||||
end
|
end
|
||||||
|
|
||||||
#return the date of the last edit (mapping updated) to the map
|
|
||||||
def last_edited
|
|
||||||
date = self.created_at
|
|
||||||
self.mappings.each do |m|
|
|
||||||
if m.updated_at > date
|
|
||||||
date = m.updated_at
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return date
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
###### JSON ######
|
###### JSON ######
|
||||||
#build a json object of a map
|
#build a json object of a map
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<%= best_in_place map, :desc, :type => :textarea, :nil => "<span class='gray'>Click to add description.</span>", :classes => 'best_in_place_desc' %>
|
<%= best_in_place map, :desc, :type => :textarea, :nil => "<span class='gray'>Click to add description.</span>", :classes => 'best_in_place_desc' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span><%= pluralize(map.contributors.count, 'contributor') %></span><span>Last edit <%= time_ago_in_words( map.last_edited ) %> ago</span>
|
<span><%= pluralize(map.contributors.count, 'contributor') %></span><span>Last edit <%= time_ago_in_words( map.updated_at ) %> ago</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
<div class="mapInfoMeta">
|
<div class="mapInfoMeta">
|
||||||
<p>Created by <%= @map.user.name %> on <%= @map.created_at.strftime("%m/%d/%Y") %></p>
|
<p>Created by <%= @map.user.name %> on <%= @map.created_at.strftime("%m/%d/%Y") %></p>
|
||||||
<p>Last edited <%= @map.last_edited.strftime("%m/%d/%Y") %></p>
|
<p>Last edited <%= @map.updated_at.strftime("%m/%d/%Y") %></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mapInfoDelete">
|
<div class="mapInfoDelete">
|
||||||
|
|
Loading…
Reference in a new issue