diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8e57fab4d..1c2419305 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,5 +1,5 @@ class CoursesController < ApplicationController - layout 'base_courses' + # layout 'base_courses' include CoursesHelper include ActivitiesHelper helper :activities @@ -73,6 +73,7 @@ class CoursesController < ApplicationController if @course.errors.full_messages.count <= 0 respond_to do |format| format.html { + # render :layout => 'base_courses' flash[:notice] = l(:notice_successful_update) redirect_to settings_course_url(@course) } @@ -82,7 +83,7 @@ class CoursesController < ApplicationController respond_to do |format| format.html { settings - render :action => 'settings' + redirect_to settings_course_url(@course) } format.api { render_validation_errors(@course) } end @@ -407,6 +408,10 @@ class CoursesController < ApplicationController @roles = Role.givable.all[3..5] @members = @course.member_principals.includes(:roles, :principal).all.sort + respond_to do |format| + format.html { render :layout => 'base_courses' } + format.api { render_validation_errors(@course) } + end else render_403 end @@ -424,6 +429,7 @@ class CoursesController < ApplicationController else respond_to do |format| format.html { + render :layout => 'base_courses' flash[:notice] = l(:notice_successful_create) if params[:continue] redirect_to new_course_url(attrs, :course => '0') @@ -738,7 +744,7 @@ class CoursesController < ApplicationController @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end - sorted_events = sort_activity_events_course(events); + sorted_events = sort_activity_events_course(events) events = paginateHelper sorted_events,10 @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} # documents diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a230688dc..2a10af260 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -438,13 +438,84 @@ class UsersController < ApplicationController # Description 所有动态 where_condition = nil; # where_condition = "act_type <> 'JournalsForMessage'" + user_ids = [] if @user == User.current watcher = User.watched_by(@user) watcher.push(User.current) - activity = Activity.where(where_condition).where('user_id in (?)', watcher).order('id desc') + user_ids = watcher.map{|x| x.id} else - activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') + user_ids << @user.id end + activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') + + permission = !User.current.admin? + if permission + #Issue + act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} + project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids = [] + ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + #Bid + act_ids = activity.where(act_type: 'Bid').select('act_id').map{|x| x.act_id} + course_ids = HomeworkForCourse.where(bid_id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: course_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << HomeworkForCourse.where(bid_id: act_ids, course_id: c_ids).map{|x| x.id} + + #Journal + act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} + project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} + + #News + act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} + project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} + + #Message + act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} + board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} + project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} + + project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} + + logger.debug "filter ids #{ids}" + + activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? + end + # activity = activity.reject { |e| # e.act.nil? || # (!User.current.admin? && !e.act.nil? @@ -454,14 +525,11 @@ class UsersController < ApplicationController # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) # } + # + @activity_count = activity.count @activity_pages = Paginator.new @activity_count, pre_count, params['page'] @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) - # @activity = @activity.reject { |e| - # ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || - # ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || - # ((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?))) - # } @state = 0 end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f4a5ac193..55f216ab9 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -20,7 +20,7 @@ module CoursesHelper # 返回教师数量,即roles表中定义的Manager def teacherCount project - project.members.count - studentCount(project).to_i + project ? project.members.count - studentCount(project).to_i : 0 # or # searchTeacherAndAssistant(project).count end @@ -152,7 +152,7 @@ module CoursesHelper # 学生人数计算 # add by nwb def studentCount course - course.student.count.to_s#course.student.count + course ? course.student.count.to_s : 0#course.student.count end #课程成员数计算 @@ -782,6 +782,7 @@ module CoursesHelper end def visable_attachemnts_incourse course + return[] unless course result = [] course.attachments.each do |attachment| if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin? diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 58935dd11..af2d5abc4 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -278,4 +278,29 @@ module UsersHelper end } end + + #获取用户留言相关的连接 + def user_jour_feed_back_url active + if active.act_type == "JournalsForMessage" + jour = JournalsForMessage.find active.act_id + if jour + case jour.jour_type + when "Principal" + link_to(l(:label_goto), user_newfeedback_user_path(jour.jour_id)) + when "Project" + link_to(l(:label_goto), project_feedback_path(jour.jour_id)) + when "Bid" + link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) + when "Course" + link_to(l(:label_goto), course_feedback_path(jour.jour_id)) + when "Contest" + link_to(l(:label_goto), show_contest_contest_path(jour.jour_id)) + when "Softapplication" + link_to(l(:label_goto), softapplication_path(jour.jour_id)) + when "HomeworkAttach" + link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) + end + end + end + end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index df23813cd..39c38b269 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -775,9 +775,9 @@ class Mailer < ActionMailer::Base end end elsif reps.is_a? String - u = User.find_by_mail(r) + u = User.find_by_mail(reps) if u && u.mail_notification == 'all' - r_reps << r + r_reps << reps end end r_reps diff --git a/app/models/user.rb b/app/models/user.rb index 35c29cbcc..59c0ab608 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -766,7 +766,7 @@ class User < Principal # * nil with options[:global] set : check if user has at least one role allowed for this action, # or falls back to Non Member / Anonymous permissions depending if the user is logged def allowed_to?(action, context, options={}, &block) - if context && context.is_a?(Project) + if Project === context return false unless context.allows_to?(action) # Admin users are authorized for anything else return true if admin? @@ -779,7 +779,7 @@ class User < Principal (block_given? ? yield(role, self) : true) } #添加课程相关的权限判断 - elsif context && context.is_a?(Course) + elsif Course === context return false unless context.allows_to?(action) # Admin users are authorized for anything else return true if admin? diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 8f86029d9..63dd725cd 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -199,13 +199,15 @@ class UsersService #搜索用户 def search_user params - @status = params[:status] || 1 + status = params[:status] || 1 has = { "show_changesets" => true } - scope = User.logged.status(@status) - @search_by = params[:search_by] ? params[:search_by] : "0" - scope = scope.like(params[:name],@search_by) if params[:name].present? + scope = User.logged.status(status) + watcher = User.watched_by(params[:user_id]) + watcher.push(params[:user_id]) + search_by = params[:search_by] ? params[:search_by] : "0" + scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present? scope end diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index a302d0981..7b388adc4 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -15,7 +15,7 @@ <%= format_time(journal.created_on) %>
-+
<%= journal.notes.html_safe %>
diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index cbb5d6fc1..f7cf2a360 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -31,7 +31,7 @@ $(function(){if($("#bid_description_<%= bid.id%>_content").height()>38){$("#bid_show_more_des_button<%= bid.id%>").show();}});<%= e.event_description.html_safe %>
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index b6f65e9b2..62fdc3082 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -9,7 +9,7 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course}) %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
- $('#ajax-modal').before("")
+ $('#ajax-modal').before("
");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb
index 3d692a36b..3946b1da1 100644
--- a/app/views/files/_course_list.html.erb
+++ b/app/views/files/_course_list.html.erb
@@ -46,8 +46,8 @@
<%= textAreailizable forum.description%>
diff --git a/app/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb index d1d055bb8..19892e841 100644 --- a/app/views/layouts/_base_feedback.html.erb +++ b/app/views/layouts/_base_feedback.html.erb @@ -173,7 +173,6 @@ function cookieget(n) <% end %> diff --git a/app/views/layouts/_new_feedback.html.erb b/app/views/layouts/_new_feedback.html.erb index 4f7e650eb..32afb4e5c 100644 --- a/app/views/layouts/_new_feedback.html.erb +++ b/app/views/layouts/_new_feedback.html.erb @@ -21,10 +21,6 @@ <% end %><%= textAreailizable act.notes %>
<%=textAreailizable act, :description %>
<%= desStr %>
@@ -282,7 +283,7 @@ <% end %><%= textAreailizable act,:long_comments %>
@@ -344,7 +345,7 @@ <% end %><%= textAreailizable(act,:content) %>
@@ -385,7 +386,7 @@ <% end %><%= textAreailizable act,:description %>
@@ -559,7 +560,7 @@ <% end %><%= textAreailizable act, :description %>
@@ -633,7 +634,7 @@<%= textAreailizable e.notes %>
diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb new file mode 100644 index 000000000..1a4cf8463 --- /dev/null +++ b/config/initializers/delayed_job_config.rb @@ -0,0 +1,9 @@ +Delayed::Worker.destroy_failed_jobs = false +Delayed::Worker.sleep_delay = 10 +Delayed::Worker.max_attempts = 1 +Delayed::Worker.max_run_time = 5.minutes +Delayed::Worker.read_ahead = 10 +Delayed::Worker.default_queue_name = 'default' +Delayed::Worker.delay_jobs = !Rails.env.test? +Delayed::Worker.raise_signal_exceptions = :term +Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log')) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index fc2f55086..658f30480 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -8,6 +8,9 @@ h3, .wiki h2 {font-size: 15px; padding-left: 5px} h4, .wiki h3 {font-size: 13px;} h4 {border-bottom: 1px dotted #bbb;} +/*上传图片处理*/ +.upload_img img{max-width: 100%;} + /****翻页***/ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } ul.wlist li{float: left;} diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index cfb27e20b..a3e358b14 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -435,6 +435,9 @@ a.link_file_board{ background:url(../images/pic_file.png) 0 3px no-repeat !impor #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;} #cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;} +/*上传图片处理*/ +.upload_img img{max-width: 100%;} + /* The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9. diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index ac7142c71..de4dcb65c 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -750,9 +750,9 @@ div.actions input[type="text"] { .memo-content img, .comments img { overflow: hidden; /*width: 100%;*/ - max-width: 500px; + max-width: 100%; height: auto !important; - width: expression(this.width > 500 ? "500px" : this.width+"px"); + /*width: expression(this.width > 500 ? "500px" : this.width+"px");*/ } table.content-text-list tbody tr td.sticky, div.memo-section .sticky { diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 17b193a44..cd4dc337a 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -156,8 +156,8 @@ div#menu ul ul a:hover { color:#ff9900;} div#menu ul ul li.last { margin-left:15px; } div#menu ul ul li {width: 100%;} /* menu::level3 */ -div#menu ul ul ul {padding: 0;margin: -38px 0 0 92px !important; width:140px; } -div#menu ul ul ul li a{ width:125px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf;} +div#menu ul ul ul {padding: 0;margin: -38px 0 0 92px !important; width:200px; } +div#menu ul ul ul li a{ width:185px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf;} /*主类容*/ @@ -199,7 +199,7 @@ html{ overflow-x:hidden;} .close_btn span { display:none;} .side_center .custom_service p { text-align:center; padding:6px 0; margin:0; vertical-align:middle;} .msgserver { margin-top:5px;} -.msgserver a { background:url(../images/sidebar_bg.png) no-repeat -119px -112px; padding-left:22px; height:21px; display:block; } +.msgserver a { background:url(../images/sidebar_bg.png) no-repeat -119px -112px; padding-left:22px; height:21px; display:block; color:#15bccf;} .opnionText{box-shadow:none; width:122px; height:180px; border-color: #DFDFDF; background:#fff; color:#999; padding:3px; font-size:12px;overflow:auto; background-attachment:fixed;border-style:solid;} a.opnionButton{ display:block; background:#15bccf; width:130px; height:23px; margin-top:5px; text-align:center; padding-top:3px;} a:hover.opnionButton{background: #0fa9bb; } @@ -210,8 +210,7 @@ a:hover.opnionButton{background: #0fa9bb; } a.close_btn {background-position:-44px 0;} a:hover.close_btn {background-position:-66px 0;} .show_btn {background-position:-119px 0;} -.msgserver a {color:#15bccf; } -.msgserver a:hover { text-decoration:underline; } +.msgserver a:hover { color: #0fa9bb; } .break_word{word-break: break-all;word-wrap: break-word;} /***** Ajax indicator ******/ #ajax-indicator {