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|%> +

+ <%=l(:label_organization_edit)%> +

+
+ <%= error_messages_for 'project' %> +

+ <%= 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"%> + +
+ <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %> + <%= javascript_tag "$('#project_name').focus();" %> +<% end %> + +<% html_title(l(:label_organization_edit)) -%> \ No newline at end of file diff --git a/app/views/organization/new.html.erb b/app/views/organization/new.html.erb new file mode 100644 index 000000000..163f4a5f5 --- /dev/null +++ b/app/views/organization/new.html.erb @@ -0,0 +1,18 @@ +<%= form_for(@organizations, :method => :post, + :name => 'new_form', + :url => {:controller => 'organization', + :action => 'create'}) do |f|%> +

+ <%=l(:label_organization_new)%> +

+
+ <%= render :partial => 'form', :locals => { :f => f } %> + + <%= submit_tag l(:button_create), :class => "enterprise"%> + +
+ <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %> + <%= javascript_tag "$('#project_name').focus();" %> +<% end %> + +<% html_title(l(:label_organization_new)) -%> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 231339a8e..72634bd2b 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -539,8 +539,10 @@ zh: label_activity_project: '项目: ' #added by bai label_organization: 组织 + label_organization_name: 组织名称 label_organization_list: 组织列表 label_organization_new: 新建组织 + label_organization_edit: 修改组织 label_project_plural: 项目列表 label_first_page_made: 首页定制 label_project_first_page: 项目托管平台首页