Orbit/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/back_end/writing_conference_category...

146 lines
4.0 KiB
Ruby

class Panel::PersonalConference::BackEnd::WritingConferenceCategorysController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :force_order_for_visitor,:only=>[:index,:show]
before_filter :force_order_for_user,:except => [:index,:show]
before_filter :for_app_manager,:except => [:index]
def index
get_types
@writing_conference_categorys = @types.all
@writing_conference_category = @types.new(:display => 'List')
# @url = panel_personal_conference_back_end_writing_conference_categorys_path
@url = eval("panel_personal_conference_back_end_#{@app_type}s_path")
respond_to do |format|
format.html # index.html.erb
format.js
end
end
# GET /writing_conferences/1
# GET /writing_conferences/1.xml
def show
get_types
@writing_conference_category = @types.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.js
end
end
# GET /writing_conferences/new
# GET /writing_conferences/new.xml
def new
get_types
@writing_conference_category = @types.new(:display => 'List')
@verb = :post
respond_to do |format|
format.html # new.html.erb
format.js
end
end
# GET /writing_conferences/1/edit
def edit
get_types
@writing_conference_category = @types.find(params[:id])
# @url = panel_personal_conference_back_end_writing_conference_category_path(@writing_conference_category)
# @url = eval("panel_personal_conference_back_end_#{@app_type}_path(@writing_conference_category)")
@url = polymorphic_path([:panel, :personal_conference, :back_end, @writing_conference_category])
@verb = :put
respond_to do |format|
format.html
format.js
end
end
# POST /writing_conferences
# POST /writing_conferences.xml
def create
get_types
@writing_conference_category = @types.new(params[:writing_conference_category])
respond_to do |format|
if @writing_conference_category.save
format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url, :notice => t('writing_conference_category.create_writing_conference_category_success')) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /writing_conferences/1
# PUT /writing_conferences/1.xml
def update
get_types
@writing_conference_category = @types.find(params[:id])
# debugger
# @url = panel_personal_conference_back_end_writing_conference_category_path(@writing_conference_category)
# @url = eval("panel_personal_conference_back_end_#{@app_type}_path(#{@writing_conference_category})")
@url = polymorphic_path([:panel, :personal_conference, :back_end, @writing_conference_category])
respond_to do |format|
if @writing_conference_category.update_attributes(params[:writing_conference_category])
format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url, :notice => t('writing_conference_category.update_writing_conference_category_success')) }
# format.xml { head :ok }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
# DELETE /writing_conferences/1
# DELETE /writing_conferences/1.xml
def destroy
get_types
@writing_conference_category = @types.find(params[:id])
@writing_conference_category.disable = @writing_conference_category.disable ? false : true
if @writing_conference_category.save!
respond_to do |format|
format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("writing_conference_category.update_failed")
format.html { render :action => "index" }
end
end
protected
def get_types
@types = @app_type.classify.constantize
end
end