diff --git a/app/assets/javascripts/org_courses.js.coffee b/app/assets/javascripts/org_courses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_courses.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_courses.css.scss b/app/assets/stylesheets/org_courses.css.scss new file mode 100644 index 000000000..026af5d01 --- /dev/null +++ b/app/assets/stylesheets/org_courses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_courses 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/courses_controller.rb b/app/controllers/courses_controller.rb index 1a561006a..cd1de16fc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -29,6 +29,30 @@ class CoursesController < ApplicationController before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] + #查找组织 + def search_public_orgs_not_in_course + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id) + if course_org_ids.empty? + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) 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 + course_org_ids = "(" + course_org_ids.join(',') + ")" + @orgs_not_in_course = Organization.where("id not in #{course_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 #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + @hint_flag = params[:hint_flag] + #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json + respond_to do |format| + format.js + end + end + def join if User.current.logged? cs = CoursesService.new diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index cbbf36ea8..a2902e3fc 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -24,7 +24,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] + before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] helper :sort include SortHelper diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e529dd3b9..edf055370 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -397,6 +397,23 @@ class IssuesController < ApplicationController end end + def add_journal_in_org + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first + org_activity.updated_at = jour.created_on + org_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + private def find_project diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 4f78d61f5..9b090de9a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -174,6 +174,11 @@ class MessagesController < ApplicationController user_activity.updated_at = Time.now user_activity.save end + org_activity = OrgActivity.where("org_act_type='Message' and org_act_id =#{@topic.id}").first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] diff --git a/app/controllers/org_courses_controller.rb b/app/controllers/org_courses_controller.rb new file mode 100644 index 000000000..3d1d313c5 --- /dev/null +++ b/app/controllers/org_courses_controller.rb @@ -0,0 +1,18 @@ +class OrgCoursesController < ApplicationController + def create + org_ids = params[:orgNames] + @course = Course.find(params[:course_id]) + org_ids.each do |org_id| + OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) + end + respond_to do |format| + format.js + end + end + + def destroy + @course = Course.find(params[:course_id]) + @org_course = OrgCourse.find(params[:id]) + @org_course.destroy + end +end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 60522dc3f..61a27c433 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -12,7 +12,7 @@ class OrgDocumentCommentsController < ApplicationController @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' + flash.keep[:notice] = l(:notice_successful_create) OrgActivity redirect_to organization_org_document_comments_path(@organization) else @@ -20,15 +20,23 @@ class OrgDocumentCommentsController < ApplicationController end end def show - + @document = OrgDocumentComment.find(params[:id]) end def index - @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + else + render_403 + end 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]) + if @org_document.parent.nil? + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first + act.update_attributes(:updated_at => @org_document.updated_at) + end respond_to do |format| format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)} end @@ -41,12 +49,24 @@ class OrgDocumentCommentsController < ApplicationController def add_reply @document = OrgDocumentComment.find(params[:id]).root + @act = OrgActivity.find(params[:id]) @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 add_reply_in_doc + @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_comment][:org_content] + @document.children << @comment + @document.save + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def find_organization @organization = Organization.find(params[:organization_id]) end @@ -59,5 +79,66 @@ class OrgDocumentCommentsController < ApplicationController org.home_id == nil end end + respond_to do |format| + format.js + end + end + + def delete_reply + @org_document_comment = OrgDocumentComment.find(params[:id]) + @document = @org_document_comment.root + org = @org_document_comment.organization + @org_document_comment.destroy + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def quote + @org_comment = OrgDocumentComment.find(params[:id]) + @subject = @org_comment.content + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " + @temp = OrgDocumentComment.new + #@course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}".html_safe + respond_to do | format| + format.js + end + end + + def reply + @document = OrgDocumentComment.find(params[:id]).root + @quote = params[:quote][:quote] + @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) + + # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @org_document.title = params[:org_document_comment][:title] + @org_document.content = params[:org_document_comment][:content] + @org_document.content = @quote + @org_document.content + #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document + # @user_activity_id = params[:user_activity_id] + # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + # if user_activity + # user_activity.updated_at = Time.now + # user_activity.save + # end + # attachments = Attachment.attach_files(@org_document, params[:attachments]) + # render_attachment_warning_if_needed(@org_document) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + # redirect_to syllabus_course_path(:id=>params[:course_id]) + # else + redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) + # end + + } + format.js + end end end diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb index 733df95b7..29e60a62a 100644 --- a/app/controllers/org_projects_controller.rb +++ b/app/controllers/org_projects_controller.rb @@ -4,7 +4,6 @@ class OrgProjectsController < ApplicationController @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 @@ -14,18 +13,5 @@ class OrgProjectsController < ApplicationController @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/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6a1030adc..0d22ab461 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -56,13 +56,29 @@ class OrganizationsController < ApplicationController if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) project_ids = @organization.projects.map(&:id) << 0 - @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - @org_activities_count = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))" , - @organization.id, 'Organization ').count - # @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 + course_ids = @organization.courses.map(&:id) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + end @page = params[:page] respond_to do |format| format.html @@ -135,13 +151,26 @@ class OrganizationsController < ApplicationController end def members - @members = OrgMember.where("organization_id =?", @organization.id) + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @members = OrgMember.where("organization_id =?", @organization.id) + else + render_403 + end 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) + @org_projects = @organization.projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + respond_to do |format| + format.js + end + end + + def more_org_courses + @organization = Organization.find(params[:id]) + @page = params[:page] + @org_courses = @organization.courses.reorder('created_at').page((params[:page].to_i || 1) + 1 ).per(5) respond_to do |format| format.js end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index baa7db060..715f56d3d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,6 +86,7 @@ class ProjectsController < ApplicationController end # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count @orgs_page = Paginator.new @org_count, 10,params[:page] + @no_roll_hint = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json respond_to do |format| format.js diff --git a/app/helpers/org_courses_helper.rb b/app/helpers/org_courses_helper.rb new file mode 100644 index 000000000..28655e52e --- /dev/null +++ b/app/helpers/org_courses_helper.rb @@ -0,0 +1,2 @@ +module OrgCoursesHelper +end diff --git a/app/models/course.rb b/app/models/course.rb index 913449d22..1350b8cf7 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -18,6 +18,8 @@ class Course < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :principals, :through => :member_principals, :source => :principal has_many :users, :through => :members + has_many :org_courses + has_many :organizations, :through => :org_courses # has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy # has_many :homework_for_courses, :dependent => :destroy diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 4e74142ad..e1f9ab9f5 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,8 +5,8 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity - before_destroy :destroy_user_activity + after_save :add_user_activity, :add_course_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -30,8 +30,34 @@ class CourseActivity < ActiveRecord::Base end end + def add_course_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first + if org_activity + org_activity.save + else + if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, + :org_act_id => self.course_act_id, + :org_act_type => self.course_act_type, + :container_id => self.course_id, + :container_type => 'Course', + :created_at => self.created_at, + :updated_at => self.updated_at) + end + end + end + def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'") + org_activity.destroy_all + end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 8a94f1019..bb5f30442 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -21,7 +21,7 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act after_save :add_user_activity, :add_org_activity - before_destroy :destroy_user_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -46,17 +46,28 @@ class ForgeActivity < ActiveRecord::Base end def add_org_activity - OrgActivity.create(:user_id => self.user_id, + if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.forge_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, :org_act_id => self.forge_act_id, :org_act_type => self.forge_act_type, :container_id => self.project_id, :container_type => 'Project', :created_at => self.created_at, :updated_at => self.updated_at) + end end def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and org_act_id = '#{self.forge_act_id}'") + org_acts.destroy_all + end end diff --git a/app/models/org_course.rb b/app/models/org_course.rb new file mode 100644 index 000000000..8c198794a --- /dev/null +++ b/app/models/org_course.rb @@ -0,0 +1,5 @@ +class OrgCourse < ActiveRecord::Base + #attr_accessible :organization, :course, :created_at + belongs_to :organization + belongs_to :course +end diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index 2b3c9132a..7b9f9cd75 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -11,6 +11,10 @@ class OrgDocumentComment < ActiveRecord::Base 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') + else + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", self.root.id).first + act.update_attributes(:updated_at => self.updated_at) end end + end diff --git a/app/models/organization.rb b/app/models/organization.rb index 7778da477..d3755b5ee 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -3,7 +3,9 @@ class Organization < ActiveRecord::Base has_many :org_members, :dependent => :destroy has_many :org_projects ,:dependent => :destroy has_many :projects,:through => :org_projects + has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy + has_many :org_courses has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index e566a8f46..5d60238bf 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -186,6 +186,7 @@ class CoursesService #params[:setup_time]:暂不传(貌似已经没用了) #params[:endup_time]: 暂不传(貌似已经没用了) #params[:class_period]:学时总数 + #params[:course][:publish_resource]允许学生上传资源 def create_course(params,current_user) if current_user.user_extensions.identity @course = Course.new @@ -202,6 +203,7 @@ class CoursesService @course.class_period = params[:class_period].to_i params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0 params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0 + params[:course][:publish_resource] ? @course.publish_resource = 1 : @course.publish_resource = 0 else end @@ -243,6 +245,7 @@ class CoursesService #params[:term]:学期(秋季学期或春季学期) #params[:time]: 年份(例:2014) #params[:class_period]:学时总数 + #params[:publish_resource] 允许学生上传资源 0 不允许 1 允许 def edit_course(params,course,current_user) course.send(:safe_attributes=, params[:course], current_user) #course.safe_attributes = params[:course] @@ -251,6 +254,7 @@ class CoursesService course.class_period = params[:class_period].to_i params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0 params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0 + params[:course][:publish_resource] ? course.publish_resource = 1 : course.publish_resource = 0 if course.save if params[:course][:is_public] == '0' course_status = CourseStatus.find_by_course_id(course.id) diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index d2c17917e..f1b917816 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -50,6 +50,12 @@ (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) +
#{@org_comment.content.html_safe}
上传:
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 4cc249c20..f04d70577 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -32,7 +32,7 @@
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
- <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
+ <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<% if @course.is_public? %>
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
@@ -57,7 +57,7 @@
文件大小:<%= number_to_human_size(file.filesize) %> <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+
+
+
+ ');
$("#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
index 49ea1dc33..f8927280a 100644
--- a/app/views/org_projects/destroy.js.erb
+++ b/app/views/org_projects/destroy.js.erb
@@ -1,22 +1,4 @@
-//$("#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 %>
+$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>');
+
diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb
index cb69738b6..aa48fedf1 100644
--- a/app/views/organizations/_org_activities.html.erb
+++ b/app/views/organizations/_org_activities.html.erb
@@ -1,5 +1,10 @@
<% unless org_activities.nil? %>
<% org_activities.each do |act| %>
+
<% if act.container_type == 'Organization' %>
<% if act.org_act_type == 'CreateOrganization' %>
+
+
+
+
+ <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+
+
+
+ ');
<% @orgs_not_in_project.each do |org|%>
diff --git a/app/views/projects/settings/_added_orgs.html.erb b/app/views/projects/settings/_added_orgs.html.erb
index d07ead277..19e0c07fe 100644
--- a/app/views/projects/settings/_added_orgs.html.erb
+++ b/app/views/projects/settings/_added_orgs.html.erb
@@ -2,7 +2,8 @@
-
- 关联
- 取消
+ <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %>
+
+
+
+ 关联
+ 取消
+ <% end %>