Allowing JSON
This commit is contained in:
parent
43e2cdba78
commit
50171effad
|
@ -13,13 +13,23 @@ def index
|
||||||
# De-dupe users for the public
|
# De-dupe users for the public
|
||||||
if can? :update, Mac then
|
if can? :update, Mac then
|
||||||
@active_macs = Mac.where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).includes(:user).order("users.name ASC")
|
@active_macs = Mac.where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).includes(:user).order("users.name ASC")
|
||||||
else
|
elsif user_signed_in? then
|
||||||
@active_macs = Mac.where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).includes(:user).order("users.name ASC").group("users.name")
|
@active_macs = Mac.where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).includes(:user).order("users.name ASC").group("users.name")
|
||||||
|
else
|
||||||
|
@active_macs = Mac.select("mac, note, user_id").where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).joins(:user).order("users.name ASC").group("users.name")
|
||||||
end
|
end
|
||||||
|
|
||||||
@hidden_macs = Mac.where("macs.active = ? AND macs.hidden = ?", true, true).order("note ASC")
|
@hidden_macs = Mac.where("macs.active = ? AND macs.hidden = ?", true, true).order("note ASC")
|
||||||
|
|
||||||
@all_macs = Mac.find(:all, :order => "LOWER(mac)")
|
@all_macs = Mac.find(:all, :order => "LOWER(mac)")
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json {
|
||||||
|
@filtered_macs = Mac.select("macs.mac, users.name").where("macs.active = ? AND (macs.hidden IS NULL OR macs.hidden = ?)", true, false).joins(:user)
|
||||||
|
render :json => @filtered_macs
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /macs/1
|
# GET /macs/1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user