diff --git a/Gemfile b/Gemfile index c739e1085..645c7b849 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ gem 'chinese_pinyin' # gem 'progress_bar' gem 'ansi' +gem 'debugger' gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f06a782bc..24f5fd52c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -902,10 +902,7 @@ class CoursesController < ApplicationController end def feedback - @course.journals_for_messages.each do |messages| - query = messages.course_messages.where("user_id = ?", User.current.id) - query.update_all(:viewed => true); - end + CourseMessage.where("user_id = ? and course_id = ?", User.current, @course.id).update_all(:viewed => true) if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) page = params[:page] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index eb78c4c5b..44f0d15f4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -118,6 +118,9 @@ class IssuesController < ApplicationController end def show + # 打开编辑内容 + @is_edit = true unless params[:edit].nil? + # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query.update_attribute(:viewed, true) unless query.nil? @@ -387,6 +390,9 @@ class IssuesController < ApplicationController end def destroy + # 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉 + page_classify = params[:page_classify] unless params[:page_classify].nil? + page_id = params[:page_id] unless params[:page_id].nil? @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] @@ -415,7 +421,11 @@ class IssuesController < ApplicationController end end respond_to do |format| - format.html { redirect_back_or_default _project_issues_path(@project) } + if page_classify + format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) } + else + format.html { redirect_back_or_default _project_issues_path(@project) } + end format.api { render_api_ok } end end diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index 15c809964..8d08f22da 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -22,10 +22,18 @@ module RoutesHelper # Returns the path to project issues or to the cross-project # issue list if project is nil def _project_issues_path(project, *args) - if project - project_issues_path(project, *args) + if args[0].to_s.include? '_page' + if args[0].to_s == "user_page" + user_activities_path(args[1].to_i) + else + project_path(project) + end else - issues_path(*args) + if project + project_issues_path(project, *args) + else + issues_path(*args) + end end end diff --git a/app/models/user.rb b/app/models/user.rb index a74c20751..abae2438a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,7 +116,7 @@ class User < Principal has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" - has_many :org_document_comments, :dependent =>:destroy + has_many :org_document_comments, :dependent =>:destroy, :foreign_key => "creator_id" has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source has_many :org_members @@ -1064,6 +1064,16 @@ class User < Principal anonymous_user end + # refactor User model find function, + # return anonymous user when can not find user id = user_id + def self.find (*args, &block) + begin + super + rescue + self.anonymous + end + # super + end # Salts all existing unsalted passwords # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # This method is used in the SaltPasswords migration and is to be kept as is diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index b9d463855..4b82f8665 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -9,6 +9,9 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); + if(<%= @is_edit %>) { + issueEditShow(); + } });
diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 73163521e..7e0832257 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -66,7 +66,7 @@ <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> <% when "Issue" %> - <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id} %> + <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %> <% when "Message" %> diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 1ce03da17..5d472497d 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -13,6 +13,29 @@ <% end %> TO <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
+
+ +
<% case activity.tracker_id %> <% when 1%> @@ -51,6 +74,10 @@
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> + + + +
<%# 局部刷新:修改xissue属性 %> <% if User.current.member_of?(activity.project) %> <% unless params[:action] == "index" %> @@ -59,10 +86,7 @@ <% end %> <% end %> -
- - -
+
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 0e55c246c..01711ace3 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -89,7 +89,7 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %> <% when 'Message' %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> <% when 'ProjectCreateInfo'%> diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb index d8649cabe..089171c3d 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -8,15 +8,15 @@ <% if ma.at_message_type == "Message" && !ma.at_message.course.nil? %> <%= link_to ma.subject.html_safe, course_boards_path(ma.at_message.course, :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id), - :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% elsif ma.at_message_type == "Message" && !ma.at_message.project.nil? %> <%= link_to ma.subject.html_safe, project_boards_path(ma.at_message.project, :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id), - :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% else %> <%= link_to ma.subject.html_safe, ma.url, :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> <% end %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 62568d505..458ba4551 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -5,9 +5,10 @@
  • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
  • <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id }, - :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %>
  • + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +