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 @@
- <%=link_to '编辑', edit_syllabus_path(@syllabus), :class => 'postOptionLink'%>
- <% if @syllabus.courses.empty? %>
- - <%=link_to '删除', syllabus_path(@syllabus), :class => 'postOptionLink', :method => 'delete', :data => {:confirm => l(:text_are_you_sure)}%>
- <% end %>
+ - <%=link_to '删除', delete_des_syllabus_path(@syllabus), :class => 'postOptionLink', :confirm => l(:text_are_you_sure)%>
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 => '查看课程' %>
+
+
+ -
+
+ -
+ <%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
+
+ <% if User.current == syllabus.user %>
+ - <%=link_to '删除', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%>
+ <% end %>
+
+
+
+
<% 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");