diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index b6d1db25c..063cfafae 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -14,7 +14,7 @@ module Mobile us = UsersService.new user = us.register params.merge(:password_confirmation => params[:password], :should_confirmation_password => true) - raise "register failed #{user.errors.full_messages}" if user.new_record? + raise "该邮箱已经被注册过了" if user.new_record? present :data, user, with: Mobile::Entities::User present :status, 0 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/courses_service.rb b/app/services/courses_service.rb index de72cab7c..a96bc0fbe 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -434,7 +434,7 @@ class CoursesService many_times = course.homeworks.index(bid) + 1 name = bid.name homework_count = bid.homeworks.count #已提交的作业数量 - student_questions_count = bid.commit.nil? ? 0 : bid.commit + student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = bid.comment_status @@ -454,7 +454,7 @@ class CoursesService many_times = course.homeworks.index(bid) + 1 name = bid.name homework_count = bid.homeworks.count #已提交的作业数量 - student_questions_count = bid.commit.nil? ? 0 : bid.commit + student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = bid.comment_status 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/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index 3f4f6aff7..ab5cdd484 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,11 +1,11 @@ <% if @status == 0%> - alert("您申请的项目不存在"); + alert("<%= l('project.join.tips.notexist') %>"); <% elsif @status == 1%> - alert("请勿重复申请加入该项目"); + alert("<%= l('project.join.tips.repeat') %>"); <% elsif @status == 2%> - alert("申请成功"); + alert("<%= l('project.join.tips.success') %>"); <% elsif @status == 3%> - alert("您已加入该项目"); + alert("<%= l('project.join.tips.has') %>"); <%else%> - alert("申请失败"); + alert("<%= l('project.join.tips.fail') %>"); <%end%> \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index e69fa2730..765cb2a65 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -10,7 +10,7 @@
<% if User.current.logged? %>
-

<%= l(:label_message_new) %>

+

<%= l(:project_module_boards_post) %>

<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'messages/form', :locals => {:f => f} %> @@ -39,12 +39,18 @@
-

<%= h @board.name %>

+

+ <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> +

-
项目讨论区共有<%= @topic_count %>个帖子
+
<%= l(:label_project_board_count , :count => @topic_count)%>
<% if @project.enabled_modules.where("name = 'boards'").count > 0 && User.current.member_of?(@project) %> - <%= link_to l(:label_message_new), new_board_message_path(@board), + <%= link_to l(:project_module_boards_post), new_board_message_path(@board), :class => 'problem_new_btn fl', :onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> <% end %> @@ -61,15 +67,15 @@
<%= link_to h(topic.subject), board_message_path(@board, topic), title:topic.subject.to_s, :class =>"problem_tit fl" %> <% if topic.sticky? %> - 置顶 + <%= l(:label_board_sticky)%> <% end %>
- 由<%= link_to topic.author, user_path(topic.author), :class =>"problem_name" %> - 添加于<%= format_time topic.created_on %> + <%= l(:label_post_by)%><%= link_to topic.author, user_path(topic.author), :class =>"problem_name" %> +  <%= l(:label_post_by_time)%><%= format_time topic.created_on %>
- <%= link_to (l(:label_reply) + topic.replies_count.to_s), board_message_path(@board, topic), :style =>"color:#fff;" %> + <%= link_to (l(:label_short_reply) + " "+topic.replies_count.to_s), board_message_path(@board, topic), :style =>"color:#fff;line-height: 18px;" %>
<% 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();}});
-
+
<%= bid.description.html_safe %>
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 79cb267b4..1cc117dd6 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -9,12 +9,13 @@ <%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %> -
+
<%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %> <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %>   <%= l(:label_new_activity) %>: - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : + (e.event_type.eql?("bid") ? homework_course_path(@course) : e.event_url),:class => "problem_tit c_dblue fl fb"%>

<%= 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 @@

- <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %> - <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %> + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index fe2f757c3..59ed1092e 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -16,7 +16,7 @@ - +

<%= textAreailizable forum.description%>

diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index 91b59d4f2..19c0d9344 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -28,7 +28,7 @@ } else { - $("#homework_attach_name_span").text("填写正确"); + $("#homework_attach_name_span").text("<%= l(:label_field_correct)%>"); $("#homework_attach_name_span").css('color','#008000'); return true; } diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 012178ae2..682ff4c99 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -12,7 +12,7 @@ :onclick => '$("#custom_query").slideToggle(400); ' if true || User.current.logged? %> <% end %> - <%= l(:label_issues_sum) %>:<%= @project.issues.count %> <%= l(:lable_issues_undo) %> <%= @project.issues.where('status_id in (1,2,4,6)').count %> + <%= l(:label_issues_sum) %>:<%= @project.issues.count %> <%= l(:lable_issues_undo) %>:<%= @project.issues.where('status_id in (1,2,4,6)').count %>
<% if !@query.new_record? && @query.editable_by?(User.current) %> 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 %>
- <%= l(:label_technical_support) %>黄井泉 <%= l(:label_technical_support) %>白   羽
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 %>
- - <%= l(:label_technical_support) %> - 黄井泉 - <%= l(:label_technical_support) %> 白   羽 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 9fed77faf..dbcf933ff 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -43,7 +43,7 @@ <%=l(:label_courses_management_platform)%> > - <%= link_to @course.name, nil %> + <%= link_to @course.name, course_path(@course) %>