diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 312af97b..25a82625 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -62,6 +62,8 @@ class CoursesController < ApplicationController course_status = CourseStatus.find_by_course_id(@course.id) course_status.destroy if course_status elsif params[:course][:is_public] == '1' + course_status = CourseStatus.find_by_course_id(@course.id) + course_status.destroy if course_status course_status = CourseStatus.create(:course_id => @course.id, :grade => 0) end @@ -350,6 +352,7 @@ class CoursesController < ApplicationController #gcmend @courses=handle_course @courses_all, @course_activity_count + @s_type = 3 @courses = @courses[@course_pages.offset, @course_pages.per_page] else @@ -500,7 +503,7 @@ class CoursesController < ApplicationController end has = { - "show_files" => true, + "show_course_files" => true, "show_messages" => true, "show_bids" => true, "show_contests" => true, @@ -516,11 +519,6 @@ class CoursesController < ApplicationController @activity.scope_select {|t| !has["show_#{t}"].nil?} events = @activity.events(@date_from, @date_to) - # @activity = Activity.where("update_on between " +@date_from.to_s + " and " +@date_to.to_s ).order('id desc') - #@activity_count = @activity.count - #@activity_pages = Paginator.new @activity_count, pre_count, params['page'] - # @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all - @offset, @limit = api_offset_and_limit({:limit => 10}) @events_count = events.count @events_pages = Paginator.new @events_count, @limit, params['page'] diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 65e3fe26..9cc56b19 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -31,12 +31,20 @@ class Attachment < ActiveRecord::Base validates_length_of :disk_filename, :maximum => 255 validates_length_of :description, :maximum => 255 validate :validate_max_file_size - acts_as_taggable + + acts_as_taggable acts_as_event :title => :filename, :url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}} - acts_as_activity_provider :type => 'files', + + acts_as_activity_provider :type => 'course_files', + :permission => :view_files, + :author_key => :author_id, + :find_options => {:select => "#{Attachment.table_name}.*", + :joins => "LEFT JOIN #{Course.table_name} ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"} + + acts_as_activity_provider :type => 'files', :permission => :view_files, :author_key => :author_id, :find_options => {:select => "#{Attachment.table_name}.*", diff --git a/app/models/course.rb b/app/models/course.rb index b63b56c4..eedc0dff 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -73,6 +73,10 @@ class Course < ActiveRecord::Base user.allowed_to?(:view_course, self) end + def parent_id_changed? + false + end + # 课程的短描述信息 def short_description(length = 255) description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description diff --git a/app/models/course_journals_for_message.rb b/app/models/course_journals_for_message.rb index 4d5f3f92..32bf8ffa 100644 --- a/app/models/course_journals_for_message.rb +++ b/app/models/course_journals_for_message.rb @@ -82,7 +82,8 @@ class CourseJournalsForMessage < ActiveRecord::Base or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))") message end - + + def act_as_activity if self.jour_type == 'Principal' unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0 diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index cf5cc13b..a40ace38 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -16,8 +16,7 @@ diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index a1cfb37e..27bd4911 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -13,6 +13,8 @@ <%= select_tag "version_id", content_tag('option', '') + options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %> + <% else %> + <% end %> <% if attachmenttypes.any? %> diff --git a/db/migrate/20140606028512_add_course_roles.rb b/db/migrate/20140606028512_add_course_roles.rb index 68991b52..f56a5aa7 100644 --- a/db/migrate/20140606028512_add_course_roles.rb +++ b/db/migrate/20140606028512_add_course_roles.rb @@ -44,6 +44,7 @@ class AddCourseRoles < ActiveRecord::Migration role.permissions.append(:view_course ) role.permissions.append(:search_course ) end + role.permissions.append(:view_course_files ) role.save end end diff --git a/lib/redmine.rb b/lib/redmine.rb index 0a4dbd52..78088f08 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -110,7 +110,7 @@ Redmine::AccessControl.map do |map| map.course_module :files do |map| map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin - map.permission :view_files, {:files => :index, :versions => :download}, :read => true + map.permission :view_course_files, {:files => :index, :versions => :download}, :read => true end #end @@ -408,6 +408,7 @@ Redmine::Activity.map do |activity| activity.register :news activity.register :documents, :class_name => %w(Document Attachment) activity.register :files, :class_name => 'Attachment' + activity.register :course_files, :class_name => 'Attachment' activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false activity.register :messages, :default => false activity.register :time_entries, :default => false
- <%= test=e.course%> - <%= h(e.course) if @course.nil? || (e.course != nil && @course.id != e.course.id) %> + <%= h(e.event_title) if @course.nil? || (e.course != nil && @course.id != e.course.id) %> <% if @canShowRealName %> <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>) @@ -27,7 +26,7 @@ <%= l(:label_new_activity) %> - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(course)) ? course_files_path(e.container) : e.event_url %> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>