课程大纲的删除和课程大纲描述的删除
This commit is contained in:
parent
25b5d74a42
commit
0ff8f0a774
|
@ -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
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<li class="homepageLeftMenuCoursesLine pr">
|
||||
<% 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 %>
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<br>
|
||||
<div style='width:470px;text-align:center;font-family: "微软雅黑","宋体"' class="f14">
|
||||
<% if @syllabus.courses.empty? %>
|
||||
确认删除该课程吗?
|
||||
<% else %>
|
||||
该课程下已经存在班级,不能删除。
|
||||
<% end %>
|
||||
</div>
|
||||
</br>
|
||||
<div style='width:164px; margin:0 auto; text-align:center; font-family: "微软雅黑","宋体"'>
|
||||
<% if @syllabus.courses.empty? %>
|
||||
<%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%>
|
||||
<a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>关闭</a>
|
||||
<% else %>
|
||||
<a href='javascript:void(0);' class='Blue-btn' style="margin-left: 50px;" onclick='hideModal()'>关闭</a>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,2 @@
|
|||
var htmlvalue = "<%=escape_javascript(render :partial => 'delete_syllabus') %>";
|
||||
pop_up_box(htmlvalue,500,30,50);
|
|
@ -45,9 +45,7 @@
|
|||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li><%=link_to '编辑', edit_syllabus_path(@syllabus), :class => 'postOptionLink'%></li>
|
||||
<% if @syllabus.courses.empty? %>
|
||||
<li><%=link_to '删除', syllabus_path(@syllabus), :class => 'postOptionLink', :method => 'delete', :data => {:confirm => l(:text_are_you_sure)}%></li>
|
||||
<% end %>
|
||||
<li><%=link_to '删除', delete_des_syllabus_path(@syllabus), :class => 'postOptionLink', :confirm => l(:text_are_you_sure)%></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -66,8 +66,20 @@
|
|||
</ul>
|
||||
</div><!--syllabus_class_box end-->
|
||||
|
||||
|
||||
<%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr',:target =>'_blank', :title => '查看课程' %>
|
||||
<div class="homepagePostSetting">
|
||||
<ul>
|
||||
<li class="icons_sy_setting">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li>
|
||||
<%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
|
||||
</li>
|
||||
<% if User.current == syllabus.user %>
|
||||
<li><%=link_to '删除', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue