Commit 9766d9cc1ea7ea5306e13d6dfc0882345f6fe406
Committed by
João M. M. da Silva
1 parent
7e0a47fa
Exists in
master
and in
29 other branches
[Mezuro] Started to refactor configuration model.
Showing
2 changed files
with
16 additions
and
13 deletions
Show diff stats
plugins/mezuro/lib/kalibro/configuration.rb
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
1 | 1 | class MezuroPlugin::ConfigurationContent < Article |
2 | 2 | validate_on_create :validate_kalibro_configuration_name |
3 | 3 | |
4 | - settings_items :description, :configuration_to_clone_name | |
4 | + settings_items :kalibro_id, :description, :configuration_to_clone_name | |
5 | 5 | |
6 | 6 | after_save :send_kalibro_configuration_to_service |
7 | 7 | after_destroy :remove_kalibro_configuration_from_service |
... | ... | @@ -23,29 +23,31 @@ class MezuroPlugin::ConfigurationContent < Article |
23 | 23 | |
24 | 24 | def kalibro_configuration |
25 | 25 | begin |
26 | - @kalibro_configuration ||= Kalibro::Configuration.find_by_name(self.name) | |
26 | + @kalibro_configuration ||= Kalibro::Configuration.find(self.kalibro_id) | |
27 | 27 | rescue Exception => exception |
28 | 28 | errors.add_to_base(exception.message) |
29 | 29 | end |
30 | 30 | @kalibro_configuration |
31 | 31 | end |
32 | 32 | |
33 | - def metric_configurations | |
34 | - kalibro_configuration.metric_configurations | |
35 | - end | |
33 | +# def metric_configurations | |
34 | +# kalibro_configuration.metric_configurations | |
35 | +# end | |
36 | 36 | |
37 | - def kalibro_configuration_names | |
37 | + def kalibro_configuration_names_and_ids | |
38 | + all_names_and_ids = {} | |
38 | 39 | begin |
39 | - all_configuration_names = Kalibro::Configuration.all_names | |
40 | - if all_configuration_names.nil? | |
41 | - ["None"] | |
42 | - else | |
43 | - ["None"] + all_configuration_names.sort | |
40 | + all_configurations = Kalibro::Configuration.all | |
41 | + if(!all_configurations.nil?) | |
42 | + all_configuration.each do |configuration| | |
43 | + all_names_and_ids[configuration.id] = configuration.name | |
44 | + end | |
44 | 45 | end |
45 | 46 | rescue Exception => exception |
46 | 47 | errors.add_to_base(exception.message) |
47 | - ["None"] | |
48 | 48 | end |
49 | + all_names_and_ids[-1] = "None" | |
50 | + all_names_and_ids | |
49 | 51 | end |
50 | 52 | |
51 | 53 | private | ... | ... |