129 lines
3.6 KiB
Ruby
129 lines
3.6 KiB
Ruby
class Panel::ErEmail::BackEnd::EmailErCategorysController < OrbitBackendController
|
|
include OrbitControllerLib::DivisionForDisable
|
|
|
|
before_filter :for_app_manager,:except => [:index,:get_categorys_json]
|
|
before_filter :force_order_for_visitor,:only=>[:index,:get_categorys_json]
|
|
before_filter :force_order_for_user,:except => [:index,:get_categorys_json]
|
|
before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json]
|
|
|
|
|
|
def index
|
|
@email_er_categorys = get_categories_for_index("EmailErCategory")
|
|
@email_er_category = EmailErCategory.new(:display => 'List')
|
|
|
|
@url = panel_er_email_back_end_email_er_categorys_path
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
format.js
|
|
end
|
|
end
|
|
|
|
def get_categorys_json
|
|
categorys = EmailErCategory.all
|
|
data = Array.new
|
|
|
|
categorys.each do |c|
|
|
data << {
|
|
category: c.title,
|
|
link: "#{url_for( :action => "index",
|
|
:controller => "panel/er_email/back_end/email_ers",
|
|
:format => :rss,
|
|
:only_path => false,
|
|
:inner=>true,
|
|
:category_id => c )}"
|
|
}
|
|
end
|
|
render :json => JSON.pretty_generate(data)
|
|
end
|
|
|
|
# GET /email_ers/1
|
|
# GET /email_ers/1.xml
|
|
def show
|
|
@email_er_category = EmailErCategory.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
format.html # show.html.erb
|
|
format.js
|
|
end
|
|
end
|
|
|
|
# GET /email_ers/new
|
|
# GET /email_ers/new.xml
|
|
def new
|
|
@email_er_category = EmailErCategory.new(:display => 'List')
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.js
|
|
end
|
|
end
|
|
|
|
# GET /email_ers/1/edit
|
|
def edit
|
|
@email_er_category = EmailErCategory.find(params[:id])
|
|
|
|
@url = panel_er_email_back_end_email_er_category_path(@email_er_category)
|
|
|
|
respond_to do |format|
|
|
format.html
|
|
format.js
|
|
end
|
|
end
|
|
|
|
# POST /email_ers
|
|
# POST /email_ers.xml
|
|
def create
|
|
@email_er_category = EmailErCategory.new(params[:email_er_category])
|
|
|
|
respond_to do |format|
|
|
if @email_er_category.save
|
|
format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.create_email_er_category_success')) }
|
|
format.js
|
|
else
|
|
format.html { render :action => "new" }
|
|
format.js { render action: "new" }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PUT /email_ers/1
|
|
# PUT /email_ers/1.xml
|
|
def update
|
|
@email_er_category = EmailErCategory.find(params[:id])
|
|
|
|
@url = panel_er_email_back_end_email_er_category_path(@email_er_category)
|
|
|
|
respond_to do |format|
|
|
if @email_er_category.update_attributes(params[:email_er_category])
|
|
format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.update_email_er_category_success')) }
|
|
# format.xml { head :ok }
|
|
format.js
|
|
else
|
|
format.html { render :action => "edit" }
|
|
format.js { render :action => "edit" }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /email_ers/1
|
|
# DELETE /email_ers/1.xml
|
|
def destroy
|
|
@email_er_category = EmailErCategory.find(params[:id])
|
|
@email_er_category.disable = @email_er_category.disable ? false : true
|
|
|
|
if @email_er_category.save!
|
|
respond_to do |format|
|
|
flash[:notice] = t("update.success_")
|
|
# flash[:error] += @email_er_category.disable ? t(:enable) : t(disable)
|
|
format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url) }
|
|
# format.xml { head :ok }
|
|
format.js
|
|
end
|
|
else
|
|
flash[:error] = t("update.fail")
|
|
format.html { render :action => "index" }
|
|
end
|
|
end
|
|
end
|