diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d458b73e4..d880ebe35 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -27,7 +27,7 @@ class AttachmentsController < ApplicationController accept_api_auth :show, :download, :upload require 'iconv' include AttachmentsHelper - + include ApplicationHelper def show respond_to do |format| @@ -65,36 +65,7 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = false - if @attachment.container.class.to_s != "HomeworkAttach" && (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project - project = @attachment.container.project - candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif @attachment.container.is_a?(Project) - project = @attachment.container - candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && - @attachment.container.board.project - project = @attachment.container.board.project - candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course - course = @attachment.container.course - candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) - elsif @attachment.container.is_a?(Course) - course = @attachment.container - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && - @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=="HomeworkAttach" && @attachment.container.bid.reward_type == 3 - candown = true - elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses.first - course = @attachment.container.courses.first - candown = User.current.member_of_course?(course) || (course.is_public == 1 && @attachment.is_public == 1) - else - - candown = @attachment.is_public == 1 - end + candown = attachment_candown @attachment if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) @@ -349,6 +320,46 @@ class AttachmentsController < ApplicationController end end + def add_exist_file_to_projects + file = Attachment.find(params[:file_id]) + projects = params[:projects][:project] + @message = "" + projects.each do |project| + c = Project.find(project); + if project_contains_attachment?(c,file) + if @message && @message == "" + @message += l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + else + @message += "
" + l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + end + end + attach_copied_obj = file.copy + attach_copied_obj.tag_list.add(file.tag_list) # tag关联 + attach_copied_obj.container = c + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + @obj = c + @save_flag = attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages + update_quotes attach_copied_obj + end + respond_to do |format| + format.js + end + rescue NoMethodError + @save_flag = false + @save_message = [] << l(:label_course_empty_select) + respond_to do |format| + format.js + end + end + def add_exist_file_to_courses file = Attachment.find(params[:file_id]) courses = params[:courses][:course] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ebdb18c08..581005bf7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -30,19 +30,19 @@ class CoursesController < ApplicationController def join if User.current.logged? cs = CoursesService.new - join = cs.join_course params,User.current + user = User.current + join = cs.join_course params,user @state = join[:state] course = join[:course] else @state = 5 #未登录 end respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => course, :object_id => params[:object_id]} } + format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } end rescue Exception => e @state = 4 #已经加入了课程 respond_to do |format| - # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} } end end @@ -323,6 +323,7 @@ class CoursesController < ApplicationController end respond_to do |format| if params[:page] + format.html {render :layout => 'base_courses'} format.js else format.html {render :layout => 'base_courses'} @@ -402,6 +403,9 @@ class CoursesController < ApplicationController @issue_category ||= IssueCategory.new @member ||= @course.members.new @trackers = Tracker.sorted.all + + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort else render_403 end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 0575294d5..1ca3e2fcf 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -23,13 +23,14 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project] helper :sort include SortHelper include FilesHelper helper :project_score include CoursesHelper + include ApplicationHelper def show_attachments obj @attachments = [] @@ -41,8 +42,8 @@ class FilesController < ApplicationController @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset - @curse_attachments_all = @all_attachments[@offset, @limit] - @curse_attachments = paginateHelper @all_attachments,10 + #@curse_attachments_all = @all_attachments[@offset, @limit] + @obj_attachments = paginateHelper @all_attachments,10 end def search @@ -78,6 +79,39 @@ class FilesController < ApplicationController end end + def search_project + sort = "" + @sort = "" + @order = "" + @is_remote = true + if params[:sort] + order_by = params[:sort].split(":") + @sort = order_by[0] + if order_by.count > 1 + @order = order_by[1] + end + sort = "#{@sort} #{@order}" + end + + begin + q = "%#{params[:name].strip}%" + #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? + if params[:insite] + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + else + @result = find_project_attache q,@project,sort + @result = visable_attachemnts @result + @searched_attach = paginateHelper @result,10 + end + + #rescue Exception => e + # #render 'stores' + # redirect_to search_course_files_url + end + end + def find_course_attache keywords,course,sort = "" if sort == "" sort = "created_on DESC" @@ -87,6 +121,26 @@ class FilesController < ApplicationController #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") end + def find_project_attache keywords,project,sort = "" + if sort == "" + sort = "created_on DESC" + end + ids = "" + len = 0 + count = project.versions.count + project.versions.each do |version| + len = len + 1 + if len != count + ids += version.id.to_s + ',' + else + ids += version.id.to_s + end + end + resultSet = Attachment.where("((attachments.container_type = 'Project' And attachments.container_id = '#{project.id}') OR (container_type = 'Version' AND container_id IN (#{ids}))) AND filename LIKE :like ", like: "%#{keywords}%"). + reorder(sort) + #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") + end + def find_public_attache keywords,sort = "" # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 @@ -132,17 +186,27 @@ class FilesController < ApplicationController attribute = "downloads" when "created_on" attribute = "created_on" + when "quotes" + attribute = "quotes" + else + attribute = "created_on" end - - if order_by.count == 1 - sort += "#{Attachment.table_name}.#{attribute} asc " if attribute - elsif order_by.count == 2 - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] - end - if sort_type != params[:sort].split(",").last - sort += "," + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Project.includes(:attachments).find(@project.id)] @@ -184,6 +248,8 @@ class FilesController < ApplicationController attribute = "created_on" when "quotes" attribute = "quotes" + else + attribute = "created_on" end @sort = order_by[0] @order = order_by[1] @@ -199,6 +265,8 @@ class FilesController < ApplicationController end end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @@ -215,6 +283,11 @@ class FilesController < ApplicationController @can_quote = attachment_candown @file end + def quote_resource_show_project + @file = Attachment.find(params[:id]) + @can_quote = attachment_candown @file + end + def new @versions = @project.versions.sort @course_tag = @project.project_type diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index aaaa4484d..fc243741a 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -133,6 +133,9 @@ class MembersController < ApplicationController elsif @course course_info = [] if params[:membership] + @create_member_error_messages = "角色不能留空" unless params[:membership][:role_ids] + @create_member_error_messages = "用户不能留空" unless params[:membership][:user_ids] + if params[:membership][:user_ids] attrs = params[:membership].dup user_ids = attrs.delete(:user_ids) @@ -140,7 +143,7 @@ class MembersController < ApplicationController member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) role = Role.find_by_id(params[:membership][:role_ids]) # 这里的判断只能通过角色名,可以弄成常量 - if role.name == "学生" || role.name == "Student" + if role && (role.name == "学生" || role.name == "Student") StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id) end members << member @@ -159,6 +162,11 @@ class MembersController < ApplicationController end @course.members << members @course.course_infos << course_info + + @roles = Role.givable.all[3..5] + members = @course.member_principals.includes(:roles, :principal).all.sort + else + @create_member_error_messages = l(:label_user_role_null) end respond_to do |format| format.html { redirect_to_settings_in_courses } @@ -242,6 +250,9 @@ class MembersController < ApplicationController end end end + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort + @member = @course.members.new end saved = @member.save @@ -304,7 +315,8 @@ class MembersController < ApplicationController joined.each do |join| join.delete end - + @roles = Role.givable.all[3..5] + @members = @course.member_principals.includes(:roles, :principal).all.sort end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c8168455c..fd567c1fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1676,6 +1676,42 @@ module ApplicationHelper courses_doing end + + def attachment_candown attachment + candown = false + if attachment.container + if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project + project = attachment.container.project + candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif attachment.container.is_a?(Project) + project = attachment.container + candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && + attachment.container.board.project + project = attachment.container.board.project + candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course + course = attachment.container.course + candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif attachment.container.is_a?(Course) + course = attachment.container + candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && + 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=="HomeworkAttach" && attachment.container.bid.reward_type == 3 + candown = true + elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses + course = attachment.container.courses.first + candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) + else + candown = (attachment.is_public == 1 || attachment.is_public == true) + end + end + candown + end + private def wiki_helper diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 2e07421f8..8843b1a76 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -77,6 +77,7 @@ module AttachmentsHelper end end + #判断课程course中是否包含课件attachment,course中引用了attachment也算作包含 def course_contains_attachment? course,attachment course.attachments.each do |att| if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from @@ -85,6 +86,15 @@ module AttachmentsHelper end false end + #判断项目project中是否包含课件attachment,project中引用了attachment也算作包含 + def project_contains_attachment? project,attachment + project.attachments.each do |att| + if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from + return true + end + end + false + end def get_qute_number attachment if attachment.copy_from diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 384fcaa9b..f4ba5040e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -677,7 +677,7 @@ module CoursesHelper #加入课程、退出课程按钮 def join_in_course_header(course, user, options=[]) if user.logged? - joined = user.member_of_course? course + joined = course.members.map{|member| member.user_id}.include? user.id text = joined ? ("".html_safe + l(:label_course_exit_student)) : ("".html_safe + l(:label_course_join_student)) url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) method = joined ? 'delete' : 'post' @@ -736,4 +736,14 @@ module CoursesHelper "未启用匿评".html_safe end end + + def visable_attachemnts_incourse course + result = [] + course.attachments.each do |attachment| + if attachment.is_public? || User.current.member_of_course?(course) + result << attachment + end + end + result + end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 884ebc2eb..3c8ed63d4 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -45,6 +45,7 @@ module FilesHelper File.new(zipfile_name,'w+') end + #带勾选框的课程列表 def courses_check_box_tags(name,courses,current_course,attachment) s = '' courses.each do |course| @@ -55,6 +56,17 @@ module FilesHelper s.html_safe end + #带勾选框的项目列表 + def projects_check_box_tags(name,projects,current_project,attachment) + s = '' + projects.each do |project| + if !project_contains_attachment?(project,attachment) && User.current.allowed_to?(:manage_files, project) + s << "" + end + end + s.html_safe + end + #判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 def has_course? user,file result = false @@ -66,6 +78,17 @@ module FilesHelper result end + #判断用户是否拥有不包含当前资源的项目,需用户在该项目中有资源管理相关资源 + def has_project? user,file + result = false + user.projects.each do |project| + if !project_contains_attachment?(project,file) && User.current.allowed_to?(:manage_files, project) + return true + end + end + result + end + # 判断指定的资源时候符合类型 def isTypeOk(attachment, type, contentType) result = false @@ -97,59 +120,23 @@ module FilesHelper result end - def visable_attachemnts_incourse attachments + def visable_attachemnts_insite attachments,obj result = [] - attachments.each do |attachment| - if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id - result << attachment - end - end - result - end - - def visable_attachemnts_insite attachments,course - result = [] - attachments.each do |attachment| - if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id - result << attachment + if obj.is_a?(Course) + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == obj.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end end + else if obj.is_a?(Project) + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "Project" && attachment.container_id == obj.id && User.current.member_of_course?(Project.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end + end end - result end - - def attachment_candown attachment - candown = false - if attachment.container - if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project - project = attachment.container.project - candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif attachment.container.is_a?(Project) - project = attachment.container - candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && - attachment.container.board.project - project = attachment.container.board.project - candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course - course = attachment.container.course - candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif attachment.container.is_a?(Course) - course = attachment.container - candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && - 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=="HomeworkAttach" && attachment.container.bid.reward_type == 3 - candown = true - elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses - course = attachment.container.courses.first - candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) - else - candown = (attachment.is_public == 1 || attachment.is_public == true) - end - end - candown + result end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index ed18b7ae4..29ba94924 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -45,17 +45,14 @@ module MembersHelper # 课程可添加的成员列表 def render_principals_for_new_course_members(course) scope = Principal.active.sorted.not_member_of_course(course).like(params[:q]) - principal_count = scope.count - principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] - principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all - - s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals') + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') - links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true) {|text, parameters, options| link_to text, autocomplete_course_memberships_path(course, parameters.merge(:q => params[:q], :format => 'js')), :remote => true } - s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') + s + content_tag('ul', links,:class => 'wlist',:id => "course_member_pagination_links") end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 8974a52d3..7995d7e68 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -155,7 +155,7 @@ module WatchersHelper else text = l(:label_new_join_group) form_tag({:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, :remote => true, :method => 'post') do - submit_tag text, class: "group_in", style: "width: 43px;height: 21px;" + submit_tag text, class: "group_in", style: "width: 90px;height: 21px;" end end end diff --git a/app/views/attachments/add_exist_file_to_projects.js.erb b/app/views/attachments/add_exist_file_to_projects.js.erb new file mode 100644 index 000000000..88f45e2cf --- /dev/null +++ b/app/views/attachments/add_exist_file_to_projects.js.erb @@ -0,0 +1,7 @@ +<% if !@save_flag && @save_message %> +$("#error_show").html("<%= @save_message.join(', ') %>"); +<% elsif @message && @message != "" %> +$("#error_show").html("<%= @message.html_safe %>"); +<% else %> +closeModal(); +<% end %> \ No newline at end of file diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 210d96891..9f3bf30c7 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -33,8 +33,9 @@

  • - + <%= render :partial => 'attachments/new_form', :locals => {:container => bid} %> +
  • <%= l(:button_create)%> diff --git a/app/views/courses/_course_members.html.erb b/app/views/courses/_course_members.html.erb new file mode 100644 index 000000000..38ef7e9db --- /dev/null +++ b/app/views/courses/_course_members.html.erb @@ -0,0 +1,49 @@ +
    + +
    +
    +

    添加成员

    + <%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %> + + <% end%> +
    \ No newline at end of file diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb new file mode 100644 index 000000000..53e7c15a5 --- /dev/null +++ b/app/views/courses/_member.html.erb @@ -0,0 +1,37 @@ +<% @members.each do |member| %> +
  • + <%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %> + + <%= h member.roles.sort.collect(&:to_s).join(', ') %> + <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), + :method => :put, + :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}} + ) do |f| %> + <% @roles.each do |role| %> + + + <% end %> + <%= hidden_field_tag 'membership[role_ids][]', '' %> + + <% end %> + + <% unless member.roles.first.to_s == "Manager"%> + 编辑 + <%= delete_link membership_path(member), + :remote => true, + :class => "c_dblue w40 fl", + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %> + <% end%> +
  • +<% end%> \ No newline at end of file diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index f65d6e98b..0ccefdba1 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -1,9 +1,10 @@ <% if object_id%> - $("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_course(course, user) %>'); + $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(course, user)) %>"); <% end %> <% if @state %> <% if @state == 0 %> alert("加入成功"); + hideModal("#popbox02"); <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 3d1a3f6a4..3057285a7 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -47,7 +47,7 @@
  • 提交 - 取消 + 取消
  • <% end%> diff --git a/app/views/courses/new_join.js.erb b/app/views/courses/new_join.js.erb index c0a6f4a50..00245f8cb 100644 --- a/app/views/courses/new_join.js.erb +++ b/app/views/courses/new_join.js.erb @@ -1,3 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', :locals => {:course => @course}) %>'); -showModal('ajax-modal', '400px'); -$('#ajax-modal').addClass('new-watcher'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', locals: { :course => @course}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').css('height','100px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + +""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 43261f4e2..569ae302b 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -2,59 +2,75 @@

    <%= l(:label_course_modify_settings)%>

    - +
    +
    + +
    + +
    + <%= render :partial => "course_members" %> +
    \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index ea499477a..b6f65e9b2 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -55,7 +55,7 @@
    - <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> + <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
    diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb new file mode 100644 index 000000000..c7e0cec29 --- /dev/null +++ b/app/views/files/_project_file_list.html.erb @@ -0,0 +1,58 @@ + +
    +

    共有 <%= all_attachments.count%> 个资源

    +

    + <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

    +
    +
    +
    + <% project_attachments.each do |file| %> +
    +
    + <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if User.current.logged? %> + <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> + <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + + <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + <% end %> + <% else %> + <% end %> +
    +
    +
    +

    文件大小:<%= number_to_human_size(file.filesize) %>

    + <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%> +

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    +
    +
    +
    + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %> +
    +
    +
    + <% end %> +
    + +
    \ No newline at end of file diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb new file mode 100644 index 000000000..89088a295 --- /dev/null +++ b/app/views/files/_project_file_new.html.erb @@ -0,0 +1,65 @@ + +
    +

    <%= l(:lable_file_sharingarea) %>

    +
    + + + + +
    +
    +
    + <%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <% end %> + <% manage_allowed = User.current.allowed_to?(:manage_files, @project) %> + <% if manage_allowed %> + 上传资源 + <% end %> +
    +
    + +
    + <%= render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @all_attachments,sort:@sort,order:@order,project_attachments:@obj_attachments,:manage_allowed => manage_allowed} %> +
    + +
    +
    +<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 6935c186f..729f0a483 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -24,8 +24,8 @@ - <% if @curse_attachments != nil %> - <% @curse_attachments.each do |file| %> + <% if @obj_attachments != nil %> + <% @obj_attachments.each do |file| %> <%if file.is_public == 0 && !User.current.member_of?(@project)%> <%next%> <%end%> diff --git a/app/views/files/_show_quote_resource_project.html.erb b/app/views/files/_show_quote_resource_project.html.erb new file mode 100644 index 000000000..7df1dc2f3 --- /dev/null +++ b/app/views/files/_show_quote_resource_project.html.erb @@ -0,0 +1,31 @@ +
    +
    +

    将此课件引入我的资源库

    + <% if error == '403' %> +
    +
    您没有权限引用此资源
    +
    + <% else %> +
    +
    + <%= form_tag attach_relations_path, + method: :post, + remote: true, + id: "relation_file_form" do %> + <%= hidden_field_tag(:file_id, file.id) %> + <%= content_tag('div', projects_check_box_tags('projects[project][]', User.current.projects,project,file), :id => 'projects')%> + 引  用取  消 + <% end -%> +
    + <% end %> + + +
    +
    + + \ No newline at end of file diff --git a/app/views/files/_upload_show_project.html.erb b/app/views/files/_upload_show_project.html.erb new file mode 100644 index 000000000..25a03b347 --- /dev/null +++ b/app/views/files/_upload_show_project.html.erb @@ -0,0 +1,29 @@ + +
    +
    +

    <%= l(:label_upload_files)%>

    +
    + <%= error_messages_for 'attachment' %> + + + <%= form_tag(project_files_path(project), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + <%= render :partial => 'attachement_list',:locals => {:project => project} %> +
    + <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <% end %> +
    + +
    + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 69ea896c9..b00ae3612 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -1,35 +1,33 @@ -<%if @addTag%> -<% if @obj_flag == '3'%> - -$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', +<% if @addTag%> + <% 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 %> -<%else%> + $('#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%> -$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); -<%elsif @course%> -$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); -closeModal(); -$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); -<%end%> + <% if @project%> + closeModal(); + $("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>'); + <%elsif @course%> + closeModal(); + $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); + <% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/files/quote_resource_show_project.js.erb b/app/views/files/quote_resource_show_project.js.erb new file mode 100644 index 000000000..440004357 --- /dev/null +++ b/app/views/files/quote_resource_show_project.js.erb @@ -0,0 +1,11 @@ +<% if @can_quote %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => ''}) %>'); +<% else %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => '403'}) %>'); +<% end %> + +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/files/search_project.js.erb b/app/views/files/search_project.js.erb new file mode 100644 index 000000000..f64b8beeb --- /dev/null +++ b/app/views/files/search_project.js.erb @@ -0,0 +1 @@ +$("#course_list").html("<%= escape_javascript(render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @result,sort:@sort,order:@order,project_attachments:@searched_attach,:manage_allowed => User.current.allowed_to?(:manage_files, @project)})%>"); \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 471902c7a..25b08ce7d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,6 +1,7 @@ <% course_model %> <% teacher_num = teacherCount(@course) %> <% student_num = studentCount(@course) %> +<% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> @@ -62,11 +63,7 @@
    ID:<%= @course.id%> @@ -77,7 +74,7 @@ <%= set_course_time @course%> <%= link_to "#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %> <% else%> - <%= join_in_course_header(@course, User.current) %> +
    <%= join_in_course_header(@course, User.current) %>
    <% end%>
    @@ -98,7 +95,7 @@ <%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) - <%= l(:project_module_attachments)%>(<%= link_to @course.attachments.count, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
    + <%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
    @@ -129,7 +126,9 @@ <%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>