parent
a793b8923d
commit
b6c9415a4b
|
@ -62,6 +62,8 @@ class CoursesController < ApplicationController
|
||||||
course_status = CourseStatus.find_by_course_id(@course.id)
|
course_status = CourseStatus.find_by_course_id(@course.id)
|
||||||
course_status.destroy if course_status
|
course_status.destroy if course_status
|
||||||
elsif params[:course][:is_public] == '1'
|
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)
|
course_status = CourseStatus.create(:course_id => @course.id, :grade => 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -350,6 +352,7 @@ class CoursesController < ApplicationController
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
@courses=handle_course @courses_all, @course_activity_count
|
@courses=handle_course @courses_all, @course_activity_count
|
||||||
|
|
||||||
@s_type = 3
|
@s_type = 3
|
||||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
else
|
else
|
||||||
|
@ -500,7 +503,7 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
has = {
|
has = {
|
||||||
"show_files" => true,
|
"show_course_files" => true,
|
||||||
"show_messages" => true,
|
"show_messages" => true,
|
||||||
"show_bids" => true,
|
"show_bids" => true,
|
||||||
"show_contests" => true,
|
"show_contests" => true,
|
||||||
|
@ -516,11 +519,6 @@ class CoursesController < ApplicationController
|
||||||
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
||||||
events = @activity.events(@date_from, @date_to)
|
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})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@events_count = events.count
|
@events_count = events.count
|
||||||
@events_pages = Paginator.new @events_count, @limit, params['page']
|
@events_pages = Paginator.new @events_count, @limit, params['page']
|
||||||
|
|
|
@ -31,12 +31,20 @@ class Attachment < ActiveRecord::Base
|
||||||
validates_length_of :disk_filename, :maximum => 255
|
validates_length_of :disk_filename, :maximum => 255
|
||||||
validates_length_of :description, :maximum => 255
|
validates_length_of :description, :maximum => 255
|
||||||
validate :validate_max_file_size
|
validate :validate_max_file_size
|
||||||
acts_as_taggable
|
|
||||||
|
|
||||||
|
|
||||||
|
acts_as_taggable
|
||||||
acts_as_event :title => :filename,
|
acts_as_event :title => :filename,
|
||||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.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,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
|
|
|
@ -73,6 +73,10 @@ class Course < ActiveRecord::Base
|
||||||
user.allowed_to?(:view_course, self)
|
user.allowed_to?(:view_course, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parent_id_changed?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
# 课程的短描述信息
|
# 课程的短描述信息
|
||||||
def short_description(length = 255)
|
def short_description(length = 255)
|
||||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||||
|
|
|
@ -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}))")
|
or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))")
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def act_as_activity
|
def act_as_activity
|
||||||
if self.jour_type == 'Principal'
|
if self.jour_type == 'Principal'
|
||||||
unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0
|
unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
<table width="580px" border="0">
|
<table width="580px" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top">
|
<td colspan="2" valign="top">
|
||||||
<%= test=e.course%>
|
<strong> <%= h(e.event_title) if @course.nil? || (e.course != nil && @course.id != e.course.id) %></strong>
|
||||||
<strong> <%= h(e.course) if @course.nil? || (e.course != nil && @course.id != e.course.id) %></strong>
|
|
||||||
<span class="font_lighter">
|
<span class="font_lighter">
|
||||||
<% if @canShowRealName %>
|
<% 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) %>)
|
<%= 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) %> </span>
|
<%= l(:label_new_activity) %> </span>
|
||||||
|
|
||||||
<%= 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 %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<%= select_tag "version_id", content_tag('option', '') +
|
<%= select_tag "version_id", content_tag('option', '') +
|
||||||
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
|
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
|
||||||
</td>
|
</td>
|
||||||
|
<% else %>
|
||||||
|
<td><p></p></td> <td></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if attachmenttypes.any? %>
|
<% if attachmenttypes.any? %>
|
||||||
|
|
|
@ -44,6 +44,7 @@ class AddCourseRoles < ActiveRecord::Migration
|
||||||
role.permissions.append(:view_course )
|
role.permissions.append(:view_course )
|
||||||
role.permissions.append(:search_course )
|
role.permissions.append(:search_course )
|
||||||
end
|
end
|
||||||
|
role.permissions.append(:view_course_files )
|
||||||
role.save
|
role.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -110,7 +110,7 @@ Redmine::AccessControl.map do |map|
|
||||||
|
|
||||||
map.course_module :files do |map|
|
map.course_module :files do |map|
|
||||||
map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
|
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
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
@ -408,6 +408,7 @@ Redmine::Activity.map do |activity|
|
||||||
activity.register :news
|
activity.register :news
|
||||||
activity.register :documents, :class_name => %w(Document Attachment)
|
activity.register :documents, :class_name => %w(Document Attachment)
|
||||||
activity.register :files, :class_name => '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 :wiki_edits, :class_name => 'WikiContent::Version', :default => false
|
||||||
activity.register :messages, :default => false
|
activity.register :messages, :default => false
|
||||||
activity.register :time_entries, :default => false
|
activity.register :time_entries, :default => false
|
||||||
|
|
Loading…
Reference in New Issue