1 class CommonLicensesController < ApplicationController
2 before_filter :authenticate_author!, :only => [:index, :show]
3 before_filter :authenticate_admin!, :only => [:list, :browse, :new, :edit, :create, :update, :destroy]
6 # GET /common_licenses.json
8 @common_licenses = CommonLicense.all
10 respond_to do |format|
11 format.html # index.html.erb
12 format.json { render json: @common_licenses }
16 # GET /common_licenses/1
17 # GET /common_licenses/1.json
19 @common_license = CommonLicense.find(params[:id])
21 respond_to do |format|
22 format.html # show.html.erb
23 format.json { render json: @common_license }
28 @common_licenses = CommonLicense.all
30 respond_to do |format|
31 format.html { render layout: 'system' }
32 format.json { render json: @common_licenses }
37 @common_license = CommonLicense.find(params[:id])
39 respond_to do |format|
40 format.html { render layout: 'system' }
41 format.json { render json: @common_license }
45 # GET /common_licenses/new
46 # GET /common_licenses/new.json
48 @common_license = CommonLicense.new
50 respond_to do |format|
51 format.html # new.html.erb
52 format.json { render json: @common_license }
56 # GET /common_licenses/1/edit
58 @common_license = CommonLicense.find(params[:id])
61 # POST /common_licenses
62 # POST /common_licenses.json
64 @common_license = CommonLicense.new(params[:common_license])
66 respond_to do |format|
67 CommonLicense.transaction do
68 if @common_license.save_save
69 format.html { redirect_to :action => :browse, :id => @common_license.id, notice: 'Common license was successfully created.' }
70 format.json { render json: @common_license, status: :created, location: @common_license }
72 format.html { render action: "new" }
73 format.json { render json: @common_license.errors, status: :unprocessable_entity }
79 # PUT /common_licenses/1
80 # PUT /common_licenses/1.json
82 @common_license = CommonLicense.find(params[:id])
84 respond_to do |format|
85 if @common_license.update_attributes(params[:common_license])
86 format.html { redirect_to :action => :browse, :id => @common_license.id, notice: 'Common license was successfully updated.' }
87 format.json { head :ok }
89 format.html { render action: "edit" }
90 format.json { render json: @common_license.errors, status: :unprocessable_entity }
95 # DELETE /common_licenses/1
96 # DELETE /common_licenses/1.json
98 @common_license = CommonLicense.find(params[:id])
99 @common_license.destroy
101 respond_to do |format|
102 format.html { redirect_to common_licenses_url }
103 format.json { head :ok }