修改words_controller与课程相关方法及视图
This commit is contained in:
parent
517a29116f
commit
165dbc3f78
|
@ -2,6 +2,7 @@ class CoursesController < ApplicationController
|
||||||
include CoursesHelper
|
include CoursesHelper
|
||||||
helper :activities
|
helper :activities
|
||||||
helper :members
|
helper :members
|
||||||
|
helper :words
|
||||||
|
|
||||||
menu_item l(:label_sort_by_time), :only => :index
|
menu_item l(:label_sort_by_time), :only => :index
|
||||||
menu_item l(:label_sort_by_active), :only => :index
|
menu_item l(:label_sort_by_active), :only => :index
|
||||||
|
@ -566,9 +567,8 @@ class CoursesController < ApplicationController
|
||||||
@offset ||= @feedback_pages.offset
|
@offset ||= @feedback_pages.offset
|
||||||
@jour = @jours[@offset, @limit]
|
@jour = @jours[@offset, @limit]
|
||||||
@state = false
|
@state = false
|
||||||
@base_courses_tag = @course.course_type
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
format.html{render :layout => 'base_courses'}
|
||||||
format.api
|
format.api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,6 +164,20 @@ class WordsController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
def leave_course_message
|
||||||
|
user = User.current
|
||||||
|
message = params[:new_form][:course_message]
|
||||||
|
feedback = Course.add_new_jour(user, message, params[:id])
|
||||||
|
if(feedback.errors.empty?)
|
||||||
|
redirect_to course_feedback_path(params[:id]), notice: l(:label_feedback_success)
|
||||||
|
else
|
||||||
|
flash[:error] = feedback.errors.full_messages[0]
|
||||||
|
redirect_to course_feedback_path(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def add_brief_introdution
|
def add_brief_introdution
|
||||||
user = User.current
|
user = User.current
|
||||||
message = params[:new_form][:user_introduction]
|
message = params[:new_form][:user_introduction]
|
||||||
|
@ -182,10 +196,14 @@ class WordsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def obj_distinguish_url_origin
|
def obj_distinguish_url_origin
|
||||||
|
#modify by nwb
|
||||||
|
#添加对课程留言的支持
|
||||||
referer = request.headers["Referer"]
|
referer = request.headers["Referer"]
|
||||||
obj_id = referer.match(%r(/([0-9]{1,})(/|$)))[1]
|
obj_id = referer.match(%r(/([0-9]{1,})(/|$)))[1]
|
||||||
if referer.match(/project/)
|
if referer.match(/project/)
|
||||||
obj = Project.find_by_id(obj_id)
|
obj = Project.find_by_id(obj_id)
|
||||||
|
elsif referer.match(/course/)
|
||||||
|
obj = Course.find_by_id(obj_id)
|
||||||
elsif referer.match(/user/)
|
elsif referer.match(/user/)
|
||||||
obj = User.find_by_id(obj_id)
|
obj = User.find_by_id(obj_id)
|
||||||
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
||||||
|
@ -203,11 +221,15 @@ class WordsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_reply_adapter options
|
def add_reply_adapter options
|
||||||
|
#modify by nwb
|
||||||
|
#添加对课程留言的支持
|
||||||
obj = obj_distinguish_url_origin
|
obj = obj_distinguish_url_origin
|
||||||
if obj.kind_of? User
|
if obj.kind_of? User
|
||||||
obj.add_jour(nil, nil, nil, options)
|
obj.add_jour(nil, nil, nil, options)
|
||||||
elsif obj.kind_of? Project
|
elsif obj.kind_of? Project
|
||||||
Project.add_new_jour(nil, nil, obj.id, options)
|
Project.add_new_jour(nil, nil, obj.id, options)
|
||||||
|
elsif obj.kind_of? Course
|
||||||
|
Course.add_new_jour(nil, nil, obj.id, options)
|
||||||
elsif obj.kind_of? Bid
|
elsif obj.kind_of? Bid
|
||||||
obj.add_jour(nil, nil, nil, options)
|
obj.add_jour(nil, nil, nil, options)
|
||||||
elsif obj.kind_of? Contest
|
elsif obj.kind_of? Contest
|
||||||
|
|
|
@ -25,7 +25,8 @@ class Course < ActiveRecord::Base
|
||||||
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
||||||
has_many :enabled_modules, :dependent => :delete_all
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||||
has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy
|
#has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy
|
||||||
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :news, :dependent => :destroy, :include => :author
|
has_many :news, :dependent => :destroy, :include => :author
|
||||||
|
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
|
@ -161,7 +162,7 @@ class Course < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 创建课程留言
|
# 创建课程讨论区
|
||||||
def create_board_sync
|
def create_board_sync
|
||||||
@board = self.boards.build
|
@board = self.boards.build
|
||||||
self.name=" #{l(:label_borad_course) }"
|
self.name=" #{l(:label_borad_course) }"
|
||||||
|
@ -175,6 +176,19 @@ class Course < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 新增课程留言
|
||||||
|
# add by nwb
|
||||||
|
def self.add_new_jour(user, notes, id, options={})
|
||||||
|
course = Course.find(id)
|
||||||
|
if options.count == 0
|
||||||
|
pjfm = course.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||||
|
else
|
||||||
|
pjfm = course.journals_for_messages.build(options)
|
||||||
|
end
|
||||||
|
pjfm.save
|
||||||
|
pjfm
|
||||||
|
end
|
||||||
|
|
||||||
# 删除课程所有成员
|
# 删除课程所有成员
|
||||||
def delete_all_members
|
def delete_all_members
|
||||||
me, mr = Member.table_name, MemberRole.table_name
|
me, mr = Member.table_name, MemberRole.table_name
|
||||||
|
|
|
@ -36,7 +36,7 @@ function checkMaxLength() {
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||||
<% if jour.size >0 %>
|
<% if jour && jour.size >0 %>
|
||||||
<% remove_allowed = (User.current.id == jour.first.user_id) %>
|
<% remove_allowed = (User.current.id == jour.first.user_id) %>
|
||||||
<ul class="message-for-user">
|
<ul class="message-for-user">
|
||||||
<% for journal in jour%>
|
<% for journal in jour%>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<% if @journal_destroyed.nil? %>
|
<% if @journal_destroyed.nil? %>
|
||||||
alert('<%=l(:notice_failed_delete)%>');
|
alert('<%=l(:notice_failed_delete)%>');
|
||||||
<% elsif (['Principal','Project', 'Bid', 'Contest', 'Softapplication'].include? @journal_destroyed.jour_type)%>
|
<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication'].include? @journal_destroyed.jour_type)%>
|
||||||
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
|
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
|
||||||
destroyedItem.fadeOut(600,function(){
|
destroyedItem.fadeOut(600,function(){
|
||||||
destroyedItem.remove();
|
destroyedItem.remove();
|
||||||
|
|
|
@ -571,9 +571,7 @@ RedmineApp::Application.routes.draw do
|
||||||
end # end of resources :courses
|
end # end of resources :courses
|
||||||
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'
|
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'
|
||||||
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
||||||
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
match 'words/:id/leave_course_message', :controller => 'words', :action => 'leave_course_message'
|
||||||
#match 'project/course_enterprise', :to => 'projects#course_enterprise'
|
|
||||||
#match 'project/course', :to => 'projects#course', :as => 'course'
|
|
||||||
|
|
||||||
|
|
||||||
match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
|
match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
|
||||||
|
|
Loading…
Reference in New Issue