Commit 333ddfad3108a35d03683434a54660e20716c2b5
Committed by
Paulo Meireles
1 parent
3fde094d
Exists in
master
and in
22 other branches
Displaying a 'new kalibro configuration' page
Showing
3 changed files
with
67 additions
and
2 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin.rb
| @@ -9,7 +9,8 @@ class MezuroPlugin < Noosfero::Plugin | @@ -9,7 +9,8 @@ class MezuroPlugin < Noosfero::Plugin | ||
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | def content_types | 11 | def content_types |
| 12 | - MezuroPlugin::ProjectContent | 12 | + [MezuroPlugin::ProjectContent, |
| 13 | + MezuroPlugin::KalibroConfiguration] | ||
| 13 | end | 14 | end |
| 14 | 15 | ||
| 15 | def stylesheet? | 16 | def stylesheet? |
| @@ -20,4 +21,4 @@ class MezuroPlugin < Noosfero::Plugin | @@ -20,4 +21,4 @@ class MezuroPlugin < Noosfero::Plugin | ||
| 20 | ['javascripts/results.js', 'javascripts/toogle.js'] | 21 | ['javascripts/results.js', 'javascripts/toogle.js'] |
| 21 | end | 22 | end |
| 22 | 23 | ||
| 23 | -end | ||
| 24 | \ No newline at end of file | 24 | \ No newline at end of file |
| 25 | +end |
plugins/mezuro/lib/mezuro_plugin/kalibro_configuration.rb
0 → 100644
| @@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
| 1 | +class MezuroPlugin::KalibroConfiguration < Article | ||
| 2 | + | ||
| 3 | + def self.short_description | ||
| 4 | + 'Kalibro configuration' | ||
| 5 | + end | ||
| 6 | + | ||
| 7 | + def self.description | ||
| 8 | + 'Kalibro configuration for some project' | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + settings_items :description | ||
| 12 | + | ||
| 13 | + include ActionView::Helpers::TagHelper | ||
| 14 | + def to_html(options = {}) | ||
| 15 | + lambda do | ||
| 16 | + render :file => 'content_viewer/show_configuration.rhtml' | ||
| 17 | + end | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + def configuration | ||
| 21 | + Kalibro::Client::ConfigurationClient.new.configuration(title) | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + after_save :send_configuration_to_service | ||
| 25 | + after_destroy :remove_configuration_from_service | ||
| 26 | + | ||
| 27 | + private | ||
| 28 | + | ||
| 29 | + def send_configuration_to_service | ||
| 30 | + Kalibro::Client::ConfigurationClient.save(create_configuration) | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + def remove_configuration_from_service | ||
| 34 | + Kalibro::Client::ConfigurationClient.remove(title) | ||
| 35 | + end | ||
| 36 | + | ||
| 37 | + def create_configuration | ||
| 38 | + configuration = Kalibro::Entities::Configuration.new | ||
| 39 | + configuration.name = title | ||
| 40 | + configuration.description = description | ||
| 41 | + configuration | ||
| 42 | + end | ||
| 43 | + | ||
| 44 | +end |
plugins/mezuro/views/cms/mezuro_plugin/_kalibro_configuration.html.erb
0 → 100644
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +<h1> <%= _(MezuroPlugin::KalibroConfiguration.short_description) %> </h1> | ||
| 2 | + | ||
| 3 | +<% | ||
| 4 | + begin | ||
| 5 | + @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title) | ||
| 6 | + rescue | ||
| 7 | + @configuration = nil | ||
| 8 | + end | ||
| 9 | +%> | ||
| 10 | + | ||
| 11 | +<%= error_messages_for 'kalibro_configuration' %> | ||
| 12 | + | ||
| 13 | +<%= hidden_field_tag 'kalibro_configuration[profile_id]', profile.id %> | ||
| 14 | +<%= hidden_field_tag 'id', @article.id %> | ||
| 15 | + | ||
| 16 | +<%= required_fields_message %> | ||
| 17 | + | ||
| 18 | +<%= required f.text_field(:name) %> | ||
| 19 | + | ||
| 20 | +<%= f.text_field :description %><br/> |