messages weren't being displayed in order

This commit is contained in:
Connor Turland 2016-03-01 12:55:00 +13:00
parent 26025d6ee9
commit 616dc9ed0e

View file

@ -34,7 +34,7 @@ class MapsController < ApplicationController
end
respond_to do |format|
format.html {
format.html {
if @request == "active" && authenticated?
redirect_to root_url and return
end
@ -55,17 +55,17 @@ class MapsController < ApplicationController
end
respond_to do |format|
format.html {
format.html {
@allmappers = @map.contributors
@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)) }
@allmappings = @map.mappings.to_a.delete_if {|m|
@allmappings = @map.mappings.to_a.delete_if {|m|
object = m.mappable
!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.csv { send_data @map.to_csv }
@ -86,7 +86,7 @@ class MapsController < ApplicationController
@allmappers = @map.contributors
@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)) }
@allmappings = @map.mappings.to_a.delete_if {|m|
@allmappings = @map.mappings.to_a.delete_if {|m|
object = m.mappable
!object || (object.permission == "private" && (!authenticated? || (authenticated? && @current.id != object.user_id)))
}
@ -97,7 +97,7 @@ class MapsController < ApplicationController
@json['synapses'] = @allsynapses
@json['mappings'] = @allmappings
@json['mappers'] = @allmappers
@json['messages'] = @map.messages
@json['messages'] = @map.messages.sort_by(&:created_at)
respond_to do |format|
format.json { render json: @json }
@ -112,7 +112,7 @@ class MapsController < ApplicationController
@map.desc = params[:desc]
@map.permission = params[:permission]
@map.user = @user
@map.arranged = false
@map.arranged = false
if params[:topicsToMap]
@all = params[:topicsToMap]
@ -161,7 +161,7 @@ class MapsController < ApplicationController
@map = Map.find(params[:id]).authorize_to_edit(@current)
respond_to do |format|
if !@map
if !@map
format.json { render json: "unauthorized" }
elsif @map.update_attributes(map_params)
format.json { head :no_content }
@ -184,7 +184,7 @@ class MapsController < ApplicationController
data.content_type = "image/png"
@map.screenshot = data
end
if @map.save
render :json => {:message => "Successfully uploaded the map screenshot."}
else
@ -204,7 +204,7 @@ class MapsController < ApplicationController
@map.delete if @map
respond_to do |format|
format.json {
format.json {
if @map
render json: "success"
else