diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index daab58bde..f663bc272 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -63,6 +63,33 @@ class AdminController < ApplicationController
end
end
+ #精品课程下的全部课程
+ def excellent_all_courses
+ @name = params[:name]
+ @courses = Course.like(@name).order('created_at desc')
+ @courses = paginateHelper @courses,30
+ @page = (params['page'] || 1).to_i - 1
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #设为精品
+ def set_excellent_course
+ @course = Course.find params[:id]
+ unless @course.nil?
+ if @course.is_excellent == 1 || @course.excellent_option == 1
+ @course.update_column('is_excellent', 0)
+ @course.update_column('excellent_option', 0)
+ else
+ @course.update_column('is_excellent', 1)
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
#管理员界面课程资源列表
def course_resource_list
@@ -548,7 +575,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..1dacffb6f 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,14 +654,16 @@ private
def renderTag
@attachmentNew = Attachment.find(params[:attchmentId])
- respond_to do |format|
+ respond_to do |format|
format.js
end
end
def has_login
- unless @attachment && @attachment.container_type == "PhoneAppVersion"
- render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download)
+ unless @attachment && @attachment.container_type == "Organization"
+ unless @attachment && @attachment.container_type == "PhoneAppVersion"
+ render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download)
+ end
end
end
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 698a5ac4f..796d541ca 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -334,7 +334,7 @@ class CoursesController < ApplicationController
def export_course_member_excel
@all_members = student_homework_score(0,0,0,"desc")
- @homeworks = @course.homework_commons.order("created_at desc")
+ @homeworks = @course.homework_commons.order("created_at asc")
filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}";
respond_to do |format|
@@ -851,8 +851,6 @@ class CoursesController < ApplicationController
# render_403
# return
# end
- # 统计访问量
- @course.update_column(:visits, @course.visits.to_i + 1)
#更新创建课程消息状态
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true)
@@ -1155,7 +1153,7 @@ class CoursesController < ApplicationController
sql_select = ""
if groupid == 0
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
+ SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
@@ -1167,7 +1165,7 @@ class CoursesController < ApplicationController
WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}"
else
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
+ SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
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/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 091e2b86b..49e6ec290 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -17,9 +17,11 @@ class HomeworkCommonController < ApplicationController
@page = params[:page] ? params[:page].to_i + 1 : 0
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
if @is_teacher
- @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
+ @homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10)
+ @homework_commons = @course.homework_commons.order("created_at desc")
else
- @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
+ @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10)
+ @homework_commons = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc")
end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@is_new = params[:is_new]
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 da0eb8009..457b3bfa1 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,6 +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 = 0
@organization.creator_id = User.current.id
member = OrgMember.new(:user_id => User.current.id)
@@ -67,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
@@ -120,12 +248,17 @@ class OrganizationsController < ApplicationController
# @organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
@organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0
+ @organization.show_mode = params[:show_mode]
#@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;
@@ -157,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]
@@ -224,8 +352,13 @@ class OrganizationsController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
- sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
- "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
+ if User.current.admin?
+ sql = "select courses.* from courses where courses.is_public = 1 and courses.name like '#{condition}'"+
+ "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
+ else
+ sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.is_public = 1 and courses.name like '#{condition}'"+
+ "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
+ end
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
@@ -268,8 +401,13 @@ class OrganizationsController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
- sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
+ if User.current.admin?
+ sql = "select projects.* from projects where projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1"
+ else
+ sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" +
+ " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1"
+ end
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 113e37af3..5c8d194b9 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -299,8 +299,6 @@ class ProjectsController < ApplicationController
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
- # 统计访问量
- @project.update_column(:visits, @project.visits + 1)
# over
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
@page = params[:page] ? params[:page].to_i + 1 : 0
@@ -321,6 +319,10 @@ class ProjectsController < ApplicationController
else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10);
end
+ g = Gitlab.client
+ unless @project.gpid.nil?
+ @static_total_per_user = g.rep_stats(@project.gpid)
+ end
# 根据对应的请求,返回对应的数据
respond_to do |format|
format.html
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 9bb6055ee..82a6196cb 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -30,7 +30,7 @@ class RepositoriesController < ApplicationController
menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
default_search_scope :changesets
- before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo]
+ before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
@@ -332,7 +332,7 @@ update
# end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
- @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
+ # @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
# :name, :path, :kind, :size, :lastrev, :changeset
@entries = @repository.entries(@path, @rev)
@@ -348,24 +348,25 @@ update
# (show_error_not_found; return) unless @entries
g = Gitlab.client
@changesets = g.commits(@project.gpid, :ref_name => @rev)
- # @changesets = @repository.latest_changesets(@path, @rev)
- # @changesets_count = @repository.latest_changesets(@path, @rev).count
+ # 总的提交数
@changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count
# 访问该页面的是会后则刷新
if @project.project_score.nil?
ProjectScore.create(:project_id => @project.id, :score => false)
end
+ # 刷新改页面的时候,更新统计数
if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0
update_commits_count(@project, @changesets_all_count)
end
# end
+ # 最近一次提交
@changesets_latest_coimmit = @changesets[0]
unless @changesets[0].blank?
update_commits_date(@project, @changesets_latest_coimmit)
end
+ @creator = User.where("id =?", @project.user_id).first.try(:login)
@properties = @repository.properties(@path, @rev)
@repositories = @project.repositories
- @course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS
gitlab_address = Redmine::Configuration['gitlab_address']
@@ -374,11 +375,7 @@ update
else
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s + @repository.url.slice(project_path_cut, @repository.url.length).to_s
end
- if @course_tag == 1
- render :action => 'show', :layout => 'base_courses'
- else
- render :action => 'show', :layout => 'base_projects'
- end
+ render :action => 'show', :layout => 'base_projects'
end
end
@@ -390,7 +387,7 @@ update
g = Gitlab.client
limit = 20
#每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来
- @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s)
+ @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:@rev)
#add by hx
#rep_count = commit_count(@project)
@@ -565,10 +562,24 @@ update
end
def stats
- @project_id = params[:id]
- @repository_id = @repository.identifier
- # 提交次数统计
- @status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
+ if @project.gpid.nil?
+ render 404
+ return
+ end
+ project_id = @project.gpid
+ # @repository_id = @repository.identifier
+ # creator = params[:creator]
+ rev = params[:rev]
+ g = Gitlab.client
+ begin
+ @static_total_per_user = g.rep_stats(project_id, :rev => rev)
+ @static_total_per_user
+ # @static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2)
+ # @static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3)
+ rescue
+ render_404
+ return
+ end
render :layout => 'base_projects'
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index a2bf24b96..6383a0d24 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -695,7 +695,7 @@ class StudentWorkController < ApplicationController
end
end
end
- redirect_to user_homeworks_user_path(User.current.id)
+ redirect_to student_homeworks_user_path(User.current.id)
end
def retry_work
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f885c5c1c..8e08508ed 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -836,8 +836,8 @@ class UsersController < ApplicationController
render_403
return
end
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@@ -886,11 +886,11 @@ class UsersController < ApplicationController
def user_ref_resource_search
search = params[:search].to_s.strip.downcase
if(params[:type].blank? || params[:type] == "1") #全部
- user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "2" #课程资源
- user_course_ids = User.current.courses.map { |c| c.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "3" #项目资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
@@ -1122,13 +1122,13 @@ class UsersController < ApplicationController
#显示更多用户课程
def user_courses4show
@page = params[:page].to_i + 1
- @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
+ @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
end
#显示更多用户项目
def user_projects4show
@page = params[:page].to_i + 1
- @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5)
+ @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5)
end
def user_course_activities
@@ -1206,8 +1206,6 @@ class UsersController < ApplicationController
end
def show
- # 统计访问量
- @user.update_column(:visits, @user.visits.to_i + 1) unless User.current == @user
#更新用户申请成为课程老师或教辅消息的状态
if params[:course_id] != nil
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
@@ -1579,16 +1577,14 @@ class UsersController < ApplicationController
# 上传用户资源
def user_resource_create
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
# user_org_ids = User.current.organizations.map {|o| o.id}
@user = User.find(params[:id])
# 保存文件
attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@@ -1618,8 +1614,10 @@ class UsersController < ApplicationController
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end
+
@status = params[:status]
@type = params[:type]
+ @path = user_resource_user_path(User.current, :type => @type)
@limit = 25
@is_remote = true
@atta_count = @attachments.count
@@ -1677,6 +1675,7 @@ class UsersController < ApplicationController
end
@status = params[:status]
@type = params[:type]
+ @path = user_resource_user_path(User.current, :type => @type)
@limit = 25
@is_remote = true
@atta_count = @attachments.count
@@ -1701,6 +1700,7 @@ class UsersController < ApplicationController
.select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
end
@search = params[:search]
+ @type = params[:type]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids]
@@ -1719,6 +1719,7 @@ class UsersController < ApplicationController
@projects = @user.projects.visible
end
@search = params[:search]
+ @type = params[:type]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids] #搜索的时候 和 直接 用表格提交的时候的send_ids
@@ -1815,11 +1816,41 @@ class UsersController < ApplicationController
else
@flag = false
end
+ @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
+ @score = @b_sort == "desc" ? "asc" : "desc"
+ user_project_ids = User.current.projects.map {|p| p.id}
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
+ if(params[:type].blank? || params[:type] == "1") # 我的资源
+ # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
+ if params[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
+ end
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @attachments = get_course_resources_public( user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources_public(user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources_public(@order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources_public(@order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
+ end
+ end
@type = params[:type]
@limit = 25
+ @path = user_resource_user_path(User.current, :type => @type)
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@@ -1926,11 +1957,42 @@ class UsersController < ApplicationController
else
@flag=true
end
+ @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
+ @score = @b_sort == "desc" ? "asc" : "desc"
+ user_project_ids = User.current.projects.map {|p| p.id}
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
+ if(params[:type].blank? || params[:type] == "1") # 我的资源
+ # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
+ if params[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
+ end
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @attachments = get_course_resources_public( user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources_public(user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources_public(@order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources_public(@order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
+ end
+ end
+ @status = params[:status]
@type = params[:type]
@limit = 25
+ @path = user_resource_user_path(User.current, :type => @type)
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@@ -2024,11 +2086,41 @@ class UsersController < ApplicationController
else
@flag=true
end
+ @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
+ @score = @b_sort == "desc" ? "asc" : "desc"
+ user_project_ids = User.current.projects.map {|p| p.id}
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
+ if(params[:type].blank? || params[:type] == "1") # 我的资源
+ # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
+ if params[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
+ end
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @attachments = get_course_resources_public( user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources_public(user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources_public(@order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources_public(@order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
+ end
+ end
@type = params[:type]
@limit = 25
+ @path = user_resource_user_path(User.current, :type => @type)
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@@ -2371,7 +2463,7 @@ class UsersController < ApplicationController
# 获取我的资源
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
- attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
+ attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
@@ -2484,8 +2576,8 @@ class UsersController < ApplicationController
end
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@@ -2542,8 +2634,8 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
@@ -2581,8 +2673,8 @@ class UsersController < ApplicationController
# 别人的资源库是没有权限去看的
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
- user_course_ids = User.current.courses.map { |c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
# user_org_ids = User.current.organizations.map {|o| o.id}
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
elsif params[:type] == "6" # 公共资源
@@ -2662,8 +2754,8 @@ class UsersController < ApplicationController
@user = User.current
@switch_search = params[:search].nil? ? " " : params[:search]
search = "%#{@switch_search.strip.downcase}%"
- user_course_ids = User.current.courses.map {|c| c.id}
- user_project_ids = User.current.projects.map {|p| p.id}
+ user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
+ user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
if params[:status] == "2"
@attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
@@ -2721,6 +2813,7 @@ class UsersController < ApplicationController
name = "%"+name+"%"
@orgs = User.current.organizations.where("name like ?", name)
@user = User.current
+ @type = params[:type]
respond_to do |format|
format.html {render :layout => 'static_base'}
format.js
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1d443610f..366cea06b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -33,6 +33,10 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
+ def update_visiti_count container
+ container.update_column(:visits, container.visits + 1)
+ end
+
# Time 2015-03-24 15:27:29
# Author lizanle
# Description 从硬盘上删除对应的资源文件
@@ -2104,6 +2108,8 @@ module ApplicationHelper
attachment.container.board.course
course = attachment.container.board.course
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
+ elsif attachment.container.class.to_s=="Organization"
+ candown = true
elsif attachment.container.class.to_s=="HomeworkAttach"
candown = true
elsif attachment.container.class.to_s=="StudentWorksScore"
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 64531a6f4..3a6b347b3 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -850,7 +850,7 @@ module CoursesHelper
# 学生按作业总分排序,取前8个
def hero_homework_score(course, score_sort_by)
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score is null,null,IF(student_works.final_score = 0, 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
+ SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{course.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/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index df5c872f8..4e11e153e 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -130,7 +130,7 @@ module StudentWorkHelper
def revise_attachment_status homework, attach
date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d")
status = ""
- if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date))
+ if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time.to_s < date))
status = "此时其他同学作品已公开"
else
status = "此时其他同学作品尚未公开"
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/member.rb b/app/models/member.rb
index 9eac21fa7..cc227cf31 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -145,7 +145,7 @@ class Member < ActiveRecord::Base
#当前课程的作业列表
def homework_common_list
- HomeworkCommon.where(:course_id => self.course_id)
+ HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Date.today}'", self.course_id)
end
#当前学生在指定作业内的得分
@@ -158,7 +158,7 @@ class Member < ActiveRecord::Base
end
def student_work_score_sum
- sql_select = "SELECT (SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))) as score
+ sql_select = "SELECT (SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))) AS score
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{self.course_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/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb
new file mode 100644
index 000000000..ca15a6696
--- /dev/null
+++ b/app/views/admin/_course_detail_tr.html.erb
@@ -0,0 +1,32 @@
+
+ <%= course.id %>
+
+
+
+ <%= link_to(course.name, course_path(course.id)) %>
+
+
+
+ <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
+
+
+ <%= studentCount(course) %>
+
+
+ <%= course.homework_commons.count%>
+
+
+ <%= student_works_num(course) %>
+
+
+ <%= visable_attachemnts_incourse(course).count%>
+
+
+ <%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %>
+
+
+ <%= course.course_activities.count%>
+
+
+ <%= link_to( course.is_excellent == 1 || course.excellent_option == 1 ? "取消精品" : "设为精品", { :controller => 'admin', :action => 'set_excellent_course', :id => course.id },:remote=>true, :class => 'icon-del') %>
+
diff --git a/app/views/admin/_tab_excellent_courses.erb b/app/views/admin/_tab_excellent_courses.erb
new file mode 100644
index 000000000..844648c0b
--- /dev/null
+++ b/app/views/admin/_tab_excellent_courses.erb
@@ -0,0 +1,7 @@
+
+
+ <%= link_to '精品课程', {:action => 'excellent_courses'}, class: "#{current_page?(excellent_courses_path)? 'selected' : nil }" %>
+ <%= link_to '全部课程', {:action => 'excellent_all_courses'}, class: "#{current_page?(excellent_all_courses_path)? 'selected' : nil }" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb
index 2505b3d06..8e2f146a0 100644
--- a/app/views/admin/courses.html.erb
+++ b/app/views/admin/courses.html.erb
@@ -13,9 +13,7 @@
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
-
- <%= l(:button_clear)%>
-
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'},:remote => true, :class => 'icon icon-reload' %>
<% end %>
diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb
new file mode 100644
index 000000000..7554885a9
--- /dev/null
+++ b/app/views/admin/excellent_all_courses.html.erb
@@ -0,0 +1,71 @@
+<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
+
+ 精品课程列表
+
+<%= render 'tab_excellent_courses' %>
+
+
+ 全部课程列表
+
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ 课程:
+
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'excellent_all_courses'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
+
+
+<% html_title(l(:label_excellent_courses_list)) -%>
\ No newline at end of file
diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb
index 59426455a..fef6da84d 100644
--- a/app/views/admin/excellent_courses.html.erb
+++ b/app/views/admin/excellent_courses.html.erb
@@ -1,3 +1,9 @@
+<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
+
+ <%=l(:label_excellent_courses_list)%>
+
+<%= render 'tab_excellent_courses' %>
+
<%=l(:label_excellent_courses_list)%>
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 @@
提交作品数
- 提交截止日期
+ 作业发布日期
<%@count=@page*30 %>
<% for homework in @homework do %>
+ <% unless homework.nil? %>
<% @count+=1 %>
<%=@count %>
- <%=link_to(homework.name, student_work_index_path(:homework => homework.id))%>
+ <%=link_to(homework.try(:name), student_work_index_path(:homework => homework.id))%>
+ <% if homework.course %>
<%= link_to(homework.course.name, course_path(homework.course.id)) %>
+ <% end %>
<%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
<% if homework.try(:user).try(:realname) == ' '%>
<%= link_to(homework.try(:user), user_path(homework.user_id)) %>
@@ -51,9 +54,10 @@
<%=link_to(StudentWork.where('homework_common_id=?',homework.id).count, student_work_index_path(:homework => homework.id))%>
- <%=format_date(homework.end_time) %>
+ <%=format_date( homework.created_at ) %>
+ <% end %>
<% end %>
diff --git a/app/views/admin/organization.html.erb b/app/views/admin/organization.html.erb
index 02b897f80..6fde09ede 100644
--- a/app/views/admin/organization.html.erb
+++ b/app/views/admin/organization.html.erb
@@ -24,7 +24,8 @@
">
- <%= link_to org.name,home_path(:organization => org.id) %>
+ <%#= link_to org.name,home_path(:organization => org.id) %>
+ <%= link_to org.name, organization_path(org) %>
diff --git a/app/views/admin/set_excellent_course.js.erb b/app/views/admin/set_excellent_course.js.erb
new file mode 100644
index 000000000..7b3ade139
--- /dev/null
+++ b/app/views/admin/set_excellent_course.js.erb
@@ -0,0 +1 @@
+$("#tr_<%=@course.id %>").html("<%=escape_javascript(render :partial => 'course_detail_tr', :locals => {:course => @course}) %>");
\ No newline at end of file
diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb
index 612f408d7..1fa9339e4 100644
--- a/app/views/courses/_show_member_score.html.erb
+++ b/app/views/courses/_show_member_score.html.erb
@@ -24,11 +24,11 @@
<% final_score = @member_score.homework_common_score(homework_common).first%>
- <%= final_score.nil? || final_score.final_score.nil? ? "--" : format("%0.2f", final_score.final_score) %>
+ <%= final_score.nil? || final_score.final_score.nil? ? "--" : format("%0.2f", final_score.final_score < 0 ? 0 : final_score.final_score) %>
<% end %>
- 作业积分(总分) <%= (@member_score.student_work_score_sum).first.score %>
+ 作业积分(总分) <%= format("%0.2f",(@member_score.student_work_score_sum).first.score) %>
diff --git a/app/views/files/_org_upload_attachment_list.html.erb b/app/views/files/_org_upload_attachment_list.html.erb
new file mode 100644
index 000000000..06fa23387
--- /dev/null
+++ b/app/views/files/_org_upload_attachment_list.html.erb
@@ -0,0 +1,32 @@
+
+ <%= l(:label_browse_org) %>
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => "_file#{container.id}",
+ :class => ie8? ? '':'file_selector',
+ :multiple => true,
+ :onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');",
+ :style => ie8? ? '': 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js'),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all),
+ :lebel_file_uploding => l(:lebel_file_uploding),
+ :containerid => "#{container.id}"
+ } %>
+
+
+
+
+ 建议上传高度不超过52px的图片
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/files/_org_upload_attachment_list_banner.html.erb b/app/views/files/_org_upload_attachment_list_banner.html.erb
new file mode 100644
index 000000000..5388afb5b
--- /dev/null
+++ b/app/views/files/_org_upload_attachment_list_banner.html.erb
@@ -0,0 +1,32 @@
+
+ <%= l(:label_browse_org) %>
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => "_file#{container.id}",
+ :class => ie8? ? '':'file_selector',
+ :multiple => true,
+ :onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');",
+ :style => ie8? ? '': 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js'),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all),
+ :lebel_file_uploding => l(:lebel_file_uploding),
+ :containerid => "#{container.id}"
+ } %>
+
+
+
+
+ 建议上传 长度为1452px/高度为304px 的图片
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/files/_upload_org_new_files.html.erb b/app/views/files/_upload_org_new_files.html.erb
new file mode 100644
index 000000000..cd460e328
--- /dev/null
+++ b/app/views/files/_upload_org_new_files.html.erb
@@ -0,0 +1,25 @@
+
+
+
更换Logo
+
+ <%= error_messages_for 'attachment' %>
+
<%= l(:label_file_upload_error_messages)%>
+ <%= form_tag(organization_files_path(org, :in_org => params[:in_org], :logo => true), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
+
+ <%= render :partial => 'files/org_upload_attachment_list', :locals => {:container => org}%>
+
+
<%= l(:button_cancel)%>
+
<%= l(:button_confirm)%>
+ <% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/files/_upload_org_new_files_banner.html.erb b/app/views/files/_upload_org_new_files_banner.html.erb
new file mode 100644
index 000000000..0cb767bf2
--- /dev/null
+++ b/app/views/files/_upload_org_new_files_banner.html.erb
@@ -0,0 +1,25 @@
+
+
+
更换背景图片
+
+ <%= error_messages_for 'attachment' %>
+
<%= l(:label_file_upload_error_messages)%>
+ <%= form_tag(organization_files_path(org, :in_org => params[:in_org]), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
+
+ <%= render :partial => 'files/org_upload_attachment_list_banner', :locals => {:container => org}%>
+
+
<%= l(:button_cancel)%>
+
<%= l(:button_confirm)%>
+ <% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb
index 1d66c2955..38308be12 100644
--- a/app/views/files/create.js.erb
+++ b/app/views/files/create.js.erb
@@ -1,71 +1,75 @@
<% if @addTag%>
- <% if @obj_flag == '3'%>
- $('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
+<% if @obj_flag == '3'%>
+$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
- //$('#put-tag-form-issue').hide();
- $('#name-issue').val("");
- <% elsif @obj_flag == '6'%>
- $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
- $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
+//$('#put-tag-form-issue').hide();
+$('#name-issue').val("");
+<% elsif @obj_flag == '6'%>
+$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
+$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
- $("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide();
- $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
- <% else %>
- $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
+$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide();
+$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
+<% else %>
+$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
- $('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>');
- $('#put-tag-form #name').val("");
- //$('#put-tag-form').hide();
- <% end %>
+$('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>');
+$('#put-tag-form #name').val("");
+//$('#put-tag-form').hide();
+<% end %>
<% else %>
$("#attachments_fields").children().remove();
$("#upload_file_count").text("未上传文件");
$('#upload_file_div').slideToggle('slow');
- <% if @project %>
- hideModal();
- <% if @in_project_toolbar %>
- window.location.href = '<%= project_files_path(@project) %>'
- <% else %>
+<% if @project %>
+hideModal();
+<% if @in_project_toolbar %>
+window.location.href = '<%= project_files_path(@project) %>'
+<% else %>
- $("#resource_list").html('<%= j(render partial:"project_file", locals: {project: @project}) %>');
- $("#project_files_count_info").html("<%= @all_attachments.count %>");
- $("#project_files_count_nav").html("(<%= @all_attachments.count %>)")
- // 添加文件上传成功提示
- <% unless params[:attachments].nil? %>
- var div = $('文件上传成功!
');
- $("#course_list").prepend(div);
- setTimeout( function(){div.remove();},3000)
- <% end %>
- <% end %>
- <%elsif @course%>
- hideModal();
- <%if @in_course_toolbar %>
- window.location.href='<%= course_files_path(@course)%>'
- <%else%>
- $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>');
- $("#courses_files_count_info").html("<%= @all_attachments.count%>");
- $("#courses_files_count_nav").html("(<%= @all_attachments.count%>)")
- // 添加文件上传成功提示,
- <% unless params[:attachments].nil? %>
- var div = $('文件上传成功!
');
- $("#course_list").prepend(div);
- setTimeout( function(){div.remove();},3000)
- <% end %>
- <%end%>
- <% elsif @org_subfield %>
- <% if params[:in_org] %>
- window.location.href = '<%= org_subfield_files_path @org_subfield %>';
- <%else %>
- hideModal();
- $("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>');
- // 添加文件上传成功提示,
- <% unless params[:attachments].nil? %>
+$("#resource_list").html('<%= j(render partial:"project_file", locals: {project: @project}) %>');
+$("#project_files_count_info").html("<%= @all_attachments.count %>");
+$("#project_files_count_nav").html("(<%= @all_attachments.count %>)")
+// 添加文件上传成功提示
+<% unless params[:attachments].nil? %>
+var div = $('文件上传成功!
');
+$("#course_list").prepend(div);
+setTimeout( function(){div.remove();},3000)
+<% end %>
+<% end %>
+<%elsif @course%>
+hideModal();
+<%if @in_course_toolbar %>
+window.location.href='<%= course_files_path(@course)%>'
+<%else%>
+$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>');
+$("#courses_files_count_info").html("<%= @all_attachments.count%>");
+$("#courses_files_count_nav").html("(<%= @all_attachments.count%>)")
+// 添加文件上传成功提示,
+<% unless params[:attachments].nil? %>
+var div = $('文件上传成功!
');
+$("#course_list").prepend(div);
+setTimeout( function(){div.remove();},3000)
+<% end %>
+<%end%>
+<% elsif @org_subfield %>
+<% if params[:in_org] %>
+window.location.href = '<%= org_subfield_files_path @org_subfield %>';
+<%else %>
+hideModal();
+$("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>');
+// 添加文件上传成功提示,
+<% unless params[:attachments].nil? %>
// var div = $('文件上传成功!
');
// $("#org_subfield_list").prepend(div);
// setTimeout( function(){div.remove();},3000);
- <% end %>
- <% end %>
- <% end %>
+<% end %>
+<% end %>
+<% elsif @organization %> //组织单独处理
+hideModal();
+window.location.href = '<%= organization_path @organization %>';
+
+<% end %>
<% end %>
$(document).ready(img_thumbnails);
diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb
index ac4ac9853..e4b63a536 100644
--- a/app/views/homework_common/index.html.erb
+++ b/app/views/homework_common/index.html.erb
@@ -39,7 +39,21 @@