1 # $Id$ |
2 # To change this template, choose Tools | Templates |
3 # and open the template in the editor. |
4 |
5 class HudsonSettings < ActiveRecord::Base |
6 unloadable |
7 has_many :health_report_settings, :class_name => 'HudsonSettingsHealthReport', :dependent => :destroy |
8 |
9 # ��������������������������� |
10 validates_presence_of :project_id, :url |
11 |
12 # ��������������������������� |
13 validates_uniqueness_of :project_id |
14 |
15 DELIMITER = ',' |
16 |
17 def use_authentication? |
18 return false unless self.auth_user |
19 return false unless self.auth_user.length > 0 |
20 return true |
21 end |
22 |
23 def job_include?(other) |
24 return false if self.job_filter == nil |
25 value = HudsonSettings.to_array( self.job_filter ) |
26 return value.include?(other.to_s) |
27 end |
28 |
29 def url_for(type) |
30 return self.url_for_plugin if type == :plugin and self.url_for_plugin and self.url_for_plugin.length > 0 |
31 return self.url |
32 end |
33 |
34 # ������������������������������������������begin, end ������������������������������������������ |
35 @@HUMANIZED_ATTRIBUTE_KEY_NAMES = { |
36 "health_report_settings" => l(:label_health_report_settings) |
37 } |
38 |
39 # attribute_key_name ���������������������������������������������������������ActiveRecord ��������������������������������������������������������� |
40 def HudsonSettings.human_attribute_name(attribute_key_name) |
41 @@HUMANIZED_ATTRIBUTE_KEY_NAMES[attribute_key_name] || super |
42 end |
43 end |
44 |
45 def HudsonSettings.add_last_slash_to_url(url) |
46 retval = url |
47 return "" unless retval |
48 return "" if retval.length == 0 |
49 retval += "/" unless retval.index(/\/$/) |
50 return retval |
51 end |
52 |
53 def HudsonSettings.find_by_project_id(project_id) |
54 retval = HudsonSettings.find(:first, :conditions => "project_id = #{project_id}") |
55 retval = HudsonSettings.new() if retval == nil |
56 return retval |
57 end |
58 |
59 def HudsonSettings.to_array(value) |
60 return [] if value == nil |
61 return value.split(HudsonSettings::DELIMITER) |
62 end |
63 |
64 def HudsonSettings.to_value(value) |
65 return "" if value == nil |
66 return value.join(HudsonSettings::DELIMITER) |
67 end |