Commit 8bc2bb1b23ce250bd3f8656da0e37e93d153585a

Authored by João M. M. da Silva + Diego Araújo
Committed by Paulo Meireles
1 parent 7f3a7e5e

[Mezuro] Refactored links in views.

plugins/mezuro/controllers/myprofile/mezuro_plugin_reading_controller.rb
... ... @@ -3,10 +3,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController
3 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5 5 def new
6   - reading_group_content = profile.articles.find(params[:id])
7   - @reading_group_name = reading_group_content.name
8   - @data_profile = reading_group_content.profile.identifier
9   - @reading_group_content_id = reading_group_content.id
  6 + @reading_group_content = profile.articles.find(params[:id])
10 7 end
11 8  
12 9 def create
... ... @@ -21,11 +18,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController
21 18 end
22 19  
23 20 def edit
24   - reading_group_content = profile.articles.find(params[:id])
25   - @reading_group_name = reading_group_content.name
26   - @data_profile = reading_group_content.profile.identifier
27   - @reading_group_content_id = reading_group_content.id
28   -
  21 + @reading_group_content = profile.articles.find(params[:id])
29 22 @reading = Kalibro::Reading.find params[:reading_id]
30 23 end
31 24  
... ...
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
... ... @@ -3,10 +3,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
3 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5 5 def new
6   - project_content = profile.articles.find(params[:id])
7   - @project_name = project_content.name
8   - @data_profile = project_content.profile.identifier
9   - @project_content_id = project_content.id
  6 + @project_content = profile.articles.find(params[:id])
10 7  
11 8 @repository_types = Kalibro::Repository.repository_types
12 9  
... ... @@ -32,11 +29,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
32 29 end
33 30  
34 31 def edit
35   - project_content = profile.articles.find(params[:id])
36   - @project_name = project_content.name
37   - @data_profile = project_content.profile.identifier
38   - @project_content_id = project_content.id
39   -
  32 + @project_content = profile.articles.find(params[:id])
40 33 @repository_types = Kalibro::Repository.repository_types
41 34  
42 35 configurations = Kalibro::Configuration.all
... ... @@ -45,7 +38,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
45 38 [configuration.name,configuration.id]
46 39 end
47 40  
48   - @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
  41 + @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
49 42 end
50 43  
51 44 def update
... ... @@ -63,12 +56,9 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
63 56 end
64 57  
65 58 def show
66   - project_content = profile.articles.find(params[:id])
67   - @project_name = project_content.name
68   - @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
  59 + @project_content = profile.articles.find(params[:id])
  60 + @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
69 61 @configuration_name = Kalibro::Configuration.configuration_of(@repository.id).name
70   - @data_profile = project_content.profile.identifier
71   - @data_content = project_content.id
72 62 end
73 63  
74 64 def destroy
... ...
plugins/mezuro/test/functional/myprofile/mezuro_plugin_reading_controller_test.rb
... ... @@ -22,10 +22,8 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase
22 22  
23 23 should 'set variables to create a new reading' do
24 24 get :new, :profile => @profile.identifier, :id => @content.id
25   -
26   - assert_equal @content.id, assigns(:reading_group_content_id)
27   - assert_equal @content.name, assigns(:reading_group_name)
28   - assert_equal @content.profile.identifier, assigns(:data_profile)
  25 + assert_equal @content.id, assigns(:reading_group_content).id
  26 + assert_response :success
29 27 end
30 28  
31 29 should 'create a reading' do
... ... @@ -47,13 +45,10 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase
47 45  
48 46 should 'set variables to edit a reading' do
49 47 Kalibro::Reading.expects(:find).with(@reading.id.to_s).returns(@reading)
50   -
51 48 get :edit, :profile => @profile.identifier, :id => @content.id, :reading_id => @reading.id
52   -
53   - assert_equal @content.id, assigns(:reading_group_content_id)
54   - assert_equal @content.name, assigns(:reading_group_name)
55   - assert_equal @content.profile.identifier, assigns(:data_profile)
  49 + assert_equal @content.id, assigns(:reading_group_content).id
56 50 assert_equal @reading, assigns(:reading)
  51 + assert_response :success
57 52 end
58 53  
59 54 should 'update a reading' do
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... ... @@ -31,12 +31,11 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
31 31  
32 32 get :new, :profile => @profile.identifier, :id => @content.id
33 33  
34   - assert_equal @content.id, assigns(:project_content_id)
35   - assert_equal @content.name, assigns(:project_name)
  34 + assert_equal @content.id, assigns(:project_content).id
36 35 assert_equal @repository_types, assigns(:repository_types)
37   - assert_equal @content.profile.identifier, assigns(:data_profile)
38 36 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
39 37 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
  38 + assert_response :success
40 39 end
41 40  
42 41 should 'create a repository' do
... ... @@ -58,20 +57,18 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
58 57 end
59 58  
60 59 should 'set variables to edit a repository' do
61   - articles = mock
62 60 Kalibro::Repository.expects(:repository_types).returns(@repository_types)
63 61 Kalibro::Configuration.expects(:all).returns(@all_configurations)
64 62 Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository])
65 63  
66 64 get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
67 65  
68   - assert_equal @content.id, assigns(:project_content_id)
69   - assert_equal @content.name, assigns(:project_name)
  66 + assert_equal @content.id, assigns(:project_content).id
70 67 assert_equal @repository_types, assigns(:repository_types)
71   - assert_equal @content.profile.identifier, assigns(:data_profile)
72 68 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
73 69 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
74 70 assert_equal @repository, assigns(:repository)
  71 + assert_response :success
75 72 end
76 73  
77 74 should 'update a repository' do
... ... @@ -98,11 +95,9 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
98 95  
99 96 get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
100 97  
101   - assert_equal @content.name, assigns(:project_name)
  98 + assert_equal @content.id, assigns(:project_content).id
102 99 assert_equal @repository, assigns(:repository)
103 100 assert_equal @configuration.name, assigns(:configuration_name)
104   - assert_equal @content.profile.identifier, assigns(:data_profile)
105   - assert_equal @content.id, assigns(:data_content)
106 101 assert_response :success
107 102 end
108 103  
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/choose_metric.html.erb
1   -<h2><%= @configuration_content.name%> Configuration</h2>
  1 +<h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
2 2  
3 3 <%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound",
4 4 :id => @configuration_content.id %>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound.html.erb
... ... @@ -2,7 +2,7 @@
2 2 <script src="/javascripts/colorpicker.js" type="text/javascript"></script>
3 3 <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script>
4 4  
5   -<h2><%= @configuration_content.name %> Configuration</h2>
  5 +<h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
6 6  
7 7 <% owner = (not user.nil?) && user.id == @profile.id %>
8 8  
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_native.html.erb
... ... @@ -2,7 +2,7 @@
2 2 <script src="/javascripts/colorpicker.js" type="text/javascript"></script>
3 3 <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script>
4 4  
5   -<h2><%= @configuration_content.name %> Configuration</h2>
  5 +<h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
6 6  
7 7 <% owner = (not user.nil?) && user.id == @profile.id %>
8 8  
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound.html.erb
1   -<h2><%= @configuration_content.name %> Configuration</h2>
  1 +<h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
2 2  
3 3 <% form_for :metric_configuration, :url => {:action =>"create_compound", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
4 4 <%= hidden_field_tag :id, @configuration_content.id %>
... ...
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_native.html.erb
1 1 <script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script>
2 2  
3   -<h2><%= @configuration_content.name %> Configuration</h2>
  3 +<h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2>
4 4 <!-- TODO This form should be a partial similar to _native_metric_configuration_form.rhtml -->
5 5 <% form_for :metric_configuration, :url => {:action =>"create_native", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %>
6 6  
... ...
plugins/mezuro/views/mezuro_plugin_reading/edit.html.erb
1 1 <script src="/javascripts/colorpicker.js" type="text/javascript"></script>
2 2 <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script>
3   -<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '-')) ) %></h3>
  3 +<h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2>
