class LicensesController < ApplicationController
- layout 'test' if Pettanr::TestLayout
- before_filter :authenticate_admin!, :only => [:list, :browse]
-
- # GET /licenses
- # GET /licenses.json
+ before_filter :authenticate_resource_reader, :only => [
+ :by_license_group, :by_system_picture
+ ]
+ before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+
def index
- @licenses = License.list({})
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @licenses.to_json(License.list_json_opt) }
- end
+ filer_list
end
-
- # GET /licenses/1
- # GET /licenses/1.json
+
+ def by_license_group
+ filer_list
+ end
+
+ def by_system_picture
+ filer_list
+ end
+
+ def show_html_format format
+ format.html {
+ @license = @item
+ }
+ end
+
def show
- @license = License.show(params[:id])
+ set_show
respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @license.to_json(License.show_json_include_opt) }
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
- def list
- @licenses = License.all
-
+ def search
+ @licenses = License.list_by_name(params[:name])
+
respond_to do |format|
- format.html { render layout: 'system' }
- format.json { render json: @licenses }
+ format.html
+ format.json { render json: @licenses.to_json }
end
end
-
- def browse
- @license = License.find(params[:id])
-
+
+ def new
+ form_new
+ end
+
+ def edit
+ form_edit
+ end
+
+ def create
+ set_model
+ @item = @my_model_class.new
+ @item.supply_default
+ @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+ @item.attributes = params[@my_model_class.item_name]
+ @item.overwrite
+ render_create
+ end
+
+ def update
+ set_edit
+ @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+ @item.attributes = params[@my_model_class.item_name]
+ @item.overwrite
+ render_update
+ end
+
+ def destroy
+ @item = self.class.model.edit(params[:id], @operators)
respond_to do |format|
- format.html { render layout: 'system' }
- format.json { render json: @license }
+ flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => self.class.model.model_name.human)
+ format.html { redirect_to @item }
+ format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end