课程动态
暂无内容,敬请期待!
+ + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index c7aa42b9e..e1e99447d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -548,7 +548,8 @@ class AdminController < ApplicationController #作业 def homework - @homework = HomeworkCommon.order('end_time desc') + #@homework = HomeworkCommon.order('end_time desc') + @homework = HomeworkCommon.order( 'created_at desc ') @homework = paginateHelper @homework,30 @page = (params['page'] || 1).to_i - 1 respond_to do |format| diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9853b4dc1..63e823063 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -70,8 +70,8 @@ class AttachmentsController < ApplicationController def direct_download @attachment.increment_download send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'attachment' #inline can open in browser + :type => detect_content_type(@attachment), + :disposition => 'attachment' #inline can open in browser end def direct_download_history @@ -175,7 +175,7 @@ class AttachmentsController < ApplicationController @attachment = Attachment.find(params[:attachmentid]) if @attachment != nil filedense = params[:newtype].to_s - # d = Iconv.conv("unicodebig","utf-8",filedense) + # d = Iconv.conv("unicodebig","utf-8",filedense) if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public) @attachment.is_public = 1 else @@ -210,9 +210,9 @@ class AttachmentsController < ApplicationController if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if stale?(:etag => thumbnail) send_file thumbnail, - :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'inline' + :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => 'inline' end else # No thumbnail for the attachment or thumbnail could not be created @@ -292,10 +292,10 @@ class AttachmentsController < ApplicationController respond_to do |format| if !@attachment.container.nil? && - (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && - @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && - @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) || - @attachment.container.is_a?(StudentWork)) + (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && + @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && + @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) || + @attachment.container.is_a?(StudentWork)) if @attachment.container.is_a?(News) format.html { redirect_to_referer_or news_path(@attachment.container) } elsif @attachment.container.is_a?(StudentWorksScore) @@ -327,25 +327,25 @@ class AttachmentsController < ApplicationController elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment) format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)} else - if @project.nil? - format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } - else + if @project.nil? + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } + else format.html { redirect_to_referer_or project_path(@project) } - end + end end format.js - end + end end def delete_homework - @bid = @attachment.container.bid - # Make sure association callbacks are called - container = @attachment.container - @attachment.container.attachments.delete(@attachment) - #if container.attachments.empty? - #container.delete - #end + @bid = @attachment.container.bid + # Make sure association callbacks are called + container = @attachment.container + @attachment.container.attachments.delete(@attachment) + #if container.attachments.empty? + #container.delete + #end respond_to do |format| format.html { redirect_to_referer_or respond_path(@bid) } @@ -594,7 +594,7 @@ class AttachmentsController < ApplicationController end end -private + private def find_project @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong @@ -608,7 +608,7 @@ private @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end @@ -628,7 +628,7 @@ private def read_authorize if @attachment.container_type == "HomeworkAttach" || @attachment.container_type == 'Bid' - true + true #User.current.allowed_to?(:view_homework_attaches, @attachment.project) ? true : deny_access else @attachment.visible? ? true : deny_access @@ -654,7 +654,7 @@ private def renderTag @attachmentNew = Attachment.find(params[:attchmentId]) - respond_to do |format| + respond_to do |format| format.js end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 69b356b5a..cf94da8d9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -623,6 +623,36 @@ class FilesController < ApplicationController @attachtype = 0 @contenttype = 0 + respond_to do |format| + format.js + # format.html { + # redirect_to org_subfield_files_url(@org_subfield) + # } + end + # 组织添加附件,为了修改图片 + elsif params[:organization_id] + @organization = Organization.find(params[:organization_id]) + @addTag=false + # atttchment_type = 0为logo 1为banner + if params[:logo] + attachments = Attachment.attach_filesex(@organization, params[:attachments], false) + else + attachments = Attachment.attach_filesex(@organization, params[:attachments], true) + end + # TODO: 临时用 nyan + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)] + + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + @attachtype = 0 + @contenttype = 0 + respond_to do |format| format.js # format.html { diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index bc339319b..661073cdc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -130,6 +130,12 @@ class OrgSubfieldsController < ApplicationController @organization = @org_subfield.organization end + def update_status + @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) + @subfield.update_attributes(:status => params[:status]) + end + def show_attachments obj @attachments = [] obj.each do |container| diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 80f196ba5..ab97b5b1b 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,18 +28,25 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper - before_filter :find_organization, :only => [:show, :members, :apply_subdomain] + before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout] layout 'base_org' def index end + + def new @organization = Organization.new render :layout => 'new_base' end def edit - @organization = Organization.find(params[:id]) + # @organization = Organization.find(params[:id]) + begin + @organization = Organization.where("id =?", params[:id]) + ensure + render_404 + end end def destroy @@ -56,7 +63,7 @@ class OrganizationsController < ApplicationController @organization.description = params[:organization][:description] @organization.is_public = params[:organization][:is_public] @organization.allow_guest_download = params[:organization][:allow_guest_download] == '1' ? 1 : 0 - @organization.show_mode = params[:show_mode] + @organization.show_mode = 0 @organization.creator_id = User.current.id member = OrgMember.new(:user_id => User.current.id) @@ -68,50 +75,170 @@ class OrganizationsController < ApplicationController end def show - if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - @organization = Organization.find(params[:id]) - # 统计访问量 - @organization.update_attribute(:visits, @organization.visits.to_i + 1) - if params[:org_subfield_id] - @org_subfield = OrgSubfield.find(params[:org_subfield_id]) - @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 - @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + # 组织新类型 show_mode:判断标准 1为新类型,0为旧 + if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:list] .nil? + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + # REDO:时间紧,暂时先这样 + @org_logo_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 0).order("created_on desc").first + @org_banner_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 1).order("created_on desc").first + + @subfield_content = @organization.org_subfields.order("priority") + @organization = Organization.find(params[:id]) + # 统计访问量 + @organization.update_column(:visits, @organization.visits.to_i + 1) + + # @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + # @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + # @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + + shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) + project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + @project_acts = get_project_activities_org @organization, project_ids + @course_acts = get_course_activities_org @organization, course_ids + #@org_acts = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc') + #@project_acts = OrgActivity.where("(container_id =? and container_type =?) " + + # "or (container_type ='Project' and org_act_type in ('Issue','Message') and container_id in (#{project_ids.join(',')})) ", + # @organization.id, 'Organization').order('updated_at desc').limit(8) + + #@course_acts = OrgActivity.where("(container_id =? and container_type =?) " + + # "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').limit(8) + + + + # 项目两种动态 + #@project_acts = get_project_activities_org @organization + + # 课程动态 + #@project_acts_issues = get_project_activities_org @organization + #@course_acts = get_course_activities_org @organization + + render :layout => 'base_org_newstyle' else - shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) - shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) - project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 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 - end - @page = params[:page] ? params[:page].to_i : 1 - respond_to do |format| - format.html - format.js + render_403 end else - render_403 + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @organization = Organization.find(params[:id]) + # 统计访问量 + @organization.update_column(:visits, @organization.visits.to_i + 1) + if params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + else + shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) + project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 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 + end + @page = params[:page] ? params[:page].to_i : 1 + respond_to do |format| + format.html + format.js + end + else + render_403 + end end + + end + + def get_project_message_activities_org org + project_ids = org.projects.map{|project| project.id}.join(",") + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'Message' order by updated_at desc limit 2;") + else + project_acts = nil + end + end + + def get_project_issue_activities_org org + project_ids = org.projects.map{|project| project.id}.join(",") + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + end + + # 获取整过项目的动态 + def get_project_activities_org org, project_ids + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids.join(',')}) and container_type = 'project' + and org_act_type in ('Message', 'Issue') order by updated_at desc limit 8;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + end + + # 获取整过课程的动态 + def get_course_activities_org org, course_ids + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids.join(',')}) and container_type = 'course' + and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 8;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;") + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + end + + def get_course_homework_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;") + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + end + + def get_course_message_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'Message' order by updated_at desc limit 1;") + else + project_acts = nil + end + end + + def get_course_news_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;") end def update @@ -125,9 +252,13 @@ class OrganizationsController < ApplicationController #@organization.name = params[:organization][:name] @organization.save respond_to do |format| + if @organization.show_mode == 1 + format.html { redirect_to organization_path(@organization)} + else format.html { redirect_to setting_organization_path(@organization)} end end + end def check_uniq @check = false; @@ -159,11 +290,6 @@ class OrganizationsController < ApplicationController end end - - def clear_org_avatar_temp - - end - def set_homepage @org = Organization.find(params[:id]) @org.home_id = params[:home_id] diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 69c355313..4faa802a5 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,6 +1,7 @@ # encoding: utf-8 module OrganizationsHelper include ApplicationHelper + include FilesHelper def find_user_not_in_current_org_by_name org @@ -28,4 +29,48 @@ module OrganizationsHelper end end + def get_message_org(org_id, field_id) + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;") + end + + def get_message_reply_org(org_id, ids) + # OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;") + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;") + end + + def get_attach_org(field_id) + Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + def get_attach_org2(field) + org_attachments = field.attachments + attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments) + return attachments.sort_by{|x| x.created_on}.reverse.first(6) + # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + # 从内容中获取路径 + def get_image_path_from_content content + r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/) + if r.match(content).nil? + image_path = nil + else + image_path = r.match(content)[1] + end + end + + #排列下拉框 + def subfield_status_option + type = [] + option1 = [] + option1 << "列表" + option1 << "1" + type << option1 + option2 = [] + option2 << "图片" + option2 << "0" + type << option2 + type + end + end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 881621c3a..754bd4dee 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" + belongs_to :organization, foreign_key: 'container_id', conditions: "attachements.container_type = 'Organization'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" diff --git a/app/models/organization.rb b/app/models/organization.rb index 248783a26..427cd4c10 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -8,6 +8,8 @@ class Organization < ActiveRecord::Base has_many :org_courses, :dependent => :destroy has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members + has_many :files + acts_as_attachable validates_uniqueness_of :name after_create :save_as_org_activity, :add_default_subfields diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb index 7260d68ff..03472d0a0 100644 --- a/app/views/admin/homework.html.erb +++ b/app/views/admin/homework.html.erb @@ -22,24 +22,27 @@ 提交作品数
建议上传高度不超过52px的图片
+ +暂无内容,敬请期待!
+ + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +暂无内容,敬请期待!
+ + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +暂无内容,敬请期待!
+ + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +暂无内容,敬请期待!
+ + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +暂无内容,敬请期待!
+ + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +暂无内容,敬请期待!
+ + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + + <% else %> +暂无内容,敬请期待!
+ + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + + <% else %> +发布时间:<%= format_date activity.updated_at %> + 作者:<%= activity.try(:user).try(:realname).nil? ? activity.try(:user).try(:login) : activity.try(:user).try(:realname) %> + <%= activity.journals_for_messages.count %>
+发布时间:<%= format_date activity.updated_on %> + 作者:<%= activity.try(:author).try(:realname).nil? ? activity.try(:author).try(:login) : activity.try(:author).try(:realname) %> + <%= activity.children.count %>
+发布时间:<%= format_date activity.created_on %> + 作者:<%= activity.try(:author).try(:realname).nil? ? activity.try(:author).try(:login) : activity.try(:author).try(:realname) %> + <%= activity.comments.count %>
+发布时间:<%= format_date activity.published_at %> + 作者:<%= activity.try(:user).try(:realname).nil? ? activity.try(:user) : activity.try(:user).try(:realname) %> + 0
+发布时间:<%= format_date activity.created_at %> + 作者:<%= activity.try(:teacher).try(:realname).nil? ? activity.try(:teacher) : activity.try(:teacher).try(:realname) %> + 0
+<%= format_date activity.updated_at %>
+<%= format_date activity.updated_on %>
+<%= format_date activity.created_on %>
+<%= format_date activity.updated_at %>
+<%= format_date activity.updated_on %>
+<%= format_date activity.created_on %>
+<%= format_date activity.published_at %>
+发布时间:<%= format_date document.created_at %> + 作者:<%= document.try(:creator).try(:realname).nil? ? document.try(:creator).try(:login) : document.try(:creator).try(:realname) %> + <%= document.children.count %>
+发布时间:<%= format_date message.created_on %> + 作者:<%= message.try(:author).try(:realname).nil? ? message.try(:author).try(:login) : message.try(:author).try(:realname) %> + <%= message.children.count %>
+发布时间:<%= format_date message.updated_at %> + 作者:<%= message.try(:author).try(:realname).nil? ? message.try(:author).try(:login) : message.try(:author).try(:realname) %> + <%= message.children.count %>
+发布时间:<%= format_date news.created_on %> + 作者:<%= news.try(:author).try(:realname).nil? ? news.try(:author).try(:login) : news.try(:author).try(:realname) %> + <%= news.comments.count %>
+<%= format_date document.created_at %>
+<%= format_date message.created_on %>
+<%= format_date message.created_on %>
+<%= format_date news.created_on %>
+<%= activity.content.html_safe %>
+ \ No newline at end of file diff --git a/app/views/organizations/_org_new_project_act_list.html.erb b/app/views/organizations/_org_new_project_act_list.html.erb new file mode 100644 index 000000000..278972b1a --- /dev/null +++ b/app/views/organizations/_org_new_project_act_list.html.erb @@ -0,0 +1,49 @@ +<% activities.each do |act| %> + <% if act.org_act_type == "Issue" %> + <% activity = Issue.find(act.org_act_id) %> +发布时间:<%= format_date activity.updated_on %> + 作者:<%= activity.try(:author).try(:realname).nil? ? activity.try(:author).try(:login) : activity.try(:author).try(:realname) %> + <%= activity.journals.count %>
+发布时间:<%= format_date activity.updated_on %> + 作者:<%= activity.try(:author).try(:realname).nil? ? activity.try(:author).try(:login) : activity.try(:author).try(:realname) %> + <%= activity.children.count %>
+发布时间:<%= format_date activity.created_on %> + 作者:<%= activity.try(:author).try(:realname).nil? ? activity.try(:author).try(:login) : activity.try(:author).try(:realname) %> + <%= activity.comments.count %>
+<%= format_date activity.updated_on %>
+<%= format_date activity.updated_on %>
+<%= format_date activity.created_on %>
+上传时间:<%= format_date attach.created_on %>类型:<%= attach.tag_list[0] %> 下载次数:<%= attach.downloads%> 引用:<%= attach.quotes.nil? ? 0:attach.quotes %>
+