This commit is contained in:
commit
2a346b3906
|
@ -90,7 +90,7 @@ class Project < ActiveRecord::Base
|
|||
# end
|
||||
#ADDED BY NIE
|
||||
has_one :project_score, :dependent => :destroy
|
||||
has_many :project_infos, :dependent => :destroy
|
||||
has_many :project_infos, :dependent => :destroy
|
||||
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
|
||||
has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy
|
||||
#end
|
||||
|
@ -106,7 +106,7 @@ class Project < ActiveRecord::Base
|
|||
:order => "#{CustomField.table_name}.position",
|
||||
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
|
||||
:association_foreign_key => 'custom_field_id'
|
||||
|
||||
|
||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||
has_many :project_tags, :class_name => 'ProjectTags'
|
||||
# 动态级联删除
|
||||
|
@ -131,11 +131,11 @@ class Project < ActiveRecord::Base
|
|||
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
|
||||
:author => nil
|
||||
############################added by william
|
||||
acts_as_taggable
|
||||
acts_as_taggable
|
||||
scope :by_join_date, order("created_on DESC")
|
||||
###################added by liuping 关注
|
||||
acts_as_watchable
|
||||
|
||||
acts_as_watchable
|
||||
|
||||
attr_protected :status
|
||||
|
||||
validates_presence_of :name, :identifier
|
||||
|
@ -157,7 +157,7 @@ class Project < ActiveRecord::Base
|
|||
#ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用
|
||||
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
|
||||
# 创建project之后默认创建一个board,之后的board去掉了board的概念
|
||||
after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index
|
||||
after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index, :sync_projects_count_to_home
|
||||
before_destroy :delete_all_members,:delete_project_ealasticsearch_index
|
||||
after_update :update_project_ealasticsearch_index
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Project < ActiveRecord::Base
|
|||
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||
scope :all_public, lambda { where(:is_public => true) }
|
||||
scope :visible, lambda {|*args| where(Project.visible_condition(args.shift || User.current, *args)) }
|
||||
scope :allowed_to, lambda {|*args|
|
||||
scope :allowed_to, lambda {|*args|
|
||||
user = User.current
|
||||
permission = nil
|
||||
if args.first.is_a?(Symbol)
|
||||
|
@ -223,6 +223,10 @@ class Project < ActiveRecord::Base
|
|||
)
|
||||
end
|
||||
|
||||
def sync_projects_count_to_home
|
||||
HomesService.new.sync_count('project', 1)
|
||||
end
|
||||
|
||||
# 判断项目是否为实训项目
|
||||
def is_training_project?
|
||||
(!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false
|
||||
|
@ -265,7 +269,7 @@ class Project < ActiveRecord::Base
|
|||
pjfm.save
|
||||
pjfm
|
||||
end
|
||||
|
||||
|
||||
def self.add_new_jour(user, notes, id, options={})
|
||||
project = Project.find(id)
|
||||
if options.count == 0
|
||||
|
@ -844,7 +848,7 @@ class Project < ActiveRecord::Base
|
|||
'attachmenttype',
|
||||
'enterprise_name',
|
||||
'gpid'
|
||||
|
||||
|
||||
|
||||
|
||||
safe_attributes 'enabled_module_names',
|
||||
|
@ -1225,7 +1229,7 @@ class Project < ActiveRecord::Base
|
|||
def update_position_under_parent
|
||||
set_or_update_position_under(parent)
|
||||
end
|
||||
|
||||
|
||||
def course
|
||||
@course
|
||||
end
|
||||
|
@ -1258,7 +1262,7 @@ class Project < ActiveRecord::Base
|
|||
def create_board_sync
|
||||
@board = self.boards.build
|
||||
@board.name = " #{l(:label_borad_project) }"
|
||||
@board.description = self.name.to_s
|
||||
@board.description = self.name.to_s
|
||||
if @board.save
|
||||
logger.debug "[Project Model] ===> #{@board.to_json}"
|
||||
else
|
||||
|
@ -1310,4 +1314,3 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
#Project.where('is_public = 1').import :force=>true
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
class School < ActiveRecord::Base
|
||||
attr_accessible :name, :province,:pinyin
|
||||
after_create :sync_schools_count_to_home
|
||||
|
||||
has_many :courses
|
||||
|
||||
def to_s
|
||||
self.name.to_s
|
||||
end
|
||||
|
||||
def sync_schools_count_to_home
|
||||
HomesService.new.sync_count('school', 1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<li>
|
||||
<a href="https://www.trustie.net/">开源托管平台</a>
|
||||
<% if User.current.logged? %>
|
||||
<a href="<%= user_path(User.current) %>" target="_blank" class="rightline">开源托管平台</a>
|
||||
<% else %>
|
||||
<a href="<%= signin_url() %>" target="_blank" class="rightline">开源托管平台</a>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.educoder.net/" target="_blank">智能学习平台</a>
|
||||
|
|
Loading…
Reference in New Issue