2015-03-05 14:15:07 +08:00
|
|
|
class OrganizationController < ApplicationController
|
2015-07-10 11:40:07 +08:00
|
|
|
# layout 'base_projects'
|
2015-03-05 17:42:31 +08:00
|
|
|
before_filter :require_admin, :except => [:index]
|
|
|
|
|
2015-03-05 14:15:07 +08:00
|
|
|
def index
|
|
|
|
#@projects = Project.find_by_sql("SELECT * FROM projects WHERE id IN (select MAX(id) from projects GROUP BY enterprise_name)")
|
|
|
|
@organizations = Organization.all
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
end
|
|
|
|
end
|
2015-03-05 17:42:31 +08:00
|
|
|
|
|
|
|
def new
|
|
|
|
@organizations = Organization.new
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@organizations = Organization.new
|
|
|
|
@organizations.name = params[:organization][:name]
|
|
|
|
if @organizations.save
|
|
|
|
redirect_to admin_organization_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@organization = Organization.find params[:id]
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@organization = Organization.find params[:id]
|
|
|
|
@organization.name = params[:organization][:name]
|
|
|
|
if @organization.save
|
|
|
|
redirect_to admin_organization_url
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@organization = Organization.find params[:id]
|
|
|
|
if @organization.destroy
|
|
|
|
redirect_to admin_organization_url
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
render_404
|
|
|
|
end
|
2015-03-05 14:15:07 +08:00
|
|
|
end
|