diff --git a/app/assets/javascripts/org_document_comment.js.coffee b/app/assets/javascripts/org_document_comment.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_document_comment.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/javascripts/org_member.js.coffee b/app/assets/javascripts/org_member.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_member.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/javascripts/org_projects.js.coffee b/app/assets/javascripts/org_projects.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_projects.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/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/org_document_comment.css.scss b/app/assets/stylesheets/org_document_comment.css.scss new file mode 100644 index 000000000..9359415ae --- /dev/null +++ b/app/assets/stylesheets/org_document_comment.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_document_comment controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/org_member.css.scss b/app/assets/stylesheets/org_member.css.scss new file mode 100644 index 000000000..4bab7e008 --- /dev/null +++ b/app/assets/stylesheets/org_member.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the OrgMember controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/org_projects.css.scss b/app/assets/stylesheets/org_projects.css.scss new file mode 100644 index 000000000..12f4fef6a --- /dev/null +++ b/app/assets/stylesheets/org_projects.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_projects controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ 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/files_controller.rb b/app/controllers/files_controller.rb index dd8dc84c4..cbbf36ea8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -374,30 +374,29 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.run.attachments_added(attachments[:files]) end - - if params[:course_attachment_type] && params[:course_attachment_type] != "5" - case params[:course_attachment_type] - when "1" - tag_name = l(:label_courseware) - when "2" - tag_name = l(:label_software) - when "3" - tag_name = l(:label_media) - when "4" - tag_name = l(:label_code) - when "6" - tag_name = "论文" - else - tag_name = "" + if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array) + params[:course_attachment_type].each do |type| + tag_name = get_tag_name_by_type_number type + if !attachments.empty? && attachments[:files] && tag_name != "" + attachments[:files].each do |attachment| + attachment.tag_list.add(tag_name) + attachment.save + end + end end - if !attachments.empty? && attachments[:files] && tag_name != "" - attachments[:files].each do |attachment| - attachment.tag_list.add(tag_name) - attachment.save + else + if params[:course_attachment_type] && params[:course_attachment_type] != "5" + tag_name = get_tag_name_by_type_number params[:course_attachment_type] + if !attachments.empty? && attachments[:files] && tag_name != "" + attachments[:files].each do |attachment| + attachment.tag_list.add(tag_name) + attachment.save + end end end end + # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", @@ -424,6 +423,23 @@ class FilesController < ApplicationController end end + def get_tag_name_by_type_number type + case type + when "1" + tag_name = l(:label_courseware) + when "2" + tag_name = l(:label_software) + when "3" + tag_name = l(:label_media) + when "4" + tag_name = l(:label_code) + when "6" + tag_name = "论文" + else + tag_name = "" + end + end + def tag_saveEx @tags = params[:tag_name][:name] @obj_id = params[:object_id] diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 5d83c1320..be2b44c06 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -74,10 +74,10 @@ class NewsController < ApplicationController @q = params[:subject] if params[:subject].nil? || params[:subject].blank? scope_order = scope.all(:include => [:author, :course], - :order => "#{News.table_name}.created_on DESC") + :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") else scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course], - :order => "#{News.table_name}.created_on DESC") + :order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") end # :offset => @offset, diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb new file mode 100644 index 000000000..60522dc3f --- /dev/null +++ b/app/controllers/org_document_comments_controller.rb @@ -0,0 +1,63 @@ +class OrgDocumentCommentsController < ApplicationController + before_filter :find_organization, :only => [:new, :create, :show, :index] + + layout 'base_org' + + def new + @org_document_comment = OrgDocumentComment.new + end + + def create + @org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id) + @org_document_comment.title = params[:org_document_comment][:title] + @org_document_comment.content = params[:org_document_comment][:content] + if @org_document_comment.save + #flash[:notice] = 'success' + OrgActivity + redirect_to organization_org_document_comments_path(@organization) + else + redirect_to new_org_document_comment_path(:organization_id => @organization.id) + end + end + def show + + end + + def index + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + end + def update + @org_document = OrgDocumentComment.find(params[:id]) + @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content]) + respond_to do |format| + format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)} + end + end + + def edit + @org_document = OrgDocumentComment.find(params[:id]) + @organization = Organization.find(params[:organization_id]) + end + + def add_reply + @document = OrgDocumentComment.find(params[:id]).root + @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:org_content] + @document.children << @comment + @document.save + end + + def find_organization + @organization = Organization.find(params[:organization_id]) + end + + def destroy + @org_document_comment = OrgDocumentComment.find(params[:id]) + org = @org_document_comment.organization + if @org_document_comment.destroy + if @org_document_comment.id == org.id + org.home_id == nil + end + end + end +end diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb new file mode 100644 index 000000000..4b842f9dc --- /dev/null +++ b/app/controllers/org_member_controller.rb @@ -0,0 +1,57 @@ +class OrgMemberController < ApplicationController + + def org_member_autocomplete + @org = Organization.find(params[:org]) + @flag = params[:flag] || false + respond_to do |format| + format.js + end + end + + def create + @org = Organization.find(params[:org]) + if params[:membership].nil? + @fail_hint = l(:label_blank_user_lists_for_org) + else + member_ids = params[:membership][:user_ids] + role_id = params[:orgRole] + member_ids.each do |user_id| + member = OrgMember.create(:user_id=>user_id) + @org.org_members << member + OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) + end + end + respond_to do |format| + format.js + end + end + + def update + @member = OrgMember.find(params[:id]) + #@member.change_role params[:org_member][:role_ids] + @member_role = @member.org_member_roles[0] + @member_role.role_id = params[:org_member][:role_ids][0] + @member_role.save + @org = @member.organization + respond_to do |format| + format.js + end + end + + def new + + end + + def destroy + member = OrgMember.find(params[:id]) + @org = member.organization + member.destroy + respond_to do |format| + format.js + end + end + + def index + + end +end diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb new file mode 100644 index 000000000..733df95b7 --- /dev/null +++ b/app/controllers/org_projects_controller.rb @@ -0,0 +1,31 @@ +class OrgProjectsController < ApplicationController + def create + org_ids = params[:orgNames] + @project = Project.find(params[:project_id]) + org_ids.each do |org_id| + OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) + p 1 + end + respond_to do |format| + format.js + end + end + def destroy + @project = Project.find(params[:project_id]) + @org_project = OrgProject.find(params[:id]) + @org_project.destroy + + condition = '%%' + project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id) + if project_org_ids.empty? + @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + project_org_ids = "(" + project_org_ids.join(',') + ")" + @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10) + @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,1 + end +end diff --git a/app/controllers/organization_controller.rb b/app/controllers/organization_controller.rb deleted file mode 100644 index 748fc1732..000000000 --- a/app/controllers/organization_controller.rb +++ /dev/null @@ -1,55 +0,0 @@ -class OrganizationController < ApplicationController - # layout 'base_projects' - 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 - respond_to do |format| - 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/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb new file mode 100644 index 000000000..b75742164 --- /dev/null +++ b/app/controllers/organizations_controller.rb @@ -0,0 +1,149 @@ +# encoding: utf-8 +class OrganizationsController < ApplicationController + + + helper :sort + include SortHelper + helper :custom_fields + include CustomFieldsHelper + include AvatarHelper + include WordsHelper + include GitlabHelper + include UserScoreHelper + + include PollHelper + helper :user_score + helper :journals + + # added by liuping 关注 + + helper :watchers + helper :activities + + ### added by william + include ActsAsTaggableOn::TagsHelper + + # fq + helper :words + helper :project_score + helper :issues + include UsersHelper + before_filter :find_organization, :only => [:show, :members] + layout 'base_org' + def index + + end + 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) + + @organization.org_members << member + if @organization.save + OrgMemberRole.create(:org_member_id => member.id, :role_id => 11) + redirect_to organization_path(@organization) + end + end + + def show + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @organization = Organization.find(params[:id]) + @org_activities = OrgActivity.where('container_id =? and container_type =? ', + @organization.id, 'Organization ').order('updated_at desc').page(params[:page]).per(10) + @org_activities_count = OrgActivity.where('container_id =? and container_type =? ', + @organization.id, 'Organization ').order('updated_at desc').count + project_ids = @organization.projects.map(&:id) << 0 + @org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10) + @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count + #@org_activities = paginateHelper @org_activities, 10 + @page = params[:page] + else + render_403 + end + respond_to do |format| + format.html + format.js + end + end + + def update + @organization = Organization.find(params[:id]) + @organization.name = params[:organization][:name] + @organization.description = params[:organization][:description] + @organization.domain = params[:organization][:domain] + @organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0 + #@organization.name = params[:organization][:name] + @organization.save + respond_to do |format| + format.html { redirect_to setting_organization_path(@organization)} + end + end + + def check_uniq + @check = false; + @org_name = params[:org_name].strip + @config_page = params[:config_page] + sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0 + if sameName == true + @check = true + end + respond_to do |format| + format.js + end + end + + def find_organization + @organization = Organization.find(params[:id]) + end + + def setting + @organization = Organization.find(params[:id]) + + if User.current.admin? || User.current.admin_of_org?(@organization) + else + render_403 + end + end + + + def clear_org_avatar_temp + + end + + def set_homepage + @org = Organization.find(params[:id]) + @org.home_id = params[:home_id] + @org.save + # respond_to do |format| + # format.html {redirect_to organization_path(org)} + # end + end + + def autocomplete_search + @project = Project.find(params[:project_id]) + #@flag = params[:flag] || false + respond_to do |format| + format.js + end + end + + def members + @members = OrgMember.where("organization_id =?", @organization.id) + end + + def more_org_projects + @organization = Organization.find params[:id] + @page = params[:page] + @org_projects = @organization.org_projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + respond_to do |format| + format.js + end + end +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 065adf596..baa7db060 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -69,6 +69,29 @@ class ProjectsController < ApplicationController ### added by william include ActsAsTaggableOn::TagsHelper + #查找组织 + def search_public_orgs_not_in_project + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id) + if project_org_ids.empty? + @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + project_org_ids = "(" + project_org_ids.join(',') + ")" + @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + #render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json + respond_to do |format| + format.js + end + end + def index render_404 end @@ -338,6 +361,15 @@ class ProjectsController < ApplicationController @wiki ||= @project.wiki @select_tab = params[:tab] + #找出所有不属于项目的公共组织 + project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{@project.id}") + if project_org_ids.empty? + @orgs_not_in_project = Organization.where("is_public = 1") + else + project_org_ids = "(" + project_org_ids.join(',') + ")" + @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and is_public = 1") + end + # 处理从新建版本库返回来的错误信息 if !params[:repository_error_message].to_s.blank? html = "" @@ -833,5 +865,4 @@ class ProjectsController < ApplicationController end #gcmend - end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0d9588d24..273d48ccf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1910,6 +1910,14 @@ class UsersController < ApplicationController end end + def user_organizations + @user = User.current + @orgs = @user.organizations + respond_to do |format| + format.html {render :layout => 'static_base'} + end + end + private def find_user diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e5cd9b52b..e08259b11 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,6 +48,15 @@ module ApplicationHelper end end end + # 获取组织成员中文名字 + def get_org_member_role_name member + case member.roles[0].name + when 'orgManager' + '管理人员' + when 'orgMember' + '组织成员' + end + end # Time 2015-03-24 16:38:05 # Author lizanle diff --git a/app/helpers/org_document_comment_helper.rb b/app/helpers/org_document_comment_helper.rb new file mode 100644 index 000000000..b430114f2 --- /dev/null +++ b/app/helpers/org_document_comment_helper.rb @@ -0,0 +1,2 @@ +module OrgDocumentCommentHelper +end diff --git a/app/helpers/org_member_helper.rb b/app/helpers/org_member_helper.rb new file mode 100644 index 000000000..fd70a0516 --- /dev/null +++ b/app/helpers/org_member_helper.rb @@ -0,0 +1,16 @@ +module OrgMemberHelper + include ApplicationHelper + def find_user_not_in_current_org_by_name org + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, org_member_autocomplete_org_member_index_path(parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) + end +end diff --git a/app/helpers/org_projects_helper.rb b/app/helpers/org_projects_helper.rb new file mode 100644 index 000000000..f3a7025bd --- /dev/null +++ b/app/helpers/org_projects_helper.rb @@ -0,0 +1,2 @@ +module OrgProjectsHelper +end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 10321ba16..607d2af5c 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,2 +1,22 @@ -module EnterprisesHelper +# encoding: utf-8 +module OrganizationsHelper + include ApplicationHelper + + + def find_user_not_in_current_org_by_name org + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) + end + + + end diff --git a/app/models/news.rb b/app/models/news.rb index a9e9d1d18..e9b8b5314 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -66,7 +66,7 @@ class News < ActiveRecord::Base scope :course_visible, lambda {|*args| includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args)) } - safe_attributes 'title', 'summary', 'description' + safe_attributes 'title', 'summary', 'description', 'sticky' def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_news, project) diff --git a/app/models/org_activity.rb b/app/models/org_activity.rb new file mode 100644 index 000000000..c48ebdf8e --- /dev/null +++ b/app/models/org_activity.rb @@ -0,0 +1,5 @@ +class OrgActivity < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :org_act ,:polymorphic => true + belongs_to :container,:polymorphic => true +end diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb new file mode 100644 index 000000000..2b3c9132a --- /dev/null +++ b/app/models/org_document_comment.rb @@ -0,0 +1,16 @@ +class OrgDocumentComment < ActiveRecord::Base + attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked + include Redmine::SafeAttributes + belongs_to :organization + belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' + + acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc" + has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy + after_create :document_save_as_org_activity + + def document_save_as_org_activity + if(self.parent().nil?) + self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization') + end + end +end diff --git a/app/models/org_member.rb b/app/models/org_member.rb new file mode 100644 index 000000000..a1c61f99d --- /dev/null +++ b/app/models/org_member.rb @@ -0,0 +1,8 @@ +class OrgMember < ActiveRecord::Base + attr_accessible :organization_id, :role, :user_id + belongs_to :organization + belongs_to :user + has_many :roles ,:through => :org_member_roles,:foreign_key => 'role_id' + has_many :org_member_roles,:dependent => :destroy + +end diff --git a/app/models/org_member_role.rb b/app/models/org_member_role.rb new file mode 100644 index 000000000..0ce4f8141 --- /dev/null +++ b/app/models/org_member_role.rb @@ -0,0 +1,5 @@ +class OrgMemberRole < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :org_member + belongs_to :role +end diff --git a/app/models/org_project.rb b/app/models/org_project.rb new file mode 100644 index 000000000..ec01013fc --- /dev/null +++ b/app/models/org_project.rb @@ -0,0 +1,5 @@ +class OrgProject < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :organization + belongs_to :project +end diff --git a/app/models/organization.rb b/app/models/organization.rb index 5f52dee98..7778da477 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,5 +1,14 @@ 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 :org_projects ,:dependent => :destroy + has_many :projects,:through => :org_projects + has_many :org_document_comments, :dependent => :destroy + has_many :users, :through => :org_members + validates_uniqueness_of :name + after_create :save_as_org_activity - has_many :projects + def save_as_org_activity + OrgActivity.create(:user_id => User.current.id, :org_act_id => self.id, :org_act_type => 'CreateOrganization', :container_id => self.id, :container_type => 'Organization') + end end diff --git a/app/models/principal.rb b/app/models/principal.rb index 0f0746f78..dd376f609 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -87,6 +87,16 @@ class Principal < ActiveRecord::Base end } + scope :not_member_of_org, lambda {|org| + orgs = [org] unless org.is_a?(Array) + if orgs.empty? + where("1=0") + else + ids = orgs.map(&:id) + where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{OrgMember.table_name} WHERE organization_id IN (?))", ids) + end + } + scope :sorted, lambda { order(*Principal.fields_for_order_statement)} scope :applied_members, lambda {|project| diff --git a/app/models/project.rb b/app/models/project.rb index fd1012fa0..0b0420920 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -69,6 +69,7 @@ class Project < ActiveRecord::Base has_many :applied_projects, :dependent => :destroy has_many :invite_lists, :dependent => :destroy has_one :dts + has_many :organizations,:through => :org_projects # end #ADDED BY NIE @@ -96,7 +97,8 @@ class Project < ActiveRecord::Base # 关联虚拟表 has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy - belongs_to :organization + has_many :org_projects,:dependent => :destroy + has_many :organization,:through => :org_projects # has_many :journals diff --git a/app/models/role.rb b/app/models/role.rb index 8bf5ebc05..f6a24a27f 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -55,6 +55,8 @@ class Role < ActiveRecord::Base has_many :member_roles, :dependent => :destroy has_many :members, :through => :member_roles + has_many :org_member_roles, :dependent => :destroy + has_many :org_members,:through => :org_member_roles acts_as_list serialize :permissions, ::Role::PermissionsAttributeCoder diff --git a/app/models/user.rb b/app/models/user.rb index edc29c015..85b9e2591 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,8 +94,11 @@ class User < Principal has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" + has_many :org_document_comments, :dependent =>:destroy has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source + has_many :org_members + has_many :organizations, :through => :org_members belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang ## added by xianbo for delete # has_many :biding_projects, :dependent => :destroy @@ -769,6 +772,21 @@ class User < Principal courses.to_a.include?(course) end + def member_of_org?(org) + OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 + end + + def admin_of_org?(org) + if OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count == 0 + return false + end + role = OrgMember.where("user_id =? and organization_id =?", self.id, org.id)[0].roles[0] + unless role.nil? + role.name == 'orgManager' ? true : false + else + false + end + end def member_of_course_group?(course_group) course_groups.to_a.include?(course_group) end diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 54c9541f2..cf24f0f2d 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -28,7 +28,7 @@ showNormalImage('message_description_<%= @article.id %>'); }); -
+
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> @@ -165,7 +165,7 @@ <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %> <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> - <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> <% end %>
diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index e397da2cc..b8bcc9ad0 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -32,7 +32,7 @@ <%#end%> -
+
<%= @user.name%>的博客 diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index f023e8413..86ec79e67 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -10,12 +10,12 @@
- 课件 |  - 软件 |  - 媒体 |  - 代码 |  - 论文 |  - 其他 + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 论文 |  + 其他
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index c750ff3b5..6e62e2d5e 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -86,6 +86,12 @@
  • <%= link_to "修改资料", my_account_path, :class => "menuGrey"%>
  • +
  • + <%= link_to "我的组织", user_organizations_user_path(:id => User.current.id), :class => "menuGrey"%> +
  • +
  • + <%= link_to "新建组织", new_organization_path, :class => "menuGrey"%> +
  • <%= link_to "退出",signout_path,:class => "menuGrey",:method => "post"%> diff --git a/app/views/layouts/_org_projects.html.erb b/app/views/layouts/_org_projects.html.erb new file mode 100644 index 000000000..be65fd516 --- /dev/null +++ b/app/views/layouts/_org_projects.html.erb @@ -0,0 +1,12 @@ +<% projects.each do |project|%> + <% pro = Project.find project.project_id %> +
  • + <%= link_to pro.name, project_path(pro.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => pro.name%> +
  • +<% end %> +<% if projects.size == 5%> +
  • + + +
  • +<% end%> \ No newline at end of file diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb new file mode 100644 index 000000000..6b4eab72a --- /dev/null +++ b/app/views/layouts/base_org.html.erb @@ -0,0 +1,117 @@ +<% @nav_dispaly_project_label = 1 + @nav_dispaly_forum_label = 1 %> +<%#@nav_dispaly_project_label = 1 %> + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> + <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> + + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + + + + + +
    +
    +
    +
    +
    + + + + + +
    + <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> + <% if @organization.is_public? %> + <%= l(:label_public)%> + <% else %> + <%= l(:label_private)%> + <% end %> +
    + + <% if User.current.admin_of_org?(@organization) %> + 配置 + <% end %> + + + + + + + + + + +
    +
    + <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) |  + <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) +
    +
    +
    +
    + <%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %> +
    +
    项目 + +
    +
    +
      + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.org_projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%> + + + + +
    +
    +
    +
    +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    +
    +
    + + +
    + <%= render :partial => 'layouts/footer' %> +
    + + + 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/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 0a5488714..a51b85870 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -4,6 +4,10 @@

    +
  • + <%= f.check_box :sticky, :value => is_new ? 0 : @news.sticky %> + <%= label_tag 'news_sticky', l(:label_board_sticky) %> +
  • <% if is_new %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> diff --git a/app/views/news/_course_news_list.html.erb b/app/views/news/_course_news_list.html.erb index 74a70e33d..3db222f25 100644 --- a/app/views/news/_course_news_list.html.erb +++ b/app/views/news/_course_news_list.html.erb @@ -13,6 +13,9 @@ <%= l(:label_release_news) %>: <%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %> + <% if news.sticky == 1%> + 置顶 + <% end%> <%=link_to "#{news.comments.all.count}".html_safe, news_path(news.id), :class => "pro_mes_w" %>
    diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 2d8dae59d..34e6e943f 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -8,6 +8,9 @@

    <%=h @news.title %>

    + <% if @news.sticky == 1%> + 置顶 + <% end%> <%= link_to(l(:button_edit), edit_news_path(@news), :class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %> diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb new file mode 100644 index 000000000..3a3356c66 --- /dev/null +++ b/app/views/org_document_comments/_new.html.erb @@ -0,0 +1,57 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> + +<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> +
    +
    + +
    +
    +
    + +
    +<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb new file mode 100644 index 000000000..5d54af2bf --- /dev/null +++ b/app/views/org_document_comments/add_reply.js.erb @@ -0,0 +1,3 @@ + +$("#organization_document_<%= @document.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document}) %>"); +init_activity_KindEditor_data(<%= @document.id %>,"","87%"); \ No newline at end of file diff --git a/app/views/org_document_comments/destroy.js.erb b/app/views/org_document_comments/destroy.js.erb new file mode 100644 index 000000000..bcebe9d37 --- /dev/null +++ b/app/views/org_document_comments/destroy.js.erb @@ -0,0 +1 @@ +location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb new file mode 100644 index 000000000..b4f8662a3 --- /dev/null +++ b/app/views/org_document_comments/edit.html.erb @@ -0,0 +1,44 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> + +
    +
    编辑文章
    +
    +<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id),:method => 'put', :id => 'new_org_document_form' do |f| %> +
    +
    + +
    +
    +
    +
    +
    + <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %> +
    +
    + + +

    +
    + +
    + 确定 + + 取消 +
    +
    + +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb new file mode 100644 index 000000000..d9b1d9579 --- /dev/null +++ b/app/views/org_document_comments/index.html.erb @@ -0,0 +1,24 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> + +<%= render :partial => 'new' %> +<% unless @documents.nil? %> + <% @documents.each do |document| %> + + <%= render :partial => 'organizations/show_org_document', :locals => {:document => document} %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb new file mode 100644 index 000000000..11a7e9359 --- /dev/null +++ b/app/views/org_document_comments/new.html.erb @@ -0,0 +1,40 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> + +<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> +
    +
    + +
    +
    + +
    +<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/org_member/create.js.erb b/app/views/org_member/create.js.erb new file mode 100644 index 000000000..f1e48281f --- /dev/null +++ b/app/views/org_member/create.js.erb @@ -0,0 +1,7 @@ +<% if @fail_hint %> + alert("<%= @fail_hint %>"); +<% else %> + $("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); + $("#principals_for_new_member").html(''); + $("#org_members_count_id").html("<%= @org.org_members.count %>"); +<% end %> \ No newline at end of file diff --git a/app/views/org_member/destroy.js.erb b/app/views/org_member/destroy.js.erb new file mode 100644 index 000000000..d87e62c17 --- /dev/null +++ b/app/views/org_member/destroy.js.erb @@ -0,0 +1,3 @@ +$("#org_members_count_id").html(""); +$("#org_members_count_id").html("<%= @org.org_members.count %>") +$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); \ No newline at end of file diff --git a/app/views/org_member/org_member_autocomplete.js.erb b/app/views/org_member/org_member_autocomplete.js.erb new file mode 100644 index 000000000..05cf3947c --- /dev/null +++ b/app/views/org_member/org_member_autocomplete.js.erb @@ -0,0 +1,23 @@ +<% if @org%> + var checked = $("#principals_for_new_member input:checked").size(); + if(checked > 0) + { + alert('翻页或搜索后将丢失当前选择的用户数据!'); + } + <% if @flag == "true"%> + $('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>'); + <% else%> + $('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_org_by_name(@org)) %>'); + <% end%> + +<%end%> +var collection=$("#principals_for_new_member").children("#principals").children("label"); +collection.css("text-overflow","ellipsis"); +collection.css("white-space","nowrap"); +collection.css("width","200px"); +collection.css("overflow","hidden"); +for(i=0;i"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); \ No newline at end of file diff --git a/app/views/org_projects/create.js.erb b/app/views/org_projects/create.js.erb new file mode 100644 index 000000000..545918c73 --- /dev/null +++ b/app/views/org_projects/create.js.erb @@ -0,0 +1,6 @@ + +$("#search_orgs_result_list").html(""); +//$("#search_orgs_result_list").append('
      '); +$("#added_orgs").html(""); +$("#paginator").css("display", "none"); +$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') \ No newline at end of file diff --git a/app/views/org_projects/destroy.js.erb b/app/views/org_projects/destroy.js.erb new file mode 100644 index 000000000..49ea1dc33 --- /dev/null +++ b/app/views/org_projects/destroy.js.erb @@ -0,0 +1,22 @@ +//$("#search_orgs_result_list").html(""); +////$("#paginator").css("display", "none"); +$("#added_orgs").html(""); +$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') +//$.ajax({ +// url: '<%#= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1', +// type:'get' +//}); +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
        '); +<% @orgs_not_in_project.each do |org|%> +link = "
      • "; +$("#search_orgs_result_list").append(link ); +<%end %> +$("#search_orgs_result_list").append('
      ') +<% if @org_count > 10 %> +$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); +$("#paginator").css("display", "block"); +<% else %> +$("#paginator").css("display", "none"); +<% end %> + diff --git a/app/views/organization/_form.html.erb b/app/views/organization/_form.html.erb deleted file mode 100644 index 80cc76850..000000000 --- a/app/views/organization/_form.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -<%= 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 deleted file mode 100644 index 60b7c06a0..000000000 --- a/app/views/organization/edit.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<%= 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/index.html.erb b/app/views/organization/index.html.erb deleted file mode 100644 index f1c50d6ab..000000000 --- a/app/views/organization/index.html.erb +++ /dev/null @@ -1,31 +0,0 @@ - - <%= l(:label_all_enterprises) %> - -
      -
      - <%= l(:label_all_enterprises) %> -
      -
      - <% if @organizations.empty? %> -

      - <%= l(:label_enterprise_nil) %> -

      - <% else %> - <% @organizations.each do |organization| %> - <% unless organization.name.blank? %> -
        -
      • - <%= organization.name%> - <%= link_to organization.name, home_path(:organization => organization.id) %> -
      • -
      - <% end %> - <% end %> - <% end %> -
      -
      -
      -
      -
        -
        -<% html_title(l(:label_enterprise_all)) -%> diff --git a/app/views/organization/new.html.erb b/app/views/organization/new.html.erb deleted file mode 100644 index 163f4a5f5..000000000 --- a/app/views/organization/new.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%= 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/app/views/organizations/_new_org_avatar_form.html.erb b/app/views/organizations/_new_org_avatar_form.html.erb new file mode 100644 index 000000000..8b80641e8 --- /dev/null +++ b/app/views/organizations/_new_org_avatar_form.html.erb @@ -0,0 +1,33 @@ + + + + +<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "upbtn fl" %> + +<%= file_field_tag 'avatar[image]', + :id => 'upload_org_logo', + :class => 'undis upload_file', + :size => "1", + :multiple => true, + :data => { + :max_file_size => Setting.upload_avatar_max_size, + :max_file_size_message => l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :file_type => Redmine::Configuration['pic_types'].to_s, + :type_support_message => l(:error_pic_type), + :upload_path => upload_avatar_path(:format => 'js'), + :description_placeholder => nil ,# l(:label_optional_description) + :source_type => source.class.to_s, + :source_id => source.id.to_s + } %> + +<% content_for :header_tags do %> + <%= javascript_include_tag 'jq-upload/jquery.ui.widget', 'jq-upload/jquery.iframe-transport', 'jq-upload/jquery.fileupload', 'jq-upload/upload' %> +<% end %> +
        diff --git a/app/views/organizations/_org_member_list.html.erb b/app/views/organizations/_org_member_list.html.erb new file mode 100644 index 000000000..f67b25811 --- /dev/null +++ b/app/views/organizations/_org_member_list.html.erb @@ -0,0 +1,42 @@ +<% members.each do |member|%> +
          +
        • <%= User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %>
        • +
        • + <%= get_org_member_role_name member %> + <%= form_for(member, {:as => :org_member, :remote => true, :url => org_member_path(member), + :method => :put, + :html => {:id => "org-member-#{member.id}-roles-form", :style=>'display:none'}} + ) do |f| %> + <% Role.givable.where("id in (11,12)").each do |role| %> +
            + <%= radio_button_tag 'org_member[role_ids][]', role.id, member.roles.include?(role) %> + + <% if User.current.language == "zh" %> + <% if role.id == 11 %> + + <% elsif role.id == 12 %> + + <% end %> + <% else %> + + <% end %> +
          + + <% end %> + <%= hidden_field_tag 'membership[role_ids][]', '' %> + + <% end %> +
        • + <% if ( (User.current.id == member.organization.creator_id || User.current.admin_of_org?(member.organization) ) && member.user_id != member.organization.creator_id )%> + 编辑 + <%= link_to '删除', org_member_path(member.id),:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %> +
          +
        +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_members.html.erb b/app/views/organizations/_org_members.html.erb new file mode 100644 index 000000000..3940a6576 --- /dev/null +++ b/app/views/organizations/_org_members.html.erb @@ -0,0 +1,29 @@ +<%= stylesheet_link_tag 'courses' %> +
        +
        +

        组织成员

        +
        +
        +
        + +
        + + <% members.each do |member| %> +
        + + <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %> + + <%= l(:label_username)%> + <%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %>
        + 身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %> +
        +
        + <% end%> + +
          + <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
        +
        +
        +
        +
        \ No newline at end of file diff --git a/app/views/organizations/_org_project_activities.html.erb b/app/views/organizations/_org_project_activities.html.erb new file mode 100644 index 000000000..b46996661 --- /dev/null +++ b/app/views/organizations/_org_project_activities.html.erb @@ -0,0 +1,28 @@ +<% org_project_activties.each do |act|%> +<% if act %> + <% if act %> + <% case act.forge_act_type.to_s %> + <% when 'Issue' %> + <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <% when 'Message' %> + <%= render :partial => 'organizations/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <% when 'ProjectCreateInfo'%> + <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> + <% end %> + <% end %> +<% end %> +<% end %> +<% if org_act_count == 10 || pro_act_count == 10 %> +
        展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
        + <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end%> + + + diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb new file mode 100644 index 000000000..573429752 --- /dev/null +++ b/app/views/organizations/_org_project_issue.html.erb @@ -0,0 +1,136 @@ +
        +
        +
        + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
        +
        +
        + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> +
        +
        + <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> + + <%#= get_issue_priority(activity.priority_id)[1] %> + +
        +
        +
        指派给   + <% unless activity.assigned_to_id.nil? %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> + <% end %> +
        +
        + 时间: + <%=format_time(activity.created_on) %> +
        +
        +
        +
        + <% if activity.description? %> + <%= textAreailizable activity, :description, :attachments => activity.attachments %> + <% end %> +
        +
        +
        + + +
        +
        + <% if activity.attachments.any? %> + <% activity.attachments.each do |attachment| %> +
        + + + <%= link_to_short_attachment attachment,:length=> 58, :class => 'link_file_a fl newsBlue', :download => true -%> + + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :class => 'fl', + :filename => attachment.filename %> + <% end %> + + ( + <%= number_to_human_size attachment.filesize %>) + + + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>, + <%= format_time(attachment.created_on) %> + +
        + <% end %> + <% end %> +
        +
        +
        +
        + <% count = activity.journals.count %> +
        +
        +
        +
        回复(<%= count %>)
        +
        <%#= format_date(activity.updated_on) %>
        + <% if count > 3 %> + + <% end %> +
        + + <% replies_all_i = 0 %> + <% if count > 0 %> +
        +
          + <% activity.journals.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i + 1 %> +
        • +
          + <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %> +
          +
          +
          + <% if reply.try(:user).try(:realname) == ' ' %> + <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
          +
          + <% if reply.details.any? %> + <% details_to_strings(reply.details).each do |string| %> +

          <%= string %>

          + <% end %> + <% end %> +

          <%= reply.notes.nil? ? "" : reply.notes.html_safe %>

          +
          +
          +
          +
        • + <% end %> +
        +
        + <% end %> + + + +
        +
        diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb new file mode 100644 index 000000000..d966d8e18 --- /dev/null +++ b/app/views/organizations/_project_create.html.erb @@ -0,0 +1,38 @@ +<% project = Project.find(activity.project_id) %> +<% user = User.find(project.user_id)%> +
        +
        +
        + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %> +
        +
        +
        + <% if user.try(:realname) == ' ' %> + <%= link_to user, user_path(user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
        +
        + <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> +
        +
        + 创建时间:<%= format_time(project.created_on) %> +
        + +
        +
        +
        +
        \ No newline at end of file diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb new file mode 100644 index 000000000..85ed08f2f --- /dev/null +++ b/app/views/organizations/_project_message.html.erb @@ -0,0 +1,100 @@ +
        +
        +
        + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
        +
        +
        + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> + +
        +
        + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" + %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey" + %> + <% end %> +
        +
        + 时间:<%= format_time(activity.created_on) %> +
        +
        +
        + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
        +
        +
        + + +
        +
        +
        +
        + <% count = 0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
        +
        +
        +
        回复( + <%=count %> + )
        +
        <%#=format_date(activity.updated_on)%>
        + <%if count>3 %> + + <% end %> +
        + + <% activity= activity.parent_id.nil? ? activity : activity.parent %> + <% replies_all_i = 0 %> + <% if count > 0 %> +
        +
          + <% activity.children.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i+1 %> +
        • +
          + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id), :alt => "用户头像" %> +
          +
          +
          + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
          +
          + <%= reply.content.html_safe %>
          +
          +
          +
        • + <% end %> +
        +
        + <% end %> + + +
        +
        \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb new file mode 100644 index 000000000..4177c3688 --- /dev/null +++ b/app/views/organizations/_show_org_document.html.erb @@ -0,0 +1,130 @@ +
        +
        +
        + <%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_path(document.creator_id) %> +
        +
        +
        + <%= link_to User.find(document.creator_id), user_path(document.creator.id), :class => "newsBlue mr15" %> + TO  <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %> + | + <% if document.organization.home_id == document.id %> + 首页 + <% else %> + 组织 + <% end %> +
        +
        <%= document.title %>
        +
        + 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
        + <% unless document.content.blank? %> +
        + <%= document.content.html_safe %> +
        + <% end %> + + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> +
        +
          +
        • +
            +
          • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %> + 设为首页 + <% end %> +
          • +
          • + <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :class => "postOptionLink" %> +
          • +
          • + <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
          • +
          +
        • +
        +
        +
        + <% end %> +
        +
        + <% comments_for_doc = document.children.reorder("created_at desc") %> + <% count = document.children.count() %> + +
        +
        +
        回复(<%= count %>)
        + <% if count > 3 %> + + <% end %> +
        +
        +
          + <% reply_id = 0 %> + <% comments_for_doc.each do |comment| %> + <% reply_id += 1 %> +
        • +
          <%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_path(comment.creator_id) %>
          +
          +
          + <%= link_to User.find(comment.creator_id), user_path(comment.creator_id), :class => "newsBlue mr10 f14" %> + <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %> +
          + <% unless comment.content.blank? %> +
          <%= comment.content.html_safe %>
          + <% end %> +
          +
          +
        • + <% end %> +
        +
        +
        +
        + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_path(User.current) %> +
        +
        +
        + <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id), :method => "post", :remote => true) do |f| %> + + + +
        + + +
        +

        + <% end %> +
        +
        +
        +
        +
        +
        +
        + + \ No newline at end of file diff --git a/app/views/organizations/autocomplete_search.js.erb b/app/views/organizations/autocomplete_search.js.erb new file mode 100644 index 000000000..357ef668c --- /dev/null +++ b/app/views/organizations/autocomplete_search.js.erb @@ -0,0 +1,13 @@ +<% if @project%> +var checked = $("#not_org_members input:checked").size(); +if(checked > 0) +{ + alert('翻页或搜索后将丢失当前选择的用户数据!'); +} +<% if @flag == "true"%> +$('#new_orgs_for_project').html('<%= escape_javascript(search_public_orgs_not_in_project(@project.id)) %>'); +<% else%> +$('#new_orgs_for_project').html('<%= escape_javascript(search_public_orgs_not_in_project(@project.id)) %>'); +<% end%> + +<%end%> diff --git a/app/views/organizations/check_uniq.js.erb b/app/views/organizations/check_uniq.js.erb new file mode 100644 index 000000000..f38578025 --- /dev/null +++ b/app/views/organizations/check_uniq.js.erb @@ -0,0 +1,22 @@ +<% if !@org_name.blank? %> + <%if @check == false %> + $checkName = false + <% if @config_page%> + $("#check_name_hint").html('名字不能重复').show(); + <% else%> + $("#organization_name_notice").html('名字不能重复').show(); + + <%end%> + + <% else %> + $checkName = true; + <% if @config_page%> + $("#check_name_hint").html('名字可以使用').show(); + <% else%> + + $("#organization_name_notice").html('名字可以使用').show(); + <%end%> + <%end%> +<% else %> +$("#check_name_hint").html('名字不能为空').show(); +<% end %> \ No newline at end of file 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/members.html.erb b/app/views/organizations/members.html.erb new file mode 100644 index 000000000..91e80b232 --- /dev/null +++ b/app/views/organizations/members.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'org_members', :locals => {:members => @members, :organization => @organization} %> \ No newline at end of file diff --git a/app/views/organizations/more_org_projects.js.erb b/app/views/organizations/more_org_projects.js.erb new file mode 100644 index 000000000..029661d39 --- /dev/null +++ b/app/views/organizations/more_org_projects.js.erb @@ -0,0 +1 @@ +$("#show_more_org_project").replaceWith("<%= escape_javascript( render :partial => 'layouts/org_projects',:locals => {:projects => @org_projects,:org_id => @organization, :page => @page} )%>"); diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb new file mode 100644 index 000000000..1ab3ad933 --- /dev/null +++ b/app/views/organizations/new.html.erb @@ -0,0 +1,110 @@ + +<% @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/app/views/organizations/set_homepage.js.erb b/app/views/organizations/set_homepage.js.erb new file mode 100644 index 000000000..b25c4c4d4 --- /dev/null +++ b/app/views/organizations/set_homepage.js.erb @@ -0,0 +1,2 @@ +//location.reload(); +window.location.href ='<%= organization_path(@org)%>' \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb new file mode 100644 index 000000000..82b28fb8a --- /dev/null +++ b/app/views/organizations/setting.html.erb @@ -0,0 +1,109 @@ + +
        +
        配置
        +
        +
        +
          +
        • 信息
        • +
        • 成员
        • +
        • +
          +
        +
        + + + <%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %> + <%= labelled_form_for @organization do |f|%> + <%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %> + + +
        组织名称: + +
        +
        +
        +
        组织描述: + +
        +
        +
        + + + + + + + + +
        公开 : + class="ml3" /> +
        + 保存 + <% end %> +
        +
        +
        +
          +
        • 用户
        • +
        • 角色
        • +
          +
        +
        + <%= render :partial=>"org_member_list",:locals=> {:members=>@organization.org_members} %> +
        +
        +
        +
        +

        添加成员

        + <%= form_tag url_for(:controller => 'org_member',:action => 'create',:org=>@organization),:id=>'org_member_add_form',:remote=>true do |f|%> + + <%= javascript_tag "observeSearchfield('not_org_member_search', null, '#{ escape_javascript org_member_autocomplete_org_member_index_path(:org=>@organization, :format => 'js') }')" %> +
        + <%= find_user_not_in_current_org_by_name(@project) %> +
        +
        +
          +
        • 角色
        • +
        • + + +
        • +
        • + + +
        • +
        新增成员 + <% end %> +
        +
        +
        +
        +
        \ No newline at end of file diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb new file mode 100644 index 000000000..0b624d479 --- /dev/null +++ b/app/views/organizations/show.html.erb @@ -0,0 +1,79 @@ +<%= javascript_include_tag "jquery.infinitescroll.js" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> + +
        +
        最新动态
        + +
        + +<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> + + + <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %> +<% end %> + + <% unless @org_activities.nil? %> + <% @org_activities.each do |act| %> + <% if act.org_act_type == 'CreateOrganization' %> +
        +
        + +
        +
        <%= link_to User.find(act.user_id), user_path(act.user_id) %>  创建了 <%= Organization.find(act.org_act_id).name %> + | 组织
        +
        创建时间:<%= format_activity_day(act.created_at) %> <%= format_time(act.created_at, false) %>
        +
        +
        +
        +
        + <% end %> + <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> + + <%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %> + <% end %> + <% end %> + + <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> + + <% end %> + + <%# @org_project_activties.each do |org_act|%> + <%= render :partial => 'organizations/org_project_activities', + :locals => {:org_project_activties =>@org_project_activties, + :page=>@page, + :org => @organization, + :org_act_count=>@org_activities.count, + :pro_act_count=>@org_project_activties.count}%> + <%# end %> + + + + diff --git a/app/views/organizations/show.js.erb b/app/views/organizations/show.js.erb new file mode 100644 index 000000000..b0a447910 --- /dev/null +++ b/app/views/organizations/show.js.erb @@ -0,0 +1,7 @@ +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'organizations/org_project_activities', + :locals => {:org_project_activties =>@org_project_activties, + :page=>@page, + :org => @organization, + :org_act_count=>@org_activities.count, + :pro_act_count=>@org_project_activties.count} )%>"); + diff --git a/app/views/projects/search_public_orgs_not_in_project.js.erb b/app/views/projects/search_public_orgs_not_in_project.js.erb new file mode 100644 index 000000000..69005d304 --- /dev/null +++ b/app/views/projects/search_public_orgs_not_in_project.js.erb @@ -0,0 +1,13 @@ +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
          '); + <% @orgs_not_in_project.each do |org|%> + link = "
        • "; + $("#search_orgs_result_list").append(link ); + <%end %> +$("#search_orgs_result_list").append('
        ') +<% if @org_count > 10 %> +$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); +$("#paginator").css("display", "block"); +<% else %> +$("#paginator").css("display", "none"); +<% end %> diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index 3fc9a89d6..76258b9e9 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -12,6 +12,7 @@ project_setting(6); $("#pro_st_edit_ku").toggle(); <%else%> + project_setting(5); <% end%> <% end%> $("div[nhname='pro_setting']").show(); @@ -36,6 +37,7 @@ <% if User.current.allowed_to?(:manage_members, @project) %>
      • 成员
      • <% end %> +
      • 组织
      • <% if User.current.allowed_to?(:manage_versions, @project) %>
      • 版本
      • <% end %> @@ -63,6 +65,7 @@ <%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%>
    • +
      <%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%>
      @@ -70,6 +73,9 @@ +
      + <%= render :partial=>"projects/settings/join_org" %> +
      <%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%> diff --git a/app/views/projects/settings/_added_orgs.html.erb b/app/views/projects/settings/_added_orgs.html.erb new file mode 100644 index 000000000..d07ead277 --- /dev/null +++ b/app/views/projects/settings/_added_orgs.html.erb @@ -0,0 +1,9 @@ +
        +
      • 名称操作
      • + <% orgs.each do |org| %> +
      • <%= org.name %> + <%= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id), + :method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %> +
      • + <% end %> +
      \ No newline at end of file diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb new file mode 100644 index 000000000..57ae714bd --- /dev/null +++ b/app/views/projects/settings/_join_org.html.erb @@ -0,0 +1,107 @@ + + + + + + + +<%= stylesheet_link_tag 'org' %> + +
        +
      • 组织
      • +
      • +
        +
      +
      +
      + 关联组织 +
      + <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true %> + +
      +
        + 关联 + 取消 +
        +
        +
        + 已关联组织 +
        + <%= render :partial => 'projects/settings/added_orgs', :locals => {:orgs => @project.organizations, :project_id => params[:id]} %> +
        +
        +
        +
        +
        +
        + + \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index ebe3d4cc6..2a0962244 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -5,7 +5,7 @@
      • <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(student_work.user)) %>
      • -
        +
      • <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
        @@ -25,7 +25,7 @@
      • -
      • +
      • <% if student_work.created_at && @homework.end_time%> <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>  <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %> @@ -80,6 +80,15 @@
      • <% end%> - + + diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index 81d868a50..e336b0282 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -7,13 +7,13 @@
      • <%= image_tag(url_to_avatar(student_work.user),width:"40", height: "40") %>
      • -
      • +
      • <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
        <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
      • -
      • +
        • <%= student_work.user.show_name%> @@ -27,12 +27,12 @@
        • <%= image_tag(url_to_avatar(""),width:"40", height: "40") %>
        • -
        • +
        • <%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
        • -
        • +
          • 匿名 @@ -46,7 +46,7 @@
        • -
        • +
        • <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>  <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %> [迟交] @@ -58,6 +58,13 @@
        • <%= my_score.nil? ? "--" : format("%.1f",my_score.score)%>
        • - +
        + diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 286d5eb39..1b0202536 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -9,10 +9,10 @@ <% if work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
      • - <%= link_to("", student_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %> + <%= link_to("", student_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
      • -
      • - <%= link_to "",edit_student_work_path(work),:class => "pic_edit"%> +
      • + <%= link_to "",edit_student_work_path(work),:class => "pic_edit",:title => "修改"%>
      • <% end%> <% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 64f097114..c18ec4c73 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -2,10 +2,14 @@ 作品 - (已有<%= @student_work_count%>人提交) + (<%= @student_work_count%>人已交) <% if !@is_teacher && @stundet_works.empty?%> 您尚未提交作品 + <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + 您已提交且不可再修改,因为截止日期已过 + <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + 您已提交,您还可以修改 <% end %> <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index f9087f057..475a982e5 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -12,9 +12,13 @@ <% end %> TO <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
        -
        + + <% if activity.sticky == 1%> + 置顶 + <% end%> +
        发布时间:<%= format_time(activity.created_on) %>
        diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 6f47e3535..156da0f07 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -7,7 +7,7 @@ <% attachments.each do |attach| %>
        • - +
        • diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 6d929ac5f..efaed2d9d 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -17,11 +17,17 @@
          <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true) unless edit_mode%> -
          + <% if edit_mode %> + + <% end %> +
          <%= calendar_for('homework_end_time')%>
          -
          + <% if edit_mode %> + + <% end %> +
          <%= calendar_for('homework_publish_time')%>
          diff --git a/app/views/users/user_organizations.html.erb b/app/views/users/user_organizations.html.erb new file mode 100644 index 000000000..50fa03bbe --- /dev/null +++ b/app/views/users/user_organizations.html.erb @@ -0,0 +1,35 @@ +<%= stylesheet_link_tag 'pleft','header','new_user','repository','org' %> +<%#= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> +
          +
          +
          +
          + 组织列表 + + + + + +
          +
          + <% @orgs.each do |org| %> +
          +
          + <%= link_to image_tag(url_to_avatar(org), :width => '78', :height => '78', :alt => '组织logo'), organization_path(org), :class => "linkGrey2" %> +
          +
          +
          + <%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %> +
          +
          <%= org.description %>
          +
          创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %>
          + +
          您的身份:<%= User.current.admin_of_org?(org) ? "组织管理员" : "组织成员" %>
          +
          + +
          +
          + <% end %> +
          +
          +
          \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index f6bb3c8cb..4fd4d0cb9 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -287,7 +287,11 @@ //批量删除 function batch_delete(){ var data = $("#resources_list_form").serialize(); - if(data != "" && confirm('您删不掉这其中上传者不是您的资源,确认要删除这些资源吗?')) { + if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){ + alert("您只能删除自己上传的资源,请重新选择后再删除。"); + return; + } + if(data != "" && confirm('确认要删除这些资源吗?')) { $.post( '<%= user_resource_delete_user_path(@user)%>', $("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交 diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index 2d6c4f4d8..f69057273 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -2,6 +2,6 @@ closeModal(); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); //这里不能将翻页的更新 -$("#res_all_count").html(parseInt($("#res_all_count").html())+1); +$("#res_all_count").html('<%= @atta_count%>'); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); \ No newline at end of file diff --git a/app/views/users/user_resource_delete.js.erb b/app/views/users/user_resource_delete.js.erb index a956ed212..e16abf28d 100644 --- a/app/views/users/user_resource_delete.js.erb +++ b/app/views/users/user_resource_delete.js.erb @@ -1,2 +1,5 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#res_all_count").html('<%= @atta_count%>') +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); \ No newline at end of file diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index ee361cc2f..d65606678 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/locales/zh.yml b/config/locales/zh.yml index 12c1b9258..4563944c8 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2090,5 +2090,7 @@ zh: label_forums: 贴吧交流 label_language: 语言 label_license: 湘ICP备09019772 + label_org_name: 组织名称: + label_blank_user_lists_for_org: 用户不能为空 diff --git a/config/routes.rb b/config/routes.rb index 6d754ffaf..c4af301bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,56 @@ 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 do + member do + get 'setting'#, :action => 'settings', :as => 'settings' + get 'clear_org_avatar_temp' + put 'set_homepage' + get 'members' + get 'more_org_projects' + end + collection do + get 'check_uniq' + get 'autocomplete_search' + end + resources :org_document_comments do + member do + + end + collection do + + end + end + end + + resources :org_member do + member do + + end + collection do + get 'org_member_autocomplete' + end + end + + resources :org_document_comments do + member do + post 'add_reply' + end + collection do + + end + end + + resources :org_projects do + member do + + end + collection do + + end + end + #match '/organizations/:organization_id/org_document_comments/new', :to => 'org_document_comments#new', :as => 'new_org_documents', :via => [:get, :post] + #match '/organizations/:organization_id/org_document_comments/create', :to => 'org_document_comments#create', :as => 'create_org_documents', :via => [:post] resources :homework_users resources :no_uses delete 'no_uses', :to => 'no_uses#delete' @@ -38,9 +88,9 @@ RedmineApp::Application.routes.draw do resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' - resources :organization, :except => [:show] do - - end + # resources :organization, :except => [:show] do + # + # end resources :school, :except => [:show] do collection do @@ -393,6 +443,7 @@ RedmineApp::Application.routes.draw do post 'import_resources_to_homework' get 'dealwith_apply_request' get 'store_selected_resource' + get 'user_organizations' # end end #resources :blogs @@ -439,7 +490,7 @@ RedmineApp::Application.routes.draw do ################# added by william match 'users/tag_save', :via => :post, :as => 'tag' match 'users/tag_saveEx', :via => [:get, :post] - + #get 'users/:id/user_organizations', :to => 'users#user_organizations', :as => 'user_organizations' post 'watchers/watch', :to => 'watchers#watch', :as => 'watch' delete 'watchers/watch', :to => 'watchers#unwatch' get 'watchers/new', :to => 'watchers#new' @@ -477,6 +528,7 @@ RedmineApp::Application.routes.draw do post 'unarchive' post 'close' post 'reopen' + get 'search_public_orgs_not_in_project' match 'copy', :via => [:get, :post] end 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/db/migrate/20151104020233_create_org_document_comments.rb b/db/migrate/20151104020233_create_org_document_comments.rb new file mode 100644 index 000000000..e300785aa --- /dev/null +++ b/db/migrate/20151104020233_create_org_document_comments.rb @@ -0,0 +1,13 @@ +class CreateOrgDocumentComments < ActiveRecord::Migration + def change + create_table :org_document_comments do |t| + t.string :title + t.text :content + t.integer :organization_id + t.integer :creator_id + t.integer :parent_id + t.integer :reply_id + t.timestamps + end + end +end diff --git a/db/migrate/20151104024335_add_locked_and_sticky_column_to_entity_org_document_comments.rb b/db/migrate/20151104024335_add_locked_and_sticky_column_to_entity_org_document_comments.rb new file mode 100644 index 000000000..313800985 --- /dev/null +++ b/db/migrate/20151104024335_add_locked_and_sticky_column_to_entity_org_document_comments.rb @@ -0,0 +1,6 @@ +class AddLockedAndStickyColumnToEntityOrgDocumentComments < ActiveRecord::Migration + def change + add_column :org_document_comments,:locked,:boolean,:default => false + add_column :org_document_comments,:sticky,:integer,:default => 0 + end +end diff --git a/db/migrate/20151104032831_create_org_activity.rb b/db/migrate/20151104032831_create_org_activity.rb new file mode 100644 index 000000000..8d78102b3 --- /dev/null +++ b/db/migrate/20151104032831_create_org_activity.rb @@ -0,0 +1,16 @@ +class CreateOrgActivity < ActiveRecord::Migration + def up + create_table :org_activities do |t| + t.integer :user_id + t.integer :act_id + t.string :act_type + t.integer :container_id + t.string :container_type + + t.timestamps + end + end + + def down + end +end diff --git a/db/migrate/20151104070007_create_org_projects.rb b/db/migrate/20151104070007_create_org_projects.rb new file mode 100644 index 000000000..db83f9632 --- /dev/null +++ b/db/migrate/20151104070007_create_org_projects.rb @@ -0,0 +1,11 @@ +class CreateOrgProjects < ActiveRecord::Migration + def up + create_table :org_projects do |t| + t.integer :organization_id + t.integer :project_id + end + end + + def down + end +end diff --git a/db/migrate/20151104070455_delete_column_role_from_org_members.rb b/db/migrate/20151104070455_delete_column_role_from_org_members.rb new file mode 100644 index 000000000..2e986dd9b --- /dev/null +++ b/db/migrate/20151104070455_delete_column_role_from_org_members.rb @@ -0,0 +1,8 @@ +class DeleteColumnRoleFromOrgMembers < ActiveRecord::Migration + def up + remove_column :org_members, :role + end + + def down + end +end diff --git a/db/migrate/20151104073902_rename_column_for_org_activity.rb b/db/migrate/20151104073902_rename_column_for_org_activity.rb new file mode 100644 index 000000000..e644c16cb --- /dev/null +++ b/db/migrate/20151104073902_rename_column_for_org_activity.rb @@ -0,0 +1,6 @@ +class RenameColumnForOrgActivity < ActiveRecord::Migration + def change + rename_column :org_activities,:act_id,:org_act_id + rename_column :org_activities,:act_type,:org_act_type + end +end diff --git a/db/migrate/20151104090032_create_org_member_roles.rb b/db/migrate/20151104090032_create_org_member_roles.rb new file mode 100644 index 000000000..d97d6eda7 --- /dev/null +++ b/db/migrate/20151104090032_create_org_member_roles.rb @@ -0,0 +1,11 @@ +class CreateOrgMemberRoles < ActiveRecord::Migration + def up + create_table :org_member_roles do |t| + t.integer :org_member_id + t.integer :role_id + end + end + + def down + end +end diff --git a/db/migrate/20151110011003_add_time_to_org_project.rb b/db/migrate/20151110011003_add_time_to_org_project.rb new file mode 100644 index 000000000..dfe370103 --- /dev/null +++ b/db/migrate/20151110011003_add_time_to_org_project.rb @@ -0,0 +1,5 @@ +class AddTimeToOrgProject < ActiveRecord::Migration + def change + add_column :org_projects, :created_at, :timestamp + end +end diff --git a/db/migrate/20151112072948_add_news_sticky.rb b/db/migrate/20151112072948_add_news_sticky.rb new file mode 100644 index 000000000..85001debe --- /dev/null +++ b/db/migrate/20151112072948_add_news_sticky.rb @@ -0,0 +1,9 @@ +class AddNewsSticky < ActiveRecord::Migration + def up + add_column :news, :sticky, :integer, :default => 0 + end + + def down + remove_column :news, :sticky + end +end diff --git a/db/schema.rb b/db/schema.rb index 7898b3f4d..73924d83c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151109080256) do +ActiveRecord::Schema.define(:version => 20151112072948) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -528,26 +528,23 @@ ActiveRecord::Schema.define(:version => 20151109080256) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 + create_table "dts", :force => true do |t| + t.string "IPLineCode" t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 + t.string "Num" + t.string "Variable" + t.string "TraceInfo" + t.string "Method" + t.string "File" + t.string "IPLine" + t.string "Review" + t.string "Category" + t.string "Defect" + t.string "PreConditions" + t.string "StartLine" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "enabled_modules", :force => true do |t| @@ -817,6 +814,16 @@ ActiveRecord::Schema.define(:version => 20151109080256) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -953,6 +960,7 @@ ActiveRecord::Schema.define(:version => 20151109080256) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.integer "sticky", :default => 0 end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1038,10 +1046,45 @@ ActiveRecord::Schema.define(:version => 20151109080256) do t.integer "project_id" end + create_table "org_activities", :force => true do |t| + t.integer "user_id" + t.integer "org_act_id" + t.string "org_act_type" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_document_comments", :force => true do |t| + t.string "title" + t.text "content" + t.integer "organization_id" + t.integer "creator_id" + t.integer "parent_id" + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + end + + create_table "org_member_roles", :force => true do |t| + t.integer "org_member_id" + t.integer "role_id" + end + create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.string "role" + t.integer "user_id" + t.integer "organization_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_projects", :force => true do |t| + t.integer "organization_id" + t.integer "project_id" + t.datetime "created_at" end create_table "organizations", :force => true do |t| diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 4d79086d4..8e231fafd 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -1,7 +1,7 @@ #coding=utf-8 namespace :homework_publishtime do - desc "start publish homework" + desc "start publish homework and end homework" task :publish => :environment do homework_commons = HomeworkCommon.where("publish_time = '#{Date.today}'") homework_commons.each do |homework| @@ -20,4 +20,16 @@ namespace :homework_publishtime do end end end + + task :end => :environment do + homework_commons = HomeworkCommon.where("end_time < '#{Date.today}'") + homework_commons.each do |homework| + if homework.anonymous_comment == 1 + homework_detail_manual = homework.homework_detail_manual + if homework_detail_manual.comment_status == 1 + homework_detail_manual.update_column('comment_status', 3) + end + end + end + end end \ No newline at end of file diff --git a/public/images/org_default.jpg b/public/images/org_default.jpg new file mode 100644 index 000000000..ad1b4f007 Binary files /dev/null and b/public/images/org_default.jpg differ diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 20e845424..d7b49c8be 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -155,13 +155,13 @@ function addFile(inputEl, file, eagerUpload,btnId) { addFile.nextAttachmentId = 1; function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { - + //上传开始调用函数 function onLoadstart(e) { fileSpan.removeClass('ajax-waiting'); fileSpan.addClass('ajax-loading'); $('input:submit', $(this).parents('form')).attr('disabled', 'disabled'); } - + //更改progressbar的值 function onProgress(e) { if (e.lengthComputable) { this.progressbar('value', e.loaded * 100 / e.total); @@ -177,40 +177,43 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { progressEventHandler: onProgress.bind(progressSpan) }) .done(function(result) { - progressSpan.progressbar('value', 100).remove(); - var containerid = $(inputEl).data('containerid'); - console.log($(inputEl)) - if(containerid == undefined ){ - var count = $('#attachments_fields>span').length; - $('#'+btnId).removeAttr("disabled"); - $('#'+btnId).val('确定') - $('#'+btnId).css('background-color','#269ac9') - $('#upload_file_count').html("" + count + "" + $(inputEl).data('fileCount')); - } - else{ - $('#'+btnId).removeAttr("disabled"); - $('#'+btnId).val('确定') - $('#'+btnId).css('background-color','#269ac9') - var count = $('#attachments_fields' + containerid + '>span').length; - $('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('fileCount')); - } - + progressSpan.progressbar('value', 100).remove(); //上传完成就去掉该文件名后的进度条 fileSpan.find('input.description, a').css('display', 'inline-block'); fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block'); }) .fail(function(result) { - progressSpan.text(result.statusText); - if ($("#network_issue")) { + progressSpan.text("网络错误"); + if ($("#network_issue")) { //在上传处都要给出一个network_issue的div用来显示错误 $("#network_issue").show(); } }).always(function() { ajaxUpload.uploading--; fileSpan.removeClass('ajax-loading'); - var form = fileSpan.parents('form'); - if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { - $('input:submit', form).removeAttr('disabled'); + var containerid = $(inputEl).data('containerid');//多个上传控件需要的容器id + if(containerid == undefined ){ + var count = 1;//同步上传参数为1,所以不需要去获取正在上传的文件就知道是1 + $('#upload_file_count').html("" + count + "" + $(inputEl).data('lebelFileUploding')); } - form.dequeue('upload'); + else{ + var count = 1; + $('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('lebelFileUploding')); + } + var form = fileSpan.parents('form'); + if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { //所有文件上传完毕,更改状态 + $('input:submit', form).removeAttr('disabled'); + $('#' + btnId).removeAttr("disabled"); + $('#' + btnId).val('确定') + $('#' + btnId).css('background-color', '#269ac9') + if(containerid == undefined ){ + var count = $('#attachments_fields>span').length; + $('#upload_file_count').html("" + count + "" + $(inputEl).data('fileCount')); + }else{ + var count = $('#attachments_fields' + containerid + '>span').length; + $('#upload_file_count'+containerid).html("" + count + "" + $(inputEl).data('fileCount')); + } + + } + form.dequeue('upload');//上传完成一个就退出一个 }); //gcm files count and add delete_all link @@ -222,7 +225,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { $('#'+btnId).attr("disabled",true); $('#'+btnId).val('提交中'); $('#'+btnId).css('background-color','#c1c1c1') - $('#upload_file_count').html("" + count + "" + $(inputEl).data('lebelFileUploding')); + $('#upload_file_count').html("1" + $(inputEl).data('lebelFileUploding'));//目前肯定是穿一个文件 if (count >= 1) { var add_attachs = $('.add_attachment'); var delete_all = $('.remove_all'); @@ -239,7 +242,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { $('#'+btnId).attr("disabled",true); $('#'+btnId).val('提交中'); $('#'+btnId).css('background-color','#c1c1c1') - $('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('lebelFileUploding')); + $('#upload_file_count' + containerid).html("1" + $(inputEl).data('lebelFileUploding'));//目前肯定是穿一个文件 if (count >= 1) { var add_attachs = $('.add_attachment').filter(function(index) { return $(this).data('containerid') == containerid; @@ -262,17 +265,25 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { //gcm } - + //在插入文件名的后边插入div var progressSpan = $('
          ').insertAfter(fileSpan.find('input.upload_filename')); - progressSpan.progressbar(); - fileSpan.addClass('ajax-waiting'); - - var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); - + progressSpan.progressbar(); //将div处理成progress bar + fileSpan.addClass('ajax-waiting'); //添加文件正在上传的状态 + var containerid = $(inputEl).data('containerid');//多个上传控件需要的容器id + if(containerid == undefined ){ //选择了多少个文件也要显示,因为有时候文件过大,一时半会传不完,但还是显示文件没有选择 + var count = $('#attachments_fields>span').length; + $('#upload_file_count').html("" + count + "" + '个文件被选择'); + }else{ + var count = $('#attachments_fields' + containerid + '>span').length; + $('#upload_file_count'+containerid).html("" + count + "" + '个文件被选择'); + } + //最大的同步上传参数 + var maxSyncUpload = 1 //$(inputEl).data('max-concurrent-uploads'); + //如果没有指定同步上传参数 或者参数不对,或者需要上传的文件已经小于同步上传的个数,那么直接上传 if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) actualUpload(file, attachmentId, fileSpan, inputEl,btnId); - else - $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); + else //否则就进行队列上传 + $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl,btnId)); } ajaxUpload.uploading = 0; @@ -338,6 +349,10 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) { function addInputFiles(inputEl,btnId) { // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { +// if(inputEl.files.length >= 5){ +// alert('一次选择的文件不能超过5个') +// return; +// } // upload files using ajax uploadAndAttachFiles(inputEl.files, inputEl,btnId); // $(inputEl).remove(); @@ -365,6 +380,10 @@ function addInputFiles_board(inputEl, id,btnId) { // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { +// if(inputEl.files.length >= 5){ +// alert('一次选择的文件不能超过5个') +// return; +// } // upload files using ajax uploadAndAttachFiles_board(inputEl.files, inputEl, id,btnId); // $(inputEl).remove(); @@ -497,6 +516,10 @@ function addInputFilesCourseSource(inputEl) { btnId = arguments[2]; // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { +// if(inputEl.files.length >= 5){ +// alert('一次选择的文件不能超过5个') +// return; +// } // upload files using ajax uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox,btnId); // $(inputEl).remove(); diff --git a/public/javascripts/org.js b/public/javascripts/org.js new file mode 100644 index 000000000..e26995931 --- /dev/null +++ b/public/javascripts/org.js @@ -0,0 +1,45 @@ +//�����֯��Ա���ύ���� +function submit_add_org_members(){ + $("#org_member_add_form").submit(); +} + +function observeSearchfield(fieldId, targetId, url) { + $('#'+fieldId).each(function() { + var $this = $(this); + $this.addClass('autocomplete'); + $this.attr('data-value-was', $this.val()); + var check = function() { + var val = $this.val(); + if ($this.attr('data-value-was') != val){ + $this.attr('data-value-was', val); + $.ajax({ + url: url, + type: 'get', + data: {q: $this.val()}, + success: function(data){ if(targetId) $('#'+targetId).html(data); }, + beforeSend: function(){ $this.addClass('ajax-loading'); }, + complete: function(){ $this.removeClass('ajax-loading'); } + }); + } + }; + var reset = function() { + if (timer) { + clearInterval(timer); + timer = setInterval(check, 300); + } + }; + var timer = setInterval(check, 300); + $this.bind('keyup click mousemove', reset); + }); +} + +//显示更多的项目 +function show_more_org_project(url){ + $.get( + url, + { page: $("#org_project_page_num").val() }, + function (data) { + + } + ); +} \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 0cb6e203f..05bba54f6 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -555,7 +555,6 @@ a:hover.st_add{ color:#ff8e15;} a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} -.r_txt_tit{width:510px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#09658c; font-size:14px;} blockquote {background: #e8e8e8;padding: 10px;margin-bottom: 5px;word-break: break-all;word-wrap: break-word;} .respond-form{display: none;margin: auto;clear: both;} @@ -987,6 +986,7 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r .m_w505{max-width: 505px;} .m_w500{max-width: 500px;} .m_w530{max-width: 530px;} +.m_w600{max-width: 600px;} .ProResultTable{ color:#888888;} .T_C{ text-align:center;} .SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; } diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index ea45fdbd0..368964f3b 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -261,7 +261,7 @@ a:hover.grey_n_btn{ background:#717171; color:#fff;} .green_btn{ background:#28be6c; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;} a.green_btn{background:#28be6c;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.green_btn{ background:#14ad5a;} -.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +.blue_btn{ background:#64bdd9; color:#fff; font-weight:normal;padding:2px 8px; text-align:center;} a.blue_btn{background:#64bdd9;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;} a.orange_btn{ background:#ff5722;color:#fff; font-weight:normal; padding:2px 10px; text-align:center; } @@ -1082,6 +1082,7 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r .m_w460{max-width: 460px;} .m_w505{max-width: 505px;} .m_w530{max-width: 530px;} +.m_w600{max-width: 600px;} .ProResultTable{ color:#888888;} .T_C{ text-align:center;} .SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; } diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css new file mode 100644 index 000000000..c8116003e --- /dev/null +++ b/public/stylesheets/org.css @@ -0,0 +1,52 @@ +@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;} + +.orgSettingOp {width:45px; height:21px; color:#269ac9; text-align:center; border-bottom:3px solid #e4e4e4; float:left; font-weight:bold; cursor:pointer;} +.orgBorder {width:628px; height:21px; border-bottom:3px solid #e4e4e4; float:left;} +.orgOpActive {border-bottom:3px solid #269ac9 !important; color:#444444;} +.logoBorder {border:1px solid #eaeaea; padding:2px;} +.logoBorder:hover {border:1px solid #269ac9;} +.logoEnter {border:1px solid #eaeaea; padding:2px 5px; margin-top:37px;} +.orgNameInput {width:600px; outline:none; border:1px solid #eaeaea; float:right; height:22px;} +.orgRow {font-size:14px; color:#484848;} +.orgDes {width:600px; height:150px; outline:none; border:1px solid #eaeaea; float:right; resize:none;} +.w607 {width:607px;} +.orgUrlInput {width:200px; outline:none; border:1px solid #eaeaea; height:22px;} +a.saveBtn {padding:3px 5px; background-color:#269ac9; color:#ffffff;} +a.saveBtn:hover {background-color:#297fb8;} +.orgMemberList {width:410px; float:left;} +.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px;} +.orgListUser {width:119px; float:left;} +.orgListRole {width:180px; float:left;} +.orgMemContainer {width:278px;} +.orgMemberAdd {float:right; width:240px;} +.orgAddSearch {border:1px solid #dddddd; outline:none; width:180px; height:22px; color:#9b9b9b;} +.undis {display:none;} +.dis {display:inline-block;} +.upbtn { margin: 40px 0px 0px 15px; + display: block; + padding: 2px 5px; + border: 1px solid #EAEAEA;} + +a.org_member_btn{ padding:1px 5px; background:#15bccf; color:#fff;} + +/*项目关联css*/ +.relateOrg {width:335px;} +.relatedList {width:335px;} +.searchOrg {height:24px; width:200px; color:#9b9b9b9; border:1px solid #15bccf;} +a.cancelBtn {padding:3px 5px; background-color:#D9D9D9; color:#656565;} +a.cancelBtn:hover {background-color:#717171; color:#ffffff;} +.relatedList ul li {border-bottom:1px solid #e4e4e4; width:320px; height:22px; vertical-align:middle; line-height:22px;} +.relatedListName {width:240px; text-align:left; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} +.relatedListOption {width:80px; text-align:center;} +.relateOrgName {width:240px; max-width:240px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;color:#656565;} + +/*组织列表*/ +.mt28 {margin-top:28px;} +.orgWrap {width:880px; float:left;} +.orgTitle {width:880px; max-width:880px; margin-bottom:5px;word-break: break-all; word-wrap:break-word; } +.orgIntro {width:880px; max-width:880px; margin-bottom:6px; color:#484848;} \ No newline at end of file diff --git a/spec/controllers/org_document_comment_controller_spec.rb b/spec/controllers/org_document_comment_controller_spec.rb new file mode 100644 index 000000000..016416264 --- /dev/null +++ b/spec/controllers/org_document_comment_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgDocumentCommentController, :type => :controller do + +end diff --git a/spec/controllers/org_member_controller_spec.rb b/spec/controllers/org_member_controller_spec.rb new file mode 100644 index 000000000..a116db00f --- /dev/null +++ b/spec/controllers/org_member_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgMemberController, :type => :controller do + +end diff --git a/spec/controllers/org_projects_controller_spec.rb b/spec/controllers/org_projects_controller_spec.rb new file mode 100644 index 000000000..8adc91d66 --- /dev/null +++ b/spec/controllers/org_projects_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgProjectsController, :type => :controller do + +end 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_activities.rb b/spec/factories/org_activities.rb new file mode 100644 index 000000000..552ea70f9 --- /dev/null +++ b/spec/factories/org_activities.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :org_activity do + + end + +end diff --git a/spec/factories/org_document_comments.rb b/spec/factories/org_document_comments.rb new file mode 100644 index 000000000..206c471aa --- /dev/null +++ b/spec/factories/org_document_comments.rb @@ -0,0 +1,11 @@ +FactoryGirl.define do + factory :org_document_comment do + title "MyString" +content "MyText" +organization_id 1 +creator_id 1 +parent_id 1 +reply_id 1 + end + +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_activity_spec.rb b/spec/models/org_activity_spec.rb new file mode 100644 index 000000000..e452fe172 --- /dev/null +++ b/spec/models/org_activity_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgActivity, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/org_document_comment_spec.rb b/spec/models/org_document_comment_spec.rb new file mode 100644 index 000000000..ba5dd15a4 --- /dev/null +++ b/spec/models/org_document_comment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgDocumentComment, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +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