From e2307366f63e00961bcc1f8942044194976f743f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Mar 2015 17:42:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=BB=84=E7=BB=87=E7=9A=84?= =?UTF-8?q?=E5=A2=9E=E3=80=81=E5=88=A0=E3=80=81=E6=94=B9=E3=80=81=E6=9F=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organization_controller.rb | 45 ++++++++++++++++++++++ app/views/organization/_form.html.erb | 21 ++++++++++ app/views/organization/edit.html.erb | 25 ++++++++++++ app/views/organization/new.html.erb | 18 +++++++++ config/locales/zh.yml | 2 + 5 files changed, 111 insertions(+) create mode 100644 app/views/organization/_form.html.erb create mode 100644 app/views/organization/edit.html.erb create mode 100644 app/views/organization/new.html.erb diff --git a/app/controllers/organization_controller.rb b/app/controllers/organization_controller.rb index ef0919ced..db8295e44 100644 --- a/app/controllers/organization_controller.rb +++ b/app/controllers/organization_controller.rb @@ -1,5 +1,7 @@ class OrganizationController < ApplicationController layout 'project_base' + before_filter :require_admin, :except => [:index] + 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 @@ -7,4 +9,47 @@ class OrganizationController < ApplicationController format.html end end + + 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 end diff --git a/app/views/organization/_form.html.erb b/app/views/organization/_form.html.erb new file mode 100644 index 000000000..80cc76850 --- /dev/null +++ b/app/views/organization/_form.html.erb @@ -0,0 +1,21 @@ +<%= error_messages_for 'project' %> + +<% unless @organizations.new_record? %> +
+ <%= render :partial=>"avatar/avatar_form",:locals=> {source:@organizations} %> +
+<% end %> ++ + <%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %> +
+ + + <%#= l(:field_description)%> + + + + diff --git a/app/views/organization/edit.html.erb b/app/views/organization/edit.html.erb new file mode 100644 index 000000000..60b7c06a0 --- /dev/null +++ b/app/views/organization/edit.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@organization) do |f|%> ++ <%= render :partial=>"avatar/avatar_form",:locals=> {source:@organization} %> +
++ + <%= f.text_field :name, :required => true, :size => 60, :style => "width:290px;" %> +
+ + <%= submit_tag l(:button_create), :class => "enterprise"%> + +