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: 项目托管平台首页