リビジョン f0fa005d
| app/models/term.rb | ||
|---|---|---|
|
acts_as_attachable
|
||
|
|
||
|
acts_as_searchable :columns => ["#{table_name}.name", "#{table_name}.description"],
|
||
|
:include => [:project]
|
||
|
:project_key => [:project]
|
||
|
|
||
|
acts_as_event :title => Proc.new {|o| "#{l(:glossary_title)} ##{o.id}: #{o.name}" },
|
||
|
:description => Proc.new {|o| "#{o.description}"},
|
||
| ... | ... | |
|
:type => 'terms',
|
||
|
:url => Proc.new {|o| {:controller => 'glossary', :action => 'show', :id => o.project, :term_id => o.id} }
|
||
|
|
||
|
attr_accessible :project, :category_id, :author, :name, :name_en, :datatype, :codename, :description,
|
||
|
:rubi, :abbr_whole
|
||
|
|
||
|
def author
|
||
|
author_id ? User.find(:first, :conditions => "users.id = #{author_id}") : nil
|
||
|
author_id ? User.find_by(author_id) : nil
|
||
|
end
|
||
|
|
||
|
def updater
|
||
|
updater_id ? User.find(:first, :conditions => "users.id = #{updater_id}") : nil
|
||
|
updater_id ? User.find_by(updater_id) : nil
|
||
|
end
|
||
|
|
||
|
def project
|
||
|
Project.find(:first, :conditions => "projects.id = #{project_id}")
|
||
|
Project.find_by(project_id)
|
||
|
end
|
||
|
|
||
|
def datetime
|
||
| ... | ... | |
|
|
||
|
def self.find_for_macro(tname, proj, all_project = false)
|
||
|
if proj
|
||
|
term = Term.find(:first,
|
||
|
:conditions => "project_id = #{proj.id} and name = '#{tname}'")
|
||
|
term = Term.find_by(:project_id => proj.id, :name => tname)
|
||
|
return term if term
|
||
|
end
|
||
|
return nil unless all_project
|
||
updating for Redmine 3.0(Rails 4.2)