Revision 1286:d0d6bbe9f2e0 plugins/redmine_bibliography/app/models
| plugins/redmine_bibliography/app/models/authorship.rb | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
validates_presence_of :name_on_paper |
| 11 | 11 |
|
| 12 |
attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results
|
|
| 12 |
attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author
|
|
| 13 | 13 |
before_save :associate_author_user |
| 14 | 14 |
|
| 15 | 15 |
# todo: review usage of scope --lf.20130108 |
| ... | ... | |
| 43 | 43 |
|
| 44 | 44 |
protected |
| 45 | 45 |
def associate_author_user |
| 46 |
case self.identify_author
|
|
| 47 |
when "no"
|
|
| 46 |
case self.search_author_class
|
|
| 47 |
when "User"
|
|
| 48 | 48 |
author = Author.new |
| 49 | 49 |
author.save |
| 50 | 50 |
self.author_id = author.id |
| 51 | 51 |
else |
| 52 | 52 |
selected = self.search_results |
| 53 |
selected_classname = Kernel.const_get(selected.split('_')[0])
|
|
| 54 |
selected_id = selected.split('_')[1]
|
|
| 53 |
selected_classname = Kernel.const_get(self.search_author_class)
|
|
| 54 |
selected_id = self.search_author_id
|
|
| 55 | 55 |
object = selected_classname.find(selected_id) |
| 56 | 56 |
|
| 57 | 57 |
if object.respond_to? :name_on_paper |
Also available in: Unified diff