Commit 0473aedaa9f782095ca623c28eaf364d4f628f0c
Committed by
Alessandro Palmeira
1 parent
caf44d7d
Exists in
master
and in
28 other branches
[Mezuro] Updated project_content and its views.
Showing
3 changed files
with
2 additions
and
118 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin/project_content.rb
| @@ -3,8 +3,6 @@ class MezuroPlugin::ProjectContent < Article | @@ -3,8 +3,6 @@ class MezuroPlugin::ProjectContent < Article | ||
| 3 | 3 | ||
| 4 | settings_items :project_id | 4 | settings_items :project_id |
| 5 | 5 | ||
| 6 | - validate_on_create :validate_repository_address | ||
| 7 | - | ||
| 8 | def self.short_description | 6 | def self.short_description |
| 9 | 'Mezuro project' | 7 | 'Mezuro project' |
| 10 | end | 8 | end |
| @@ -38,50 +36,6 @@ class MezuroPlugin::ProjectContent < Article | @@ -38,50 +36,6 @@ class MezuroPlugin::ProjectContent < Article | ||
| 38 | @repositories | 36 | @repositories |
| 39 | end | 37 | end |
| 40 | 38 | ||
| 41 | - def processing(repository_id) | ||
| 42 | - begin | ||
| 43 | - if Kalibro::Processing.has_ready_processing(repository_id) | ||
| 44 | - @processing ||= Kalibro::Processing.last_ready_processing_of(repository_id) | ||
| 45 | - else | ||
| 46 | - @processing = Kalibro::Processing.last_processing_of(repository_id) | ||
| 47 | - end | ||
| 48 | - rescue Exception => error | ||
| 49 | - errors.add_to_base(error.message) | ||
| 50 | - end | ||
| 51 | - @processing | ||
| 52 | - end | ||
| 53 | - | ||
| 54 | - def processing_with_date(repository_id, date) | ||
| 55 | - begin | ||
| 56 | - if Kalibro::Processing.has_processing_after(repository_id, date) | ||
| 57 | - @processing ||= Kalibro::Processing.first_processing_after(repository_id, date) | ||
| 58 | - elsif Kalibro::Processing.has_processing_before(repository_id, date) | ||
| 59 | - @processing ||= Kalibro::Processing.last_processing_before(repository_id, date) | ||
| 60 | - end | ||
| 61 | - rescue Exception => error | ||
| 62 | - errors.add_to_base(error.message) | ||
| 63 | - end | ||
| 64 | - @processing | ||
| 65 | - end | ||
| 66 | - | ||
| 67 | - def module_result(repository_id, date = nil) | ||
| 68 | - @processing ||= date.nil? ? processing(repository_id) : processing_with_date(repository_id, date) | ||
| 69 | - begin | ||
| 70 | - @module_result ||= Kalibro::ModuleResult.find(@processing.results_root_id) | ||
| 71 | - rescue Exception => error | ||
| 72 | - errors.add_to_base(error.message) | ||
| 73 | - end | ||
| 74 | - @module_result | ||
| 75 | - end | ||
| 76 | - | ||
| 77 | - def result_history(module_result_id) | ||
| 78 | - begin | ||
| 79 | - @result_history ||= Kalibro::MetricResult.history_of(module_result_id) | ||
| 80 | - rescue Exception => error | ||
| 81 | - errors.add_to_base(error.message) | ||
| 82 | - end | ||
| 83 | - end | ||
| 84 | - | ||
| 85 | def description=(value) | 39 | def description=(value) |
| 86 | @description=value | 40 | @description=value |
| 87 | end | 41 | end |
| @@ -95,7 +49,7 @@ class MezuroPlugin::ProjectContent < Article | @@ -95,7 +49,7 @@ class MezuroPlugin::ProjectContent < Article | ||
| 95 | @repositories = @repositories.map { |element| to_repository(element) } | 49 | @repositories = @repositories.map { |element| to_repository(element) } |
| 96 | end | 50 | end |
| 97 | 51 | ||
| 98 | - after_save :send_project_to_service | 52 | + before_save :send_project_to_service |
| 99 | after_destroy :destroy_project_from_service | 53 | after_destroy :destroy_project_from_service |
| 100 | 54 | ||
| 101 | private | 55 | private |
| @@ -119,13 +73,11 @@ class MezuroPlugin::ProjectContent < Article | @@ -119,13 +73,11 @@ class MezuroPlugin::ProjectContent < Article | ||
| 119 | 73 | ||
| 120 | def send_project_to_service | 74 | def send_project_to_service |
| 121 | created_project = create_kalibro_project | 75 | created_project = create_kalibro_project |
| 122 | - repositories = Kalibro::Repository.repositories_of(project_id) | ||
| 123 | - repositories.each {|repository| repository.process_repository } | 76 | + self.project_id = created_project.id |
| 124 | end | 77 | end |
| 125 | 78 | ||
| 126 | def create_kalibro_project | 79 | def create_kalibro_project |
| 127 | Kalibro::Project.create( | 80 | Kalibro::Project.create( |
| 128 | - :id => project_id, | ||
| 129 | :name => name, | 81 | :name => name, |
| 130 | :description => description | 82 | :description => description |
| 131 | ) | 83 | ) |
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
| @@ -2,14 +2,6 @@ | @@ -2,14 +2,6 @@ | ||
| 2 | 2 | ||
| 3 | <% | 3 | <% |
| 4 | @project = @article.title.nil? ? nil : @article.project | 4 | @project = @article.title.nil? ? nil : @article.project |
| 5 | - begin | ||
| 6 | - @repository_types = Kalibro::Repository.repository_types.sort | ||
| 7 | - @configuration_names = Kalibro::Configuration.all_names.sort | ||
| 8 | - rescue Exception => exception | ||
| 9 | - @article.errors.add_to_base(exception.message) | ||
| 10 | - @repository_types = [] | ||
| 11 | - @configuration_names = [] | ||
| 12 | - end | ||
| 13 | %> | 5 | %> |
| 14 | 6 | ||
| 15 | <%= error_messages_for 'project_content' %> | 7 | <%= error_messages_for 'project_content' %> |
| @@ -24,28 +16,5 @@ | @@ -24,28 +16,5 @@ | ||
| 24 | <%= required f.text_field(:name) %> | 16 | <%= required f.text_field(:name) %> |
| 25 | <% end %> | 17 | <% end %> |
| 26 | 18 | ||
| 27 | -<% selected = (@project.nil? ? "" : @project.license) %> | ||
| 28 | -<%= required labelled_form_field _('License'), | ||
| 29 | - f.select(:project_license, MezuroPlugin::Helpers::ContentViewerHelper.create_license_options ,{:selected => selected}) %><br/> | ||
| 30 | - | ||
| 31 | <%= f.text_field :description %><br/> | 19 | <%= f.text_field :description %><br/> |
| 32 | 20 | ||
| 33 | -<% @selected = (@project.nil? ? @repository_types : @project.repository.type) %> | ||
| 34 | -<%= required labelled_form_field _('Repository type'), | ||
| 35 | - f.select(:repository_type, @repository_types, {:selected => @selected}) %><br/> | ||
| 36 | - | ||
| 37 | -<%= required f.text_field(:repository_url) %><br/> | ||
| 38 | - | ||
| 39 | -<% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> | ||
| 40 | - | ||
| 41 | -<% if !@project.nil? && !@article.id.nil? %> | ||
| 42 | - <%= required labelled_form_field _('Configuration') + " (Changing the configuration will erase your saved periodic avaliations)", | ||
| 43 | - f.select(:configuration_name, @configuration_names, {:selected => @selected}) %> | ||
| 44 | -<% else %> | ||
| 45 | - <%= required labelled_form_field _('Configuration'), | ||
| 46 | - f.select(:configuration_name, @configuration_names, {:selected => @selected}) %><br/> | ||
| 47 | -<% end %> | ||
| 48 | - | ||
| 49 | -<% selected = (@project.nil? ? 0 : @project.process_period.to_i) %> | ||
| 50 | -<%= required labelled_form_field _('Periodic Avaliation'), | ||
| 51 | - f.select(:periodicity_in_days, MezuroPlugin::Helpers::ContentViewerHelper.create_periodicity_options ,{:selected => selected}) %><br/> |
plugins/mezuro/views/content_viewer/show_project.rhtml
| 1 | -<script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | ||
| 2 | - | ||
| 3 | <% @project = @page.project %> | 1 | <% @project = @page.project %> |
| 4 | <% unless @page.errors[:base].nil? %> | 2 | <% unless @page.errors[:base].nil? %> |
| 5 | <% if @page.errors[:base] =~ /There is no project named/ %> | 3 | <% if @page.errors[:base] =~ /There is no project named/ %> |
| @@ -16,44 +14,9 @@ | @@ -16,44 +14,9 @@ | ||
| 16 | <td><%= @project.name %></td> | 14 | <td><%= @project.name %></td> |
| 17 | </tr> | 15 | </tr> |
| 18 | <tr> | 16 | <tr> |
| 19 | - <td><%= _('License') %></td> | ||
| 20 | - <td><%= @project.license %></td> | ||
| 21 | - </tr> | ||
| 22 | - <tr> | ||
| 23 | <td><%= _('Description') %></td> | 17 | <td><%= _('Description') %></td> |
| 24 | <td><%= @project.description %></td> | 18 | <td><%= @project.description %></td> |
| 25 | </tr> | 19 | </tr> |
| 26 | - <tr> | ||
| 27 | - <td><%= _('Repository type') %></td> | ||
| 28 | - <td><%= @project.repository.type %></td> | ||
| 29 | - </tr> | ||
| 30 | - <tr> | ||
| 31 | - <td><%= _('Repository address') %></td> | ||
| 32 | - <td><%= @project.repository.address %></td> | ||
| 33 | - </tr> | ||
| 34 | - <tr> | ||
| 35 | - <td><%= _('Configuration') %></td> | ||
| 36 | - <td><%= @project.configuration_name %></td> | ||
| 37 | - </tr> | ||
| 38 | - <tr> | ||
| 39 | - <td><%= _('Periodicity') %></td> | ||
| 40 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | ||
| 41 | - </tr> | ||
| 42 | - <tr> | ||
| 43 | - <td><%= _('Status')%></td> | ||
| 44 | - <td> | ||
| 45 | - <div id="project-state" style="color:DarkGoldenRod"><%= @project.state %></div> | ||
| 46 | - <div id="msg-time"></div> | ||
| 47 | - </td> | ||
| 48 | - </tr> | ||
| 49 | </table> | 20 | </table> |
| 50 | 21 | ||
| 51 | - <br /> | ||
| 52 | - | ||
| 53 | - <div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | ||
| 54 | - data-project-name="<%= @project.name %>"> | ||
| 55 | - </div> | ||
| 56 | - <div id="project-tree"></div> | ||
| 57 | - <div id="module-result"> | ||
| 58 | - </div> | ||
| 59 | <% end %> | 22 | <% end %> |