67 lines
1.8 KiB
Ruby
67 lines
1.8 KiB
Ruby
class WebFooterCompaniesController < ApplicationController
|
|
layout 'admin'
|
|
menu_item :projects, :only => :projects
|
|
menu_item :plugins, :only => :plugins
|
|
menu_item :info, :only => :info
|
|
before_filter :require_admin
|
|
before_filter :get_type
|
|
|
|
def index
|
|
@companys =
|
|
if @type == WebFooterCompany::RELATION_TYPE[1]
|
|
WebFooterCompany.dedicators
|
|
else
|
|
WebFooterCompany.partners
|
|
end
|
|
end
|
|
|
|
def new
|
|
@company ||= WebFooterCompany.new
|
|
end
|
|
|
|
def create
|
|
logger.info ""
|
|
@company = WebFooterCompany.new(params[:web_footer_company])
|
|
@company.key = (@type == WebFooterCompany::RELATION_TYPE[1]) ? WebFooterCompany::RELATION_TYPE[1] : WebFooterCompany::RELATION_TYPE[0]
|
|
if @company.save
|
|
flash[:notice] = l(:notice_successful_create)
|
|
redirect_to web_footer_companies_url(type: @type)
|
|
else
|
|
flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}"
|
|
respond_to do |format|
|
|
format.html { redirect_to new_web_footer_company_path(type: @type) }
|
|
format.api { render_validation_errors(@company) }
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@company = WebFooterCompany.find(params[:id])
|
|
@company.destroy
|
|
redirect_to web_footer_companies_url(type: @type)
|
|
end
|
|
|
|
def edit
|
|
@company = WebFooterCompany.find(params[:id])
|
|
end
|
|
|
|
def update
|
|
@company = WebFooterCompany.find(params[:id])
|
|
if @company.update_attributes(params[:web_footer_company])
|
|
flash[:notice] = l(:notice_successful_update)
|
|
redirect_to web_footer_companies_url(type: @type)
|
|
else
|
|
flash[:error] = "#{l :web_footer_company_update_fail}: #{@company.errors.full_messages[0]}"
|
|
render :action => 'edit'
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def get_type
|
|
@type = params[:type].to_s.strip
|
|
end
|
|
|
|
end
|