From 97d920c195372eeea45aca1c6e5c24c7416ebf1b Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 12 Jun 2014 09:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=80=9A=E7=9F=A5=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 ++ app/models/course.rb | 7 +++++-- app/views/news/_course_form.html.erb | 13 +++++++++++++ app/views/news/_course_news.html.erb | 2 +- lib/redmine.rb | 10 ++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 app/views/news/_course_form.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 46fc68184..fb7bf50f0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -321,6 +321,8 @@ class ApplicationController < ActionController::Base render_404 end + #added by nwb + #获取课程 def find_course @course= Course.find(params[:id]) rescue ActiveRecord::RecordNotFound diff --git a/app/models/course.rb b/app/models/course.rb index 545330705..ff4f1a222 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -95,8 +95,7 @@ class Course < ActiveRecord::Base allowed_to_condition(user, :view_course, options) end - - # 获取课程的资源类型列表 + # 获取课程的资源类型列表 def attachmenttypes @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) end @@ -131,6 +130,7 @@ class Course < ActiveRecord::Base end end + # 课程允许的权限集合 def allowed_permissions @allowed_permissions ||= begin module_names = enabled_modules.all(:select => :name).collect {|m| m.name} @@ -138,6 +138,7 @@ class Course < ActiveRecord::Base end end + # 课程允许的动作集合 def allowed_actions @actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten end @@ -160,6 +161,7 @@ class Course < ActiveRecord::Base end end + # 创建课程留言 def create_board_sync @board = self.boards.build self.name=" #{l(:label_borad_course) }" @@ -173,6 +175,7 @@ class Course < ActiveRecord::Base end end + # 删除课程所有成员 def delete_all_members me, mr = Member.table_name, MemberRole.table_name connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})") diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb new file mode 100644 index 000000000..6e3060c3c --- /dev/null +++ b/app/views/news/_course_form.html.erb @@ -0,0 +1,13 @@ +<%= error_messages_for @news %> +
+ <% str = l(:bale_news_notice)%> + <%= str %> +
+
+

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

+ +

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

+

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

+
+ +<%= wikitoolbar_for 'news_description' %> diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index d980cbacf..60d0f0ed3 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -15,7 +15,7 @@