diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index af229635c..82a25cb01 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -20,11 +20,15 @@ class OrgDocumentCommentsController < ApplicationController end end def show - + @document = OrgDocumentComment.find(params[:id]) end def index - @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + else + render_403 + end end def update @org_document = OrgDocumentComment.find(params[:id]) @@ -48,6 +52,17 @@ class OrgDocumentCommentsController < ApplicationController @document.save end + def add_reply_in_doc + @document = OrgDocumentComment.find(params[:id]).root + @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:org_comment][:org_content] + @document.children << @comment + @document.save + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def find_organization @organization = Organization.find(params[:organization_id]) end @@ -61,4 +76,62 @@ class OrgDocumentCommentsController < ApplicationController end end end + + def delete_reply + @org_document_comment = OrgDocumentComment.find(params[:id]) + @document = @org_document_comment.root + org = @org_document_comment.organization + @org_document_comment.destroy + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def quote + @org_comment = OrgDocumentComment.find(params[:id]) + @subject = @org_comment.content + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " + @temp = OrgDocumentComment.new + #@course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + def reply + @document = OrgDocumentComment.find(params[:id]).root + @quote = params[:quote][:quote] + @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) + + # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @org_document.title = params[:org_document_comment][:title] + @org_document.content = params[:org_document_comment][:content] + @org_document.content = @quote + @org_document.content + #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document + # @user_activity_id = params[:user_activity_id] + # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + # if user_activity + # user_activity.updated_at = Time.now + # user_activity.save + # end + # attachments = Attachment.attach_files(@org_document, params[:attachments]) + # render_attachment_warning_if_needed(@org_document) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + # redirect_to syllabus_course_path(:id=>params[:course_id]) + # else + redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) + # end + + } + format.js + end + end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3713beb22..0d22ab461 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -151,7 +151,11 @@ class OrganizationsController < ApplicationController end def members - @members = OrgMember.where("organization_id =?", @organization.id) + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @members = OrgMember.where("organization_id =?", @organization.id) + else + render_403 + end end def more_org_projects diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index af90b3049..bb8a91b69 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -13,10 +13,10 @@ <% author = topic.last_reply.try(:author)%> <% if author%> -
最后回复:<%= author.name%>
+
最后回复:<%= author.name%>
<%= format_date(topic.last_reply.created_at)%>
<% end%> -
最后更新:<%= format_date(topic.updated_at)%>
+
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 408be0aa3..efcd15a66 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -79,7 +79,6 @@ <%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> <% end %>
-
最后更新:<%= format_date(@memo.updated_at)%>
diff --git a/app/views/org_document_comments/_reply_form.html.erb b/app/views/org_document_comments/_reply_form.html.erb new file mode 100644 index 000000000..7871b910d --- /dev/null +++ b/app/views/org_document_comments/_reply_form.html.erb @@ -0,0 +1,2 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); diff --git a/app/views/org_document_comments/_simple_ke_reply_form.html.erb b/app/views/org_document_comments/_simple_ke_reply_form.html.erb new file mode 100644 index 000000000..cfa197ff4 --- /dev/null +++ b/app/views/org_document_comments/_simple_ke_reply_form.html.erb @@ -0,0 +1,31 @@ + + +
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
+ <%= form_for @org_comment, :as => :reply, :url => {:controller => 'org_document_comments',:action => 'reply', :id => @org_comment.id}, :method => 'post', :html => {:multipart => true, :id => 'new_form'} do |f| %> + + + +
+ +
+

+ <% end%> +
+
+
+
+
\ No newline at end of file diff --git a/app/views/org_document_comments/add_reply_in_doc.js.erb b/app/views/org_document_comments/add_reply_in_doc.js.erb new file mode 100644 index 000000000..bcebe9d37 --- /dev/null +++ b/app/views/org_document_comments/add_reply_in_doc.js.erb @@ -0,0 +1 @@ +location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index 498ac46a6..4b50c1064 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -26,7 +26,7 @@
- <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org1_document_description_editor', :height => "150px" %> + <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %>
@@ -37,7 +37,7 @@
确定 - 取消 + 取消
diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb index 6019dae14..d967c42fd 100644 --- a/app/views/org_document_comments/index.html.erb +++ b/app/views/org_document_comments/index.html.erb @@ -16,7 +16,7 @@ <% @documents.each do |document| %> <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> diff --git a/app/views/org_document_comments/quote.js.erb b/app/views/org_document_comments/quote.js.erb new file mode 100644 index 000000000..a71b23f0e --- /dev/null +++ b/app/views/org_document_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @org_comment.id%>").length > 0) { + $("#reply_message_<%= @org_comment.id%>").replaceWith("<%= escape_javascript(render :partial => 'org_document_comments/simple_ke_reply_form', :locals => {:reply => @org_comment,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @org_comment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @org_comment.id %>").length >0) { + $("#reply_to_message_<%= @org_comment.id%>").replaceWith("

"); +} \ No newline at end of file diff --git a/app/views/org_document_comments/reply.js.erb b/app/views/org_document_comments/reply.js.erb new file mode 100644 index 000000000..888613c8c --- /dev/null +++ b/app/views/org_document_comments/reply.js.erb @@ -0,0 +1 @@ +//location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index e69de29bb..ae90b15bb 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -0,0 +1,147 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + +
+
+
+ <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_path(@document.creator_id) %> +
+
+
+ <%= link_to User.find(@document.creator_id), user_path(@document.creator.id), :class => "newsBlue mr15" %> + TO  <%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> + | + <% if @document.organization.home_id == @document.id %> + 首页 + <% else %> + 组织文章 + <% end %> +
+
<%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %>
+
+ 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
+ <% unless @document.content.blank? %> +
+ <%= @document.content.html_safe %> +
+ <% end %> + + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> +
+
    +
  • +
      +
    • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> + 设为首页 + <% end %> +
    • +
    • + <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :class => "postOptionLink" %> +
    • +
    • + <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
    • +
    +
  • +
+
+
+ <% end %> +
+
+ <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> + +
+ <% if count > 0 %> +
+
回复(<%= count %>)
+
+
+ <% comments_for_doc.each_with_index do |reply,i| %> + + <% user = User.find(reply.creator_id) %> +
+
+ <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_path(user) %> +
+
+
+ <%= reply.content.html_safe unless reply.content.nil? %> +
+
+ <%= format_time(reply.created_at) %> + +
+

+
+
+
+ <% end %> +
+
+ <% end %> + <% if User.current.logged?%> +
+ +
+
+ <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> + <% end %> +
+
+
+ <% end %> +
+
+ + \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 1324729ac..e74da846e 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -14,7 +14,7 @@ 组织文章 <% end %>
-
<%= document.title %>
+
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
<% unless document.content.blank? %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 3e4576b47..da649663d 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -126,7 +126,7 @@ <% end %> -
  •    截止时间快到了.
  • +
  •    截止时间快到了!
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -158,7 +158,7 @@
  • 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  23:59
  • <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%> -

    请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    +

    请您尽早完成匿评!如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分

    <% end%> @@ -209,7 +209,7 @@ <% end %> @@ -404,16 +404,14 @@

    如需获得最终成绩,请您联系主讲老师对您的作品进行单独评分!

    -
  •   您迟交了作品
  • +
  •   您迟交了作品!
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> <% if ma.course_message_type == "Course" %>