4 4  
5 5 <% form_for :reading, :url => {:action =>"update", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %>
6   - <%= hidden_field_tag :id, @reading_group_content_id %>
  6 + <%= hidden_field_tag :id, @reading_group_content.id %>
7 7  
8 8 <%= f.hidden_field :id %>
9 9 <%= required labelled_form_field _('label:'), f.text_field(:label) %>
... ...
plugins/mezuro/views/mezuro_plugin_reading/new.html.erb
1 1 <script src="/javascripts/colorpicker.js" type="text/javascript"></script>
2 2 <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script>
3   -<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '-')) ) %></h3>
  3 +<h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2>
4 4  
5 5 <% form_for :reading, :url => {:action =>"create", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %>
6   - <%= hidden_field_tag :id, @reading_group_content_id %>
  6 + <%= hidden_field_tag :id, @reading_group_content.id %>
7 7  
8 8 <%= required labelled_form_field _('label:'), f.text_field(:label) %>
9 9  
... ...
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1   -<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
  1 +<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
2 2  
3 3 <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content_id %>
  4 + <%= hidden_field_tag :id, @project_content.id %>
5 5  
6 6 <%= f.hidden_field :id%>
7 7 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
8 8  
9   - <div class="formfieldline">
10   - <%= f.label :description, "Description:", :class => 'formlabel' %>
11   - <div class="formfield type-text">
12   - <%= f.text_field :description %>
13   - </div>
14   - </div>
  9 + <%= labelled_form_field _("Description:"), f.text_field(:description) %>
15 10  
16 11 <%= required labelled_form_field _('License'),
17 12 f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options, :selected => @repository.license) %>
... ... @@ -28,8 +23,6 @@
28 23 <%= required labelled_form_field _('Configuration'),
29 24 f.select(:configuration_id, @configuration_select, :selected => @repository.configuration_id.to_i) %>
30 25  
31   - <p>
32   - <%= f.submit "Add" %>
33   - </p>
  26 + <p> <%= f.submit "Add" %> </p>
34 27  
35 28 <% end %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1   -<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
  1 +<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
2 2  
3 3 <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4   - <%= hidden_field_tag :id, @project_content_id %>
  4 + <%= hidden_field_tag :id, @project_content.id %>
5 5  
6 6 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
7 7  
8   - <div class="formfieldline">
9   - <%= f.label :description, "Description:", :class => 'formlabel' %>
10   - <div class="formfield type-text">
11   - <%= f.text_field :description %>
12   - </div>
13   - </div>
  8 + <%= labelled_form_field _('Description'), f.text_field(:description) %>
14 9  
15 10 <%= required labelled_form_field _('License'),
16 11 f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.license_options) %>
... ... @@ -27,8 +22,6 @@
27 22 <%= required labelled_form_field _('Configuration'),
28 23 f.select(:configuration_id, @configuration_select) %>
29 24  
30   - <p>
31   - <%= f.submit "Add" %>
32   - </p>
  25 + <p> <%= f.submit "Add" %> </p>
33 26  
34 27 <% end %>
... ...
plugins/mezuro/views/mezuro_plugin_repository/show.html.erb
1 1 <script src="/plugins/mezuro/javascripts/processing.js" type="text/javascript"></script>
2   -<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
  2 +<h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2>
3 3  
4 4 <table>
5 5 <tr>
... ... @@ -40,6 +40,6 @@
40 40 </table>
41 41 <br />
42 42  
43   -<div id="processing" data-profile="<%= @data_profile %>" data-content="<%= @data_content %>"
  43 +<div id="processing" data-profile="<%= @project_content.profile.identifier %>" data-content="<%= @project_content.id %>"
44 44 data-repository-id="<%= @repository.id %>"></div>
45 45 <div id="module-result"></div>
... ...