RE: Writing plugins compatible with both Redmine 1.x and ... » issue_patch.rb
1 |
require_dependency 'issue' |
---|---|
2 |
|
3 |
module Redmine_tlcit |
4 |
module IssuePatch |
5 |
|
6 |
def self.included(base) # :nodoc: |
7 |
base.send(:include, InstanceMethods) |
8 |
|
9 |
base.class_eval do |
10 |
unloadable
|
11 |
#inserire qui relazioni
|
12 |
has_many :impacts, :dependent => :destroy |
13 |
belongs_to :assigned_to_group, :class_name => 'Group', :foreign_key => 'assigned_to_id' |
14 |
belongs_to :impacted_by, :class_name => 'Impact', :foreign_key => 'impacted_by_id', :dependent => :destroy |
15 |
|
16 |
has_many :releasecompositionimpacts, :foreign_key => 'issue_release_id', :class_name => 'Releasecomposition', :dependent => :destroy |
17 |
has_many :issue_impacts, :through => :releasecompositionimpacts |
18 |
has_many :releasecompositionreleases, :foreign_key => 'issue_impact_id', :class_name => 'Releasecomposition', :dependent => :destroy |
19 |
has_many :issue_releases, :through => :releasecompositionreleases |
20 |
alias_method_chain :validate, :impact |
21 |
end
|
22 |
end
|
23 |
|
24 |
module InstanceMethods |
25 |
def validate_with_impact |
26 |
validate_without_impact
|
27 |
if self.assigned_to_id.nil? and self.tracker_id == Integer(Setting.plugin_redmine_tlcit['id_tracker_impact']) |
28 |
errors.add :assigned_to_id, " e' un campo obbligatorio per la scheda Impatto" |
29 |
end
|
30 |
end
|
31 |
|
32 |
end
|
33 |
end
|
34 |
end
|
35 |
|
36 |
Issue.send(:include, Redmine_tlcit::IssuePatch) |
- « Previous
- 1
- 2
- Next »