diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index dcd549d76..bbccf2d6e 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -145,10 +145,12 @@ class BlogCommentsController < ApplicationController @blogComment.content = params[:blog_comment][:content] parent = BlogComment.find params[:parent_id] @blogComment.reply_id = params[:id] + @blogComment.root_id = parent.root_id.nil? ? parent.id : parent.root_id parent.children << @blogComment else @quote = params[:quote][:quote] || "" @blogComment.content = @quote + @blogComment.content + @blogComment.root_id = @article.id @article.children << @blogComment end @article.save diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 099e9404a..d4eedb7e3 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -126,7 +126,8 @@ class BoardsController < ApplicationController @type = 2 @topics.each do |topic| all_comments = [] - count=get_all_children(all_comments, topic).count + #count=get_all_children(all_comments, topic).count + count=Message.where("root_id = #{topic.id}").count topic[:infocount] = get_praise_num(topic) + count if topic[:infocount] < 0 topic[:infocount] = 0 diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7318a4dc2..54babdd64 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,7 +26,7 @@ class FilesController < ApplicationController before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project, :search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment, :search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache, - :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description, :edit_file_description] helper :sort include SortHelper @@ -981,6 +981,13 @@ class FilesController < ApplicationController def upload_files_menu end + + def edit_file_description + @attachment = Attachment.find(params[:id]) + @attachment.description = params[:file_description_edit] + @attachment.save + end + def update_file_description @attachment = Attachment.find(params[:id]) @attachment.description = params[:description] diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 226d24afa..31ca95789 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -45,7 +45,7 @@ class MessagesController < ApplicationController # page = 1 + offset / REPLIES_PER_PAGE # end all_comments = [] - @replies = get_all_children(all_comments, @topic) + @replies = Message.where("root_id = #{@topic.id}").reorder("created_on desc") @reply_count = @replies.count @page = params[:page] ? params[:page].to_i + 1 : 0 @limit = 10 @@ -165,6 +165,7 @@ class MessagesController < ApplicationController @reply.content = params[:content] @reply.subject = "RE: #{@topic.subject}" @reply.reply_id = params[:id] + @reply.root_id = parent.root_id.nil? ? parent.id : parent.root_id # @reply.reply_id = params[:id] parent.children << @reply @user_activity_id = params[:user_activity_id] if params[:user_activity_id] @@ -178,6 +179,7 @@ class MessagesController < ApplicationController @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] + @reply.root_id = @topic.id @topic.children << @reply # @reply.reply_id = params[:id] end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index a8a294d4d..65dae9b9e 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -89,6 +89,7 @@ class OrgDocumentCommentsController < ApplicationController @act = OrgActivity.find(params[:act_id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment.content = params[:org_content] + @comment.root_id = @document.id @document.children << @comment @document.save end @@ -102,6 +103,7 @@ class OrgDocumentCommentsController < ApplicationController @comment.content = params[:org_comment][:org_content] end + @comment.root_id = @document.id @document.children << @comment @document.save respond_to do |format| @@ -161,6 +163,7 @@ class OrgDocumentCommentsController < ApplicationController @org_document.title = params[:org_document_comment][:title] @org_document.content = params[:org_document_comment][:content] + @org_document.root_id = @document.root_id.nil? ? @document.id : @document.root_id @document.children << @org_document @document = @document.root diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 78c60599a..150a113a3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3524,19 +3524,19 @@ class UsersController < ApplicationController if params[:type].present? case params[:type] when 'OrgDocumentComment' - obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first + #obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] @type = 'OrgDocumentComment' - comments = [] - @journals = get_all_children(comments, obj) + #comments = [] + @journals = OrgDocumentComment.where("root_id = #{params[:id].to_i}").reorder("created_at desc") when 'Message' - obj = Message.where('id = ?', params[:id].to_i).first + #obj = Message.where('id = ?', params[:id].to_i).first @type = 'Message' @is_course = params[:is_course] @is_board = params[:is_board] @user_activity_id = params[:div_id].to_i if params[:div_id] - comments = [] - @journals = get_all_children(comments, obj) + #comments = [] + @journals = Message.where("root_id = #{params[:id].to_i}").reorder("created_on desc") when 'News' obj = News.where('id = ?', params[:id].to_i).first @journals = obj.comments.reorder("created_on desc") @@ -3548,9 +3548,9 @@ class UsersController < ApplicationController @type = 'Syllabus' @user_activity_id = params[:div_id].to_i if params[:div_id] when 'JournalsForMessage' - obj = JournalsForMessage.where('id = ?', params[:id].to_i).first - journals = [] - @journals = get_all_children(journals, obj) + #obj = JournalsForMessage.where('id = ?', params[:id].to_i).first + #journals = [] + @journals = JournalsForMessage.where("root_id = #{params[:id].to_i}").reorder("created_on desc") @type = 'JournalsForMessage' @user_activity_id = params[:div_id].to_i if params[:div_id] when 'Issue' @@ -3559,13 +3559,13 @@ class UsersController < ApplicationController @type = 'Issue' @user_activity_id = params[:div_id].to_i if params[:div_id] when 'BlogComment' - obj = BlogComment.where('id = ?', params[:id].to_i).first + #obj = BlogComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] @homepage = params[:homepage].to_i @type = 'BlogComment' @user_id = obj.author_id - comments = [] - @journals = get_all_children(comments, obj) + #comments = [] + @journals = BlogComment.where("root_id = #{params[:id].to_i}").reorder("created_on desc") when 'HomeworkCommon' obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @type = 'HomeworkCommon' diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 9c8954ed9..c9bb42ebe 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -41,6 +41,7 @@ class WordsController < ApplicationController # 删除留言功能要调用destroy,也记得在destroy.js中修改 # deny api. api useless + parent = JournalsForMessage.find params[:reference_id].to_i parent_id = params[:reference_id] author_id = User.current.id reply_user_id = params[:reference_user_id] @@ -52,7 +53,8 @@ class WordsController < ApplicationController :m_parent_id => parent_id, :m_reply_id => reply_id, :reply_id => reply_user_id, - :notes => content, + :notes => content, + :root_id => parent.root_id.nil? ? parent.id : parent.root_id, :is_readed => false} @activity = params[:activity_id].nil? ? JournalsForMessage.find(parent_id) : JournalsForMessage.find(params[:activity_id].to_i) @jfm = add_reply_adapter(@activity, options) @@ -274,7 +276,7 @@ class WordsController < ApplicationController @user = User.current @syllabus = Syllabus.find(params[:id]); if params[:comment].size>0 && User.current.logged? && @user - feedback = Syllabus.add_syllabus_jour(@user, params[:comment], params[:id]) + feedback = Syllabus.add_syllabus_jour(@user, params[:comment], params[:id], @syllabus.id) if (feedback.errors.empty?) if params[:asset_id] ids = params[:asset_id].split(',') @@ -296,7 +298,7 @@ class WordsController < ApplicationController @user = User.current @homework_common = HomeworkCommon.find(params[:id]); if params[:homework_message].size>0 && User.current.logged? && @user - feedback = HomeworkCommon.add_homework_jour(@user, params[:homework_message], params[:id]) + feedback = HomeworkCommon.add_homework_jour(@user, params[:homework_message], params[:id], @homework_common.id) if (feedback.errors.empty?) if params[:asset_id] ids = params[:asset_id].split(',') @@ -329,7 +331,7 @@ class WordsController < ApplicationController reply = JournalsForMessage.find params[:id].to_i @homework_common = HomeworkCommon.find reply.jour_id if params[:reply_message].size>0 && User.current.logged? && @user - options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i} + options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i, :root_id => reply.root_id} feedback = HomeworkCommon.add_homework_jour(@user, params[:reply_message], reply.jour_id, options) if (feedback.errors.empty?) if params[:asset_id] @@ -363,7 +365,7 @@ class WordsController < ApplicationController reply = JournalsForMessage.find params[:id].to_i @syllabus = Syllabus.find reply.jour_id if params[:reply_message].size>0 && User.current.logged? && @user - options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i} + options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i, :root_id => reply.root_id} feedback = Syllabus.add_syllabus_jour(@user, params[:reply_message], reply.jour_id, options) if (feedback.errors.empty?) if params[:asset_id] diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 88fadd644..879759c89 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -41,7 +41,7 @@ class Attachment < ActiveRecord::Base validates :filename, presence: true, length: {maximum: 254} validates :author, presence: true validates :disk_filename, length: {maximum: 254} - validates :description, length: {maximum: 254} + # validates :description, length: {maximum: 254} validate :validate_max_file_size #elasticsearch diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 6290840a3..6189d435f 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -19,7 +19,7 @@ class BlogComment < ActiveRecord::Base validates_presence_of :title, :content validates_length_of :title, :maximum => 255 #validate :cannot_reply_to_locked_comment, :on => :create - safe_attributes 'title', 'content',"sticky", "locked" + safe_attributes 'title', 'content',"sticky", "locked", "root_id" after_save :add_user_activity after_update :update_activity diff --git a/app/models/course.rb b/app/models/course.rb index cc80a1b4b..13050ddbe 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -24,7 +24,7 @@ class Course < ActiveRecord::Base end end - attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete, :syllabus_id + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 @@ -96,7 +96,9 @@ class Course < ActiveRecord::Base 'class_period', 'open_student', 'is_delete', - 'syllabus_id' + 'syllabus_id', + 'end_time', + 'end_term' acts_as_customizable diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index dfff273a0..3072fa72b 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -113,10 +113,10 @@ class HomeworkCommon < ActiveRecord::Base end ###添加回复 - def self.add_homework_jour(user, notes, id , options = {}) + def self.add_homework_jour(user, notes, id, root_id, options = {}) homework = HomeworkCommon.find(id) if options.count == 0 - jfm = homework.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0) + jfm = homework.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0, :root_id => root_id) else jfm = homework.journals_for_messages.build(options) end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 30d8120ef..2ea52fd92 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -19,7 +19,8 @@ class JournalsForMessage < ActiveRecord::Base "m_reply_count", # 留言的回复数量 "m_reply_id" , # 回复某留言的留言id(a留言回复了b留言,这是b留言的id) "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 - "private" + "private", + "root_id" acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC" after_destroy :delete_kindeditor_assets belongs_to :project, diff --git a/app/models/message.rb b/app/models/message.rb index 3192907fe..1d76c8ef6 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -96,7 +96,7 @@ class Message < ActiveRecord::Base } - safe_attributes 'subject', 'content', 'reply_id' + safe_attributes 'subject', 'content', 'reply_id', 'root_id' safe_attributes 'board_id','locked', 'sticky', :if => lambda {|message, user| if message.project diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index a87fe783f..59fcd28dc 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -1,6 +1,6 @@ class OrgDocumentComment < ActiveRecord::Base # status: 1 模式二中置顶 0:模式二中正常显示 - attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title, :sticky, :locked, :status + attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title, :sticky, :locked, :status, :root_id include Redmine::SafeAttributes include ApplicationHelper belongs_to :organization diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 959499bf0..ea5d44dfd 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -65,10 +65,10 @@ class Syllabus < ActiveRecord::Base end ###添加回复 - def self.add_syllabus_jour(user, notes, id , options = {}) + def self.add_syllabus_jour(user, notes, id, root_id, options = {}) syllabus = Syllabus.find(id) if options.count == 0 - jfm = syllabus.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0) + jfm = syllabus.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0, :root_id => root_id) else jfm = syllabus.journals_for_messages.build(options) end diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 7143e980b..4e46879fc 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -106,7 +106,7 @@
<% all_comments = []%> - <% all_replies = get_all_children(all_comments, @article) %> + <% all_replies = BlogComment.where("root_id = #{@article.id}").reorder("created_on desc") %> <% count= all_replies.count %>
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index dd818fe72..bb16dcea0 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -36,12 +36,8 @@ <% end %>
- <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> + + <% count=BlogComment.where("root_id = #{activity.id}").count%>
  • 发布:<%= format_time(activity.created_on) %> 更新:<%= format_time(activity.updated_on) %> diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb index 6e45fdd88..6b40a23da 100644 --- a/app/views/blogs/_homepage.html.erb +++ b/app/views/blogs/_homepage.html.erb @@ -46,7 +46,7 @@
  • <% all_comments = []%> - <% all_repies = get_all_children(all_comments, activity) %> + <% all_repies = BlogComment.where("root_id = #{activity.id}").reorder("created_on desc") %> <% count = all_repies.count %>
    <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 1} %> diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index de37ed054..45aa7095b 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -43,8 +43,10 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    - + <%= form_tag(edit_file_description_org_subfield_file_path(file, :org_subfield_id => org_subfield.id ),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
    <% else %>
    @@ -108,3 +110,8 @@ <%end%> <% end%> + \ No newline at end of file diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index faf254015..3193f4b42 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -40,8 +40,10 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    - + <%= form_tag(edit_file_description_project_file_path(file, :project_id => project.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
    <% else %>
    @@ -70,6 +72,11 @@ <%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%> + diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index b60814afd..08b85ab2f 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -42,8 +42,10 @@
    <%= render :partial => 'files/file_description', :locals => {:file => file} %>
    - + <%= form_tag(edit_file_description_course_file_path(file, :course_id => @course.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
    <% else %>
    @@ -99,4 +101,9 @@
    -
    \ No newline at end of file +
    + diff --git a/app/views/files/edit_file_description.js.erb b/app/views/files/edit_file_description.js.erb new file mode 100644 index 000000000..40b47a2ec --- /dev/null +++ b/app/views/files/edit_file_description.js.erb @@ -0,0 +1,3 @@ +$("#file_description_show_<%= @attachment.id %>").html("<%= escape_javascript render(:partial => "files/file_description", :locals => {:file => @attachment}) %>"); +$("#file_description_show_<%= @attachment.id %>").show(); +$("#file_description_edit_<%= @attachment.id %>").hide(); \ No newline at end of file diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 9a52fb410..853a43eca 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -35,5 +35,5 @@ <% end %> <% else %> - <%= render :partial => "layouts/no_content" %> + <%#= render :partial => "layouts/no_content" %> <% end %> \ No newline at end of file diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 412cbe540..cdc752e7e 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -14,9 +14,12 @@ - + <% memo = Memo.where(:id => 1168).first %> + <% unless memo.nil? %> + + <% end %> <% else %>