diff --git a/app/assets/javascripts/organizations.js.coffee b/app/assets/javascripts/organizations.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/organizations.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/app/assets/stylesheets/organizations.css.scss b/app/assets/stylesheets/organizations.css.scss
new file mode 100644
index 000000000..39819880e
--- /dev/null
+++ b/app/assets/stylesheets/organizations.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the organizations controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
new file mode 100644
index 000000000..1d0edbd7e
--- /dev/null
+++ b/app/controllers/organizations_controller.rb
@@ -0,0 +1,15 @@
+class OrganizationsController < ApplicationController
+ def new
+ @organization = Organization.new
+ render :layout => 'new_base'
+ end
+ def create
+ @organization = Organization.new
+ @organization.name = params[:organization][:name]
+ @organization.description = params[:organization][:description]
+ @organization.is_public = params[:organization][:is_public]
+ @organization.creator_id = User.current.id
+ member = OrgMember.new(:user_id => User.current.id, :role => 'Manager')
+ @organization.org_members << member
+ end
+end
diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb
index 10321ba16..24cc9a80e 100644
--- a/app/helpers/organizations_helper.rb
+++ b/app/helpers/organizations_helper.rb
@@ -1,2 +1,2 @@
-module EnterprisesHelper
+module OrganizationsHelper
end
diff --git a/app/models/org_member.rb b/app/models/org_member.rb
new file mode 100644
index 000000000..c4be034fe
--- /dev/null
+++ b/app/models/org_member.rb
@@ -0,0 +1,4 @@
+class OrgMember < ActiveRecord::Base
+ attr_accessible :organization_id, :role, :user_id
+ belongs_to :organization
+end
diff --git a/app/models/organization.rb b/app/models/organization.rb
index 5f52dee98..39b5900d9 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -1,5 +1,5 @@
class Organization < ActiveRecord::Base
- attr_accessible :logo_link, :name
-
+ attr_accessible :name, :description, :creator_id, :home_id, :domain, :is_public
+ has_many :org_members, :dependent => :destroy
has_many :projects
end
diff --git a/app/views/layouts/new_base.html.erb b/app/views/layouts/new_base.html.erb
index 6ab83d393..a2bbee9e3 100644
--- a/app/views/layouts/new_base.html.erb
+++ b/app/views/layouts/new_base.html.erb
@@ -13,7 +13,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
- <%= stylesheet_link_tag 'public', 'leftside', 'courses','header','prettify'%>
+ <%= stylesheet_link_tag 'public', 'leftside', 'courses','header','prettify', 'org'%>
<%= javascript_include_tag "course","header",'prettify' %>
<%= yield :header_tags -%>
diff --git a/app/views/organizations/create.js.erb b/app/views/organizations/create.js.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb
new file mode 100644
index 000000000..de8983f02
--- /dev/null
+++ b/app/views/organizations/new.html.erb
@@ -0,0 +1,95 @@
+
+<% @nav_dispaly_organization_label = 1
+ @nav_dispaly_forum_label = 1 %>
+<%= error_messages_for 'organization' %>
+
+
<%= l(:label_organization_new)%>
+
+
+
+ <%= labelled_form_for @organization do |f| %>
+ -
+
+
+
+
+ 项目名称不能为空
+
+
+
+ -
+
+
+
+
+ -
+
+ <%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :maxlength => Project::IDENTIFIER_MAX_LENGTH,
+ value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %>
+
+
+ -
+
+
+ (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。)
+
+
+ -
+ 提交
+ <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
+
+
+ <% end%>
+
+
+
+
+<% html_title(l(:label_organization_new)) -%>
+
+
+
diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml
index 61bad2a00..54f0fbdaf 100644
--- a/config/locales/commons/zh.yml
+++ b/config/locales/commons/zh.yml
@@ -288,6 +288,10 @@ zh:
label_tags_project_name: "项目名称:"
label_projects_new_name: "项目名称"
label_tags_project_description: "项目描述"
+
+ label_organization_name: "组织名称"
+ label_organization_description: "组织描述"
+ label_organization_new: "新建组织"
label_tags_user_mail: "用户邮箱:"
label_tags_user_name: "用户名:"
diff --git a/config/routes.rb b/config/routes.rb
index 9a6b48da2..0394cdb53 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -31,6 +31,8 @@ RedmineApp::Application.routes.draw do
# Enable Grack support
# mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
+ resources :organizations
+
resources :homework_users
resources :no_uses
delete 'no_uses', :to => 'no_uses#delete'
diff --git a/db/migrate/20151102090519_create_org_members.rb b/db/migrate/20151103011119_create_org_members.rb
similarity index 76%
rename from db/migrate/20151102090519_create_org_members.rb
rename to db/migrate/20151103011119_create_org_members.rb
index 037d8a3c6..6ef208794 100644
--- a/db/migrate/20151102090519_create_org_members.rb
+++ b/db/migrate/20151103011119_create_org_members.rb
@@ -1,14 +1,11 @@
class CreateOrgMembers < ActiveRecord::Migration
- def up
+ def change
create_table :org_members do |t|
t.integer :user_id
t.integer :organization_id
t.string :role
+ t.timestamps
end
end
-
- def down
- drop_table :org_members
- end
end
diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css
new file mode 100644
index 000000000..b1dfbbcf0
--- /dev/null
+++ b/public/stylesheets/org.css
@@ -0,0 +1,6 @@
+@charset "utf-8";
+/* CSS Document */
+
+.orgName {width:130px; color:#484848;}
+.organization_r_h02{ width:970px; height:40px; background:#eaeaea; margin-bottom:10px;}
+.organization_h2{ background:#64bdd9; color:#fff; height:33px; width:90px; text-align:center; font-weight:normal; padding-top:7px; font-size:16px;}
\ No newline at end of file
diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb
new file mode 100644
index 000000000..cf00f4cf9
--- /dev/null
+++ b/spec/controllers/organizations_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe OrganizationsController, :type => :controller do
+
+end
diff --git a/spec/factories/org_members.rb b/spec/factories/org_members.rb
new file mode 100644
index 000000000..90997fd30
--- /dev/null
+++ b/spec/factories/org_members.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :org_member do
+ user_id 1
+organization_id 1
+role "MyString"
+ end
+
+end
diff --git a/spec/models/org_member_spec.rb b/spec/models/org_member_spec.rb
new file mode 100644
index 000000000..e7058e5b3
--- /dev/null
+++ b/spec/models/org_member_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe OrgMember, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end