diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index acfd785d9..b99963e2f 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -5,39 +5,73 @@ class PraiseTreadController < ApplicationController def praise_plus @obj = nil - # @is_in_list = nil + @activity = false + if request.get? @obj_id = params[:obj_id] @obj_type = params[:obj_type] - @horizontal = params[:horizontal].downcase == "false" ? false:true + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end + # @is_in_list = nil @obj = find_object_by_type_and_id(@obj_type,@obj_id) - unless @obj.author_id == User.current.id + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id) + unless pts.empty? + respond_to do |format| + format.js + end + return + end + #@horizontal = params[:horizontal].downcase == "false" ? false:true + if @obj.respond_to?("author_id") + author_id = @obj.author_id + elsif @obj.respond_to?("user_id") + author_id = @obj.user_id + end + unless author_id == User.current.id praise_tread_plus(@obj_type,@obj_id,1) end - + respond_to do |format| + format.js + end end end def praise_minus @obj = nil + @activity = false if request.get? - @obj = params[:obj] # 传的是对象,最后变成id了 - + #@obj = params[:obj] # 传的是对象,最后变成id了 #首先更新praise_tread 表 删除关注记录 - @pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user") - @pt.delete - + #@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user") + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end + @obj = find_object_by_type_and_id(@obj_type,@obj_id) + @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first + if @pt.nil? + respond_to do |format| + format.js + end + return + end + @pt.delete if !@pt.nil? #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 - @ptc = PraiseTreadCache.find_by_object_id(@obj) - @ptc.minus(1) + @ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first + @ptc.minus(1) if !@ptc.nil? if @ptc.praise_num == 0 - @ptc.delete + @ptc.delete end end - @obj = User.find_by_id(@obj) + #@obj = User.find_by_id(@obj) respond_to do |format| - format.html format.js end end @@ -48,7 +82,7 @@ class PraiseTreadController < ApplicationController if request.get? @obj_id = params[:obj_id] @obj_type = params[:obj_type] - @horizontal = params[:horizontal].downcase == "false" ? false:true + #@horizontal = params[:horizontal].downcase == "false" ? false:true @obj = find_object_by_type_and_id(@obj_type,@obj_id) unless @obj.author_id == User.current.id praise_tread_plus(@obj_type,@obj_id,0) @@ -83,6 +117,16 @@ class PraiseTreadController < ApplicationController @obj = Memo.find_by_id(id) when 'Message' @obj = Message.find_by_id(id) + when 'HomeworkCommon' + @obj = HomeworkCommon.find_by_id(id) + when 'JournalsForMessage' + @obj = JournalsForMessage.find_by_id(id) + when 'News' + @obj = News.find_by_id(id) + when 'Comment' + @obj = Comment.find_by_id(id) + when 'Journal' + @obj = Journal.find_by_id(id) end return @obj end @@ -106,10 +150,6 @@ class PraiseTreadController < ApplicationController @ptc.save @ptc.plus(flag,1) end - respond_to do |format| - format.html - format.js - end end end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0a9de787a..cafec1c62 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -122,8 +122,8 @@ class RepositoriesController < ApplicationController if project.save r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) - if ProjectScore.where("project_id=?", @project.id).first.nil? - ProjectScore.create(:project_id => @project.id, :score => false) + if ProjectScore.where("project_id=?", project.id).first.nil? + ProjectScore.create(:project_id => project.id, :score => false) end project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be9c59992..07f7a0ed8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2792,7 +2792,7 @@ int main(int argc, char** argv){ g = Gitlab.client project.gpid.nil? ? 0 : g.project(project.gpid).commit_count # project.changesets.count - end +end #课程动态的更新 def update_course_activity type, id diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 50854cf23..3ded0cb1d 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -2,19 +2,19 @@ <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> <% if show_nav?(@course.homework_commons.count) %> <% end %> <% if show_nav?(@course.news.count) %> <% end %> <% if show_nav?(course_file_num) %>
上传时间:<%= format_date(file.created_on)%> diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb index 7332f4892..31fb38cce 100644 --- a/app/views/files/_subfield_files.html.erb +++ b/app/views/files/_subfield_files.html.erb @@ -50,7 +50,7 @@
- <%#= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%> + <%= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%>

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

diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 49198e680..1d66c2955 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -60,9 +60,9 @@ $('#upload_file_div').slideToggle('slow'); $("#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); +// var div = $('
文件上传成功!
'); +// $("#org_subfield_list").prepend(div); +// setTimeout( function(){div.remove();},3000); <% end %> <% end %> <% end %> diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index b28e6843f..48cd4ab53 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -102,9 +102,9 @@
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index cb5c2502f..bef5b7f4a 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -126,7 +126,7 @@ <%# 工具栏展开 %> <% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 || course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %> - + diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 5d4aebcf7..631385e22 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -223,10 +223,16 @@ <% count=activity.journals_for_messages.count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%if count>3 %> @@ -261,6 +267,19 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> + +
<%= comment.notes.html_safe %>
diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index 93aa7a97b..55be0bf91 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -72,11 +72,17 @@ <% count=activity.children.count%> <% end %>
-
-
-
回复( - <%= count %> - )
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%#=format_date(activity.updated_on)%>
<%if count > 3 %>
@@ -111,6 +117,13 @@ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<%= reply.content.html_safe %> diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 7926d2737..ddad08279 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -44,10 +44,16 @@
<% count=activity.comments.count %>
-
-
-
- 回复(<%= count %>) +
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
<%#= format_date(activity.updated_on) %>
<%if count>3 %> @@ -82,6 +88,13 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
<%= comment.comments.html_safe %>
diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 32b717896..9c1863992 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -57,9 +57,17 @@
<% count = activity.journals.count %>
-
-
-
回复(<%= count %>)
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%#= format_date(activity.updated_on) %>
<% if count > 3 %>
@@ -93,6 +101,13 @@ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<% if reply.details.any? %> diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb index bc9e28de0..901c2ecf4 100644 --- a/app/views/organizations/_org_subfield_message.html.erb +++ b/app/views/organizations/_org_subfield_message.html.erb @@ -57,12 +57,17 @@ <% count=activity.children.count%> <% end %>
-
-
-
回复( - <%=count %> - )
-
<%#=format_date(activity.updated_on)%>
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%if count>3 %> <% end %> @@ -92,6 +97,13 @@ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<%= reply.content.html_safe %>
diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 7e8746fc4..c7d99c5fb 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -57,11 +57,17 @@ <% count=activity.children.count%> <% end %>
-
-
-
回复( - <%=count %> - )
+
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
<%#=format_date(activity.updated_on)%>
<%if count>3 %> @@ -92,6 +98,13 @@ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> +
<%= reply.content.html_safe %>
diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 10cf6fc00..b49436d4e 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -28,9 +28,15 @@
  • 新增
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • <% count=activity.comments.count %>
    -
    -
    -
    - 回复(<%= count %>) +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
    <%#= format_date(activity.updated_on) %>
    <%if count>3 %> @@ -82,6 +88,13 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> +
    <%= comment.comments.html_safe %>
    diff --git a/app/views/tags/update_org_subfield_tag_name.js.erb b/app/views/tags/update_org_subfield_tag_name.js.erb index 4fabc1afd..418d05363 100644 --- a/app/views/tags/update_org_subfield_tag_name.js.erb +++ b/app/views/tags/update_org_subfield_tag_name.js.erb @@ -8,4 +8,5 @@ <% else %> $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'files/org_subfield_list', :locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments}) %>"); + $("#files_tag").html("<%= j(render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}) %>") <% end %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 66d348d98..81627f9d6 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -223,10 +223,16 @@ <% count=activity.journals_for_messages.count %>
    -
    -
    -
    - 回复(<%= count %>) +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> +
    <%if count>3 %> @@ -261,12 +267,20 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> -
    <%= comment.notes.html_safe %>
    diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 21a3ff076..d8268d698 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -22,7 +22,7 @@ <% end %>
    <% if activity.sticky == 1%> - 置顶 + 置顶 <% end%> <% if activity.locked%>        @@ -92,11 +92,17 @@ <% count=activity.children.count%> <% end %>
    -
    -
    -
    回复( - <%= count %> - )
    +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
    <%#=format_date(activity.updated_on)%>
    <%if count > 3 %>
    @@ -114,9 +120,9 @@
      <% activity.children.reorder("created_on desc").each do |reply|%> <% replies_all_i=replies_all_i+1 %>
    • @@ -131,6 +137,14 @@ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> + + <% if reply.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> + +
    <%= reply.content.html_safe %> @@ -144,26 +158,26 @@ <% end %> <% if !activity.locked? && authorize_for_course('messages', 'reply') %> -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    -
    - <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> - - - -
    - +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> + + + +
    + +
    +

    + <% end%>
    -

    - <% end%> +
    +
    +
    -
    -
    -
    -
    - <% end %> + <% end %>