diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index b1d7bf32d..8ff88823d 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -5,8 +5,8 @@ class SyllabusesController < ApplicationController include AttachmentsHelper include CoursesHelper - before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy] - before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info] + before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus] + before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info, :delete_syllabus, :delete_des] def index user = User.current @syllabuses = user.syllabuses @@ -32,7 +32,7 @@ class SyllabusesController < ApplicationController @syllabus.title = params[:title] @syllabus.eng_name = params[:eng_name] @syllabus.user_id = User.current.id - @syllabus.description = Message.where("id = 17848").first.nil? ? '' : Message.where("id = 17848").first.content + @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content if @syllabus && @syllabus.save respond_to do |format| flash[:notice] = l(:notice_successful_create) @@ -55,6 +55,12 @@ class SyllabusesController < ApplicationController end end + def delete_syllabus + respond_to do |format| + format.js + end + end + def update @syllabus.description = params[:syllabus][:description] @syllabus.des_status = 1 @@ -71,10 +77,21 @@ class SyllabusesController < ApplicationController end #删除课程大纲的描述 + def delete_des + if @syllabus + @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content + @syllabus.des_status = 0 + @syllabus.attachments.destroy_all + if @syllabus.save + redirect_to syllabus_path(@syllabus) + end + end + end + def destroy if @syllabus && @syllabus.courses.empty? @syllabus.destroy - redirect_to user_path(User.current.id) + redirect_to user_courselist_user_path(User.current.id) end end diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 6388b94d0..31f06689d 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -2,7 +2,7 @@
  • <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", - :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+"("+current_time_and_term(course)+")"%> + :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> diff --git a/app/views/syllabuses/_delete_syllabus.html.erb b/app/views/syllabuses/_delete_syllabus.html.erb new file mode 100644 index 000000000..fbc0a0995 --- /dev/null +++ b/app/views/syllabuses/_delete_syllabus.html.erb @@ -0,0 +1,17 @@ +
    +
    + <% if @syllabus.courses.empty? %> + 确认删除该课程吗? + <% else %> + 该课程下已经存在班级,不能删除。 + <% end %> +
    +
    +
    + <% if @syllabus.courses.empty? %> + <%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%> + 关闭 + <% else %> + 关闭 + <% end %> +
    \ No newline at end of file diff --git a/app/views/syllabuses/delete_syllabus.js.erb b/app/views/syllabuses/delete_syllabus.js.erb new file mode 100644 index 000000000..e764aa80b --- /dev/null +++ b/app/views/syllabuses/delete_syllabus.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%=escape_javascript(render :partial => 'delete_syllabus') %>"; +pop_up_box(htmlvalue,500,30,50); \ No newline at end of file diff --git a/app/views/syllabuses/show.html.erb b/app/views/syllabuses/show.html.erb index e64343d90..e3e6436b4 100644 --- a/app/views/syllabuses/show.html.erb +++ b/app/views/syllabuses/show.html.erb @@ -45,9 +45,7 @@
  • diff --git a/app/views/users/_user_syllabus_list.html.erb b/app/views/users/_user_syllabus_list.html.erb index 3cc7bf61c..143b21681 100644 --- a/app/views/users/_user_syllabus_list.html.erb +++ b/app/views/users/_user_syllabus_list.html.erb @@ -66,8 +66,20 @@ - - <%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr',:target =>'_blank', :title => '查看课程' %> +
    + +
    <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index a491726f2..215267cb8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1078,6 +1078,8 @@ RedmineApp::Application.routes.draw do match 'syllabus_courselist', :to => 'syllabuses#syllabus_courselist', :via => :get, :as => 'syllabus_courselist' get 'edit_syllabus_eng_name' post 'update_base_info' + get 'delete_syllabus' + get 'delete_des' end collection do diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c67efb191..142b0be42 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1545,6 +1545,17 @@ function show_edit_file_description(id) { $("#file_description_edit_"+id).focus(); } +//编辑资源描述之后提交 +function edit_file_description(url,id){ + $.get( + url, + {id: id ,description: $("#file_description_edit_"+id).val() }, + function (data) { + + } + ); +} + //展开课程大纲列表中的班级 function expand_course_list(id, target, btnid, count) { var target = $(target); diff --git a/public/javascripts/syllabus.js b/public/javascripts/syllabus.js index f65ddf11b..1b2a18a41 100644 --- a/public/javascripts/syllabus.js +++ b/public/javascripts/syllabus.js @@ -48,17 +48,6 @@ function edit_syllabus_eng_name(url){ ); } -//编辑资源描述之后提交 -function edit_file_description(url,id){ - $.get( - url, - {id: id ,description: $("#file_description_edit_"+id).val() }, - function (data) { - - } - ); -} - //展开所有属性 function toggle_all_syllabus_attr(){ var btn = $("#show_all_syllabus_attr");