diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5e968e854..30f78d9a5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -149,6 +149,9 @@ class UsersController < ApplicationController @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] @type = 'Issue' + when 'Syllabus' + @reply = JournalsForMessage.find params[:reply_id] + @type = 'Syllabus' end respond_to do |format| format.js @@ -3342,6 +3345,8 @@ class UsersController < ApplicationController when 'Syllabus' obj = Syllabus.where('id = ?', params[:id].to_i).first @journals = obj.journals_for_messages.reorder("created_on desc") + @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 = [] diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 828739cc4..499272706 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -112,6 +112,10 @@ class WordsController < ApplicationController end @is_in_course = params[:is_in_course].to_i @course_activity = params[:course_activity].to_i + elsif @journal_destroyed.jour_type == 'Syllabus' + @syllabus = Syllabus.find @journal_destroyed.jour_id + @count = @syllabus.journals_for_messages.count + @comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3) end respond_to do |format| format.js @@ -352,6 +356,35 @@ class WordsController < ApplicationController render_403 end end + + #课程大纲的二级回复 + def reply_to_syllabus + if User.current.logged? + @user = User.current + 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} + feedback = Syllabus.add_syllabus_jour(@user, params[:reply_message], reply.jour_id, options) + if (feedback.errors.empty?) + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end + @syllabus.update_column('updated_at', Time.now) + @count = @syllabus.journals_for_messages.count + @comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3) + respond_to do |format| + format.js + end + else + flash[:error] = feedback.errors.full_messages[0] + end + end + else + render_403 + end + end def add_brief_introdution user = User.current diff --git a/app/views/layouts/_base_course_old.html.erb b/app/views/layouts/_base_course_old.html.erb deleted file mode 100644 index 4b2077cf8..000000000 --- a/app/views/layouts/_base_course_old.html.erb +++ /dev/null @@ -1,278 +0,0 @@ -<%# course_model %> -<% course_file_num = visable_attachemnts_incourse(@course).count%> -<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> -<% homework_num = visable_course_homework @course %> - - - - - - - <%= h html_title %> - - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= javascript_heads %> - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup'%> - <%= javascript_include_tag "course","sy_public", "syllabus","header","attachments",'prettify' %> - - <%= yield :header_tags -%> - - - - - - - - - - - -
-
-
-
-
- <%=render :partial=>'layouts/project_info' %> -
- -
-
    -
  • <%= l(:label_main_teacher)%> :  <%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %>
  • -
  • <%= l(:label_class_period)%> :  <%= @course.class_period %> <%= l(:label_class_hour) %>
  • -
  • <%= l(:label_main_term)%> :  <%= current_time_and_term @course %>
  • - <% if @course.school%> -
  • <%= l(:label_course_organizers)%> :  <%= @course.school%>
  • - <% end%> -
-
- - <%# 更新访问数,刷新的时候更新访问次数 %> - <% update_visiti_count @course %> - <%# over %> - - - <%# 课程活跃度 %> -
- <%= render :partial => 'courses/course_activity_users', :locals => {:course => @course} %> - <%# 课程英雄榜 %> - <%= render :partial => 'courses/course_heroes', :locals => {:course => @course} %> - - <% if @course.description && !@course.description.blank? %> -
-
-

<%= l(:label_course_brief_introduction)%>:

-
- <%= textilizable(@course.description) if @course.description && !@course.description.blank? %> -
-
-
- - - - -
-
- <% end %> -
-

<%= l(:label_tag)%>:

-
- <%= render :partial => 'tags/new_tag', :locals => {:obj => @course, :object_flag => "9"} %> -
-
-
- - <%= render :partial => 'courses/recommendation', :locals => {:course => @course} %> -
访问计数 <%= @course.visits.to_i %> (自2016年5月)
-
- -
- <%= yield %> - <%#= render_flash_messages %> - <%#= call_hook :view_layouts_base_content %> -
- -
- -
-
- -
-<%= render :partial => 'layouts/footer' %> -
- -<%= render :partial => 'layouts/new_feedback' %> - - -<%= call_hook :view_layouts_base_body_bottom %> - - - - \ No newline at end of file diff --git a/app/views/layouts/_base_syllabus_old.html.erb b/app/views/layouts/_base_syllabus_old.html.erb deleted file mode 100644 index 45e77dbad..000000000 --- a/app/views/layouts/_base_syllabus_old.html.erb +++ /dev/null @@ -1,151 +0,0 @@ - - - - - <%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'syllabus','css/common','css/public','css/structure','css/courses','css/popup','prettify',:media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> - <%= javascript_heads %> - <%= javascript_include_tag "bootstrap","avatars","course",'attachments','prettify','syllabus'%> - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - <%= yield :header_tags -%> - - - - - - - -<% is_current_user = User.current.logged?%> - -
-
-
-
-
- <%=render :partial => 'layouts/syllabus_info' %> -
- <% update_visiti_count @syllabus %> - -
- <%= render :partial => 'layouts/syllabus_base_info', :locals => {:syllabus => @syllabus} %> -
- -
-
- <%=link_to '班级', {:controller => "syllabuses", :action => "syllabus_courselist", :id => @syllabus.id}, :class => 'homepageMenuText' %> - <% if is_current_user%> - <% if User.current == @syllabus.user && User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> -
-
    -
  • -
      -
    • - <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "menuGrey", :target => '_blank'%> -
    • -
    • - <%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%> -
    • -
    -
  • -
-
- <% else%> - <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入班级"%> - <% end%> - <% end%> -
- <% if User.current == @syllabus.user || User.current.admin? - all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") - else - all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") - end %> - <% courses = all_courses.limit(5) %> - <% all_count = all_courses.count%> -
-
-
    - <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => User.current,:all_count => all_count,:type =>'Syllabus',:page => 0} %> -
-
- <% if !courses.empty? %> -
- -
- <% end %> -
-
- -
-

标签:

-
- <%= render :partial => 'tags/syllabus_tag', :locals => {:obj => @syllabus,:object_flag => "11"}%> -
-
-
-
访问计数 <%=@syllabus.visits %> (自2016年7月)
- -
-
- <%= yield %> -
-
- <%= render :partial => 'layouts/new_feedback' %> -
-
-<%= render :partial => 'layouts/footer' %> -
- - - - - - diff --git a/app/views/syllabuses/show.html.erb b/app/views/syllabuses/show.html.erb index 9b1bdafc5..062b9aeb4 100644 --- a/app/views/syllabuses/show.html.erb +++ b/app/views/syllabuses/show.html.erb @@ -53,7 +53,7 @@ <% comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3) %> <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'Syllabus'} %>
<% end %>
diff --git a/app/views/users/_all_replies.html.erb b/app/views/users/_all_replies.html.erb deleted file mode 100644 index a74acc77c..000000000 --- a/app/views/users/_all_replies.html.erb +++ /dev/null @@ -1,39 +0,0 @@ - \ No newline at end of file diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb index a4732af8c..1da4bc85e 100644 --- a/app/views/users/_news_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -76,6 +76,20 @@ :class => 'fr mr20', :title => l(:button_delete) ) if comment.user_id == User.current.id %> + <% elsif type == 'Syllabus' %> + + <%= link_to( + l(:button_reply), + {:controller => 'users', :action => 'reply_to', :reply_id => comment.id, :type => type}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if User.current.admin? || User.current == Syllabus.find(activity_id).user || comment.user == User.current%> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> <% end %>
diff --git a/app/views/users/_reply_banner.html.erb b/app/views/users/_reply_banner.html.erb index 43aebb89c..4f2094899 100644 --- a/app/views/users/_reply_banner.html.erb +++ b/app/views/users/_reply_banner.html.erb @@ -1,4 +1,4 @@ -
+
回复 ︿ diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index aa519a5da..24c1ce77a 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -82,6 +82,15 @@

<% end %> + <% elsif @type == 'Syllabus' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_syllabus', :id => reply.id},:method => "post", :remote => true) do |f| %> + +
+ + +
+

+ <% end%> <% end %>
diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index cc36ef3b3..d43768f1e 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -8,8 +8,6 @@ $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :p $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i, :homepage => @homepage}) %>'); <% elsif params[:type] == 'OrgDocumentComment' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>'); -<% elsif params[:type] == 'News' || params[:type] == 'Issue' %> +<% elsif params[:type] == 'News' || params[:type] == 'Issue' || params[:type] == 'Syllabus' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i}) %>'); -<% else %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); <% end %> diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index c527474cd..76ec9e319 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -1,6 +1,6 @@ <% if @journal_destroyed.nil? %> alert('<%=l(:notice_failed_delete)%>'); -<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon'].include? @journal_destroyed.jour_type)%> +<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon','Syllabus'].include? @journal_destroyed.jour_type)%> <% if @is_user%> <% if @activity %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); @@ -18,6 +18,9 @@ <% else %> <% if @bid && @jours_count %> $('#jours_count').html("<%= @jours_count %>"); + <% elsif @syllabus %> + $("#reply_banner_<%=@syllabus.id %>").replaceWith("<%=escape_javascript(render :partial => 'users/reply_banner', :locals => {:count => @count, :activity => @syllabus, :user_activity_id => @syllabus.id}) %>"); + $("#reply_div_<%=@syllabus.id %>").html("<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @comments, :type => 'Syllabus', :user_activity_id => @syllabus.id, :activity_id => @syllabus.id}) %>"); <% elsif @course && @jours_count%> <% if @user_activity_id %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); diff --git a/app/views/words/reply_to_syllabus.js.erb b/app/views/words/reply_to_syllabus.js.erb new file mode 100644 index 000000000..ece0843d4 --- /dev/null +++ b/app/views/words/reply_to_syllabus.js.erb @@ -0,0 +1,2 @@ +$("#reply_banner_<%=@syllabus.id %>").replaceWith("<%=escape_javascript(render :partial => 'users/reply_banner', :locals => {:count => @count, :activity => @syllabus, :user_activity_id => @syllabus.id}) %>"); +$("#reply_div_<%=@syllabus.id %>").html("<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @comments, :type => 'Syllabus'}) %>"); diff --git a/config/routes.rb b/config/routes.rb index 1124080b7..5439da9f4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1232,6 +1232,7 @@ RedmineApp::Application.routes.draw do post 'words/:id/leave_syllabus_message', :to => 'words#leave_syllabus_message', :as => "leave_syllabus_message" post 'words/:id/leave_homework_message', :to => 'words#leave_homework_message', :as => "leave_homework_message" post 'words/:id/reply_to_homework', :to => 'words#reply_to_homework', :as => "reply_to_homework" + post 'words/:id/reply_to_syllabus', :to => 'words#reply_to_syllabus', :as => "reply_to_syllabus" post 'join_in/join', :to => 'courses#join', :as => 'join' delete 'join_in/join', :to => 'courses#unjoin'