2014-05-17 18:57:03 +00:00
|
|
|
class MetacodesController < ApplicationController
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
before_filter :require_admin, except: [:index]
|
2014-05-17 18:57:03 +00:00
|
|
|
|
|
|
|
# GET /metacodes
|
|
|
|
# GET /metacodes.json
|
|
|
|
def index
|
2014-07-27 19:57:35 +00:00
|
|
|
|
2014-05-17 18:57:03 +00:00
|
|
|
@metacodes = Metacode.order("name").all
|
|
|
|
|
|
|
|
respond_to do |format|
|
2014-07-27 19:57:35 +00:00
|
|
|
format.html {
|
|
|
|
unless authenticated? && user.admin
|
|
|
|
redirect_to root_url, notice: "You need to be an admin for that."
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
render action: "index"
|
|
|
|
}
|
2014-05-17 18:57:03 +00:00
|
|
|
format.json { render json: @metacodes }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
### SHOW IS CURRENTLY DISABLED
|
|
|
|
# GET /metacodes/1
|
|
|
|
# GET /metacodes/1.json
|
2014-07-30 05:24:20 +00:00
|
|
|
# def show
|
|
|
|
# @metacode = Metacode.find(params[:id])
|
|
|
|
#
|
|
|
|
# respond_to do |format|
|
|
|
|
# format.html # show.html.erb
|
|
|
|
# format.json { render json: @metacode }
|
|
|
|
# end
|
|
|
|
# end
|
2014-05-17 18:57:03 +00:00
|
|
|
|
|
|
|
# GET /metacodes/new
|
|
|
|
# GET /metacodes/new.json
|
|
|
|
def new
|
|
|
|
@metacode = Metacode.new
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # new.html.erb
|
|
|
|
format.json { render json: @metacode }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /metacodes/1/edit
|
|
|
|
def edit
|
|
|
|
@metacode = Metacode.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST /metacodes
|
|
|
|
# POST /metacodes.json
|
|
|
|
def create
|
|
|
|
@metacode = Metacode.new(params[:metacode])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @metacode.save
|
|
|
|
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully created.' }
|
|
|
|
format.json { render json: @metacode, status: :created, location: metacodes_url }
|
|
|
|
else
|
|
|
|
format.html { render action: "new" }
|
|
|
|
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PUT /metacodes/1
|
|
|
|
# PUT /metacodes/1.json
|
|
|
|
def update
|
|
|
|
@metacode = Metacode.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @metacode.update_attributes(params[:metacode])
|
|
|
|
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully updated.' }
|
|
|
|
format.json { head :no_content }
|
|
|
|
else
|
|
|
|
format.html { render action: "edit" }
|
|
|
|
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
### DESTROY IS CURRENTLY DISABLED
|
|
|
|
# DELETE /metacodes/1
|
|
|
|
# DELETE /metacodes/1.json
|
2014-07-30 05:24:20 +00:00
|
|
|
# def destroy
|
|
|
|
# @metacode = Metacode.find(params[:id])
|
|
|
|
# @metacode.destroy
|
|
|
|
#
|
|
|
|
# respond_to do |format|
|
|
|
|
# format.html { redirect_to metacodes_url }
|
|
|
|
# format.json { head :no_content }
|
|
|
|
# end
|
|
|
|
# end
|
2014-05-17 18:57:03 +00:00
|
|
|
end
|