class LicensesController < ApplicationController
- before_filter :authenticate_user!, :only => [:index, :show]
+ layout 'test' if MagicNumber['test_layout']
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /licenses
# GET /licenses.json
def index
- @licenses = License.all
+ @licenses = License.list()
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @licenses }
+ format.json { render json: @licenses.to_json(License.list_json_opt) }
end
end
# GET /licenses/1
# GET /licenses/1.json
def show
- @license = License.find(params[:id])
- if @license.common_license
- redirect_to :controller => 'common_licenses', :action => :browse, :id => @license.common_license.id
- else
- redirect_to :controller => 'original_licenses', :action => :browse, :id => @license.original_license.id
+ @license = License.show(params[:id])
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @license.to_json(License.show_json_opt) }
end
end
+ def search
+ @licenses = License.list_by_name(params[:name])
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @licenses.to_json }
+ end
+ end
+
def list
@licenses = License.all