messages weren't being displayed in order
This commit is contained in:
parent
26025d6ee9
commit
616dc9ed0e
1 changed files with 11 additions and 11 deletions
|
@ -34,7 +34,7 @@ class MapsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
if @request == "active" && authenticated?
|
if @request == "active" && authenticated?
|
||||||
redirect_to root_url and return
|
redirect_to root_url and return
|
||||||
end
|
end
|
||||||
|
@ -55,17 +55,17 @@ class MapsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
@allmappers = @map.contributors
|
@allmappers = @map.contributors
|
||||||
@alltopics = @map.topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
@alltopics = @map.topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||||
@allsynapses = @map.synapses.to_a.delete_if {|s| s.permission == "private" && (!authenticated? || (authenticated? && @current.id != s.user_id)) }
|
@allsynapses = @map.synapses.to_a.delete_if {|s| s.permission == "private" && (!authenticated? || (authenticated? && @current.id != s.user_id)) }
|
||||||
@allmappings = @map.mappings.to_a.delete_if {|m|
|
@allmappings = @map.mappings.to_a.delete_if {|m|
|
||||||
object = m.mappable
|
object = m.mappable
|
||||||
!object || (object.permission == "private" && (!authenticated? || (authenticated? && @current.id != object.user_id)))
|
!object || (object.permission == "private" && (!authenticated? || (authenticated? && @current.id != object.user_id)))
|
||||||
}
|
}
|
||||||
@allmessages = @map.messages
|
@allmessages = @map.messages.sort_by(&:created_at)
|
||||||
|
|
||||||
respond_with(@allmappers, @allmappings, @allsynapses, @alltopics, @allmessages, @map)
|
respond_with(@allmappers, @allmappings, @allsynapses, @alltopics, @allmessages, @map)
|
||||||
}
|
}
|
||||||
format.json { render json: @map }
|
format.json { render json: @map }
|
||||||
format.csv { send_data @map.to_csv }
|
format.csv { send_data @map.to_csv }
|
||||||
|
@ -86,7 +86,7 @@ class MapsController < ApplicationController
|
||||||
@allmappers = @map.contributors
|
@allmappers = @map.contributors
|
||||||
@alltopics = @map.topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
@alltopics = @map.topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||||
@allsynapses = @map.synapses.to_a.delete_if {|s| s.permission == "private" && (!authenticated? || (authenticated? && @current.id != s.user_id)) }
|
@allsynapses = @map.synapses.to_a.delete_if {|s| s.permission == "private" && (!authenticated? || (authenticated? && @current.id != s.user_id)) }
|
||||||
@allmappings = @map.mappings.to_a.delete_if {|m|
|
@allmappings = @map.mappings.to_a.delete_if {|m|
|
||||||
object = m.mappable
|
object = m.mappable
|
||||||
!object || (object.permission == "private" && (!authenticated? || (authenticated? && @current.id != object.user_id)))
|
!object || (object.permission == "private" && (!authenticated? || (authenticated? && @current.id != object.user_id)))
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ class MapsController < ApplicationController
|
||||||
@json['synapses'] = @allsynapses
|
@json['synapses'] = @allsynapses
|
||||||
@json['mappings'] = @allmappings
|
@json['mappings'] = @allmappings
|
||||||
@json['mappers'] = @allmappers
|
@json['mappers'] = @allmappers
|
||||||
@json['messages'] = @map.messages
|
@json['messages'] = @map.messages.sort_by(&:created_at)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render json: @json }
|
format.json { render json: @json }
|
||||||
|
@ -112,7 +112,7 @@ class MapsController < ApplicationController
|
||||||
@map.desc = params[:desc]
|
@map.desc = params[:desc]
|
||||||
@map.permission = params[:permission]
|
@map.permission = params[:permission]
|
||||||
@map.user = @user
|
@map.user = @user
|
||||||
@map.arranged = false
|
@map.arranged = false
|
||||||
|
|
||||||
if params[:topicsToMap]
|
if params[:topicsToMap]
|
||||||
@all = params[:topicsToMap]
|
@all = params[:topicsToMap]
|
||||||
|
@ -161,7 +161,7 @@ class MapsController < ApplicationController
|
||||||
@map = Map.find(params[:id]).authorize_to_edit(@current)
|
@map = Map.find(params[:id]).authorize_to_edit(@current)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if !@map
|
if !@map
|
||||||
format.json { render json: "unauthorized" }
|
format.json { render json: "unauthorized" }
|
||||||
elsif @map.update_attributes(map_params)
|
elsif @map.update_attributes(map_params)
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
|
@ -184,7 +184,7 @@ class MapsController < ApplicationController
|
||||||
data.content_type = "image/png"
|
data.content_type = "image/png"
|
||||||
@map.screenshot = data
|
@map.screenshot = data
|
||||||
end
|
end
|
||||||
|
|
||||||
if @map.save
|
if @map.save
|
||||||
render :json => {:message => "Successfully uploaded the map screenshot."}
|
render :json => {:message => "Successfully uploaded the map screenshot."}
|
||||||
else
|
else
|
||||||
|
@ -204,7 +204,7 @@ class MapsController < ApplicationController
|
||||||
@map.delete if @map
|
@map.delete if @map
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json {
|
||||||
if @map
|
if @map
|
||||||
render json: "success"
|
render json: "success"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue