Commit 67aa673b710676bfa792a91567e38ac9b9f2edd4
Committed by
Paulo Meireles
1 parent
b129d88b
Exists in
master
and in
23 other branches
[Mezuro] Only the owner can edit metric_configuration
Showing
5 changed files
with
74 additions
and
49 deletions
Show diff stats
plugins/mezuro/views/content_viewer/_metric_configuration_form.rhtml
0 → 100644
... | ... | @@ -0,0 +1,41 @@ |
1 | +<% form_for :metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
2 | + <%= hidden_field_tag :id, @configuration_content.id %> | |
3 | + <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | |
4 | + | |
5 | + <% f.fields_for :metric do |m| %> | |
6 | + | |
7 | + <% @metric.language.each do |language| %> | |
8 | + <%= m.hidden_field :language, :multiple => true, :value => language %> | |
9 | + <% end %> | |
10 | + | |
11 | + <%= m.hidden_field "scope", :value => @metric.scope %> | |
12 | + <p> | |
13 | + <b><%= m.label :origin, "Collector Name:" %></b> | |
14 | + <%= @metric.origin %> | |
15 | + <%= m.hidden_field "origin", :value => @metric.origin %> | |
16 | + </p> | |
17 | + <p> | |
18 | + <b><%= m.label :metric_name, "Metric Name:" %></b> | |
19 | + <%= @metric.name %> | |
20 | + <%= m.hidden_field "name", :value => @metric.name %> | |
21 | + </p> | |
22 | + <% end %> | |
23 | + <p> | |
24 | + <b><%= f.label :code, "Code:" %></b> | |
25 | + <%= @metric_configuration.code %> | |
26 | + <%= f.hidden_field "code", :value => @metric_configuration.code %> | |
27 | + </p> | |
28 | + <p> | |
29 | + <b><%= f.label :aggregation_form, "Aggregation Form:" %></b> | |
30 | + <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
31 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | |
32 | + </p> | |
33 | + <p> | |
34 | + <b><%= f.label :weight, "Weight:" %></b> | |
35 | + <%= f.text_field "weight", :value => @metric_configuration.weight %> | |
36 | + </p> | |
37 | + | |
38 | + <p> | |
39 | + <%= f.submit "Save" %> | |
40 | + </p> | |
41 | +<% end %> | ... | ... |
plugins/mezuro/views/content_viewer/_metric_configuration_view.rhtml
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +<p> | |
2 | + <b>Collector Name:</b> <%= @metric.origin %> | |
3 | +</p> | |
4 | +<p> | |
5 | + <b>Metric Name:</b> <%= @metric.name %> | |
6 | +</p> | |
7 | +<p> | |
8 | + <b>Code:</b> <%= @metric_configuration.code %> | |
9 | +</p> | |
10 | +<p> | |
11 | + <b>Aggregation Form:</b> <%= @metric_configuration.aggregation_form %> | |
12 | +</p> | |
13 | +<p> | |
14 | + <b>Weight:</b> <%= @metric_configuration.weight %> | |
15 | +</p> | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_metric_configuration.html.erb
... | ... | @@ -4,54 +4,14 @@ |
4 | 4 | |
5 | 5 | <h2><%= @configuration_content.name %> Configuration</h2> |
6 | 6 | |
7 | -<% form_for :metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
8 | - <%= hidden_field_tag :id, @configuration_content.id %> | |
9 | - <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | |
10 | - | |
11 | - <% f.fields_for :metric do |m| %> | |
12 | - | |
13 | - <% @metric.language.each do |language| %> | |
14 | - <%= m.hidden_field :language, :multiple => true, :value => language %> | |
15 | - <% end %> | |
16 | - | |
17 | - <%= m.hidden_field "scope", :value => @metric.scope %> | |
18 | - <p> | |
19 | - <%= m.label :origin, "Collector Name:" %> | |
20 | - <%= @metric.origin %> | |
21 | - <%= m.hidden_field "origin", :value => @metric.origin %> | |
22 | - </p> | |
23 | - <p> | |
24 | - <%= m.label :metric_name, "Metric Name:" %> | |
25 | - <%= @metric.name %> | |
26 | - <%= m.hidden_field "name", :value => @metric.name %> | |
27 | - </p> | |
28 | - <!--<p>--> | |
29 | - <% m.label :description, "Description:" %> | |
30 | - <% @metric.description %> | |
31 | - <% m.hidden_field "description", :value => @metric.description %> | |
32 | - <!--</p>--> | |
33 | - <% end %> | |
34 | - <p> | |
35 | - <%= f.label :code, "Code:" %> | |
36 | - <%= @metric_configuration.code %> | |
37 | - <%= f.hidden_field "code", :value => @metric_configuration.code %> | |
38 | - </p> | |
39 | - <p> | |
40 | - <%= f.label :aggregation_form, "Aggregation Form:" %> | |
41 | - <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
42 | - ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | |
43 | - </p> | |
44 | - <p> | |
45 | - <%= f.label :weight, "Weight:" %> | |
46 | - <%= f.text_field "weight", :value => @metric_configuration.weight %> | |
47 | - </p> | |
7 | +<% owner = (not user.nil?) && user.id == @profile.id %> | |
48 | 8 | |
49 | - <p> | |
50 | - <%= f.submit "Save" %> | |
51 | - </p> | |
9 | +<% if owner %> | |
10 | + <%= render :partial => "content_viewer/metric_configuration_form" %> | |
11 | +<% else %> | |
12 | + <%= render :partial => "content_viewer/metric_configuration_view" %> | |
52 | 13 | <% end %> |
53 | 14 | |
54 | - | |
55 | 15 | <h5> Ranges </h5><br/> |
56 | 16 | |
57 | 17 | <table id="ranges"> |
... | ... | @@ -83,6 +43,8 @@ |
83 | 43 | </table> |
84 | 44 | |
85 | 45 | <br/> |
86 | -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | |
46 | +<% if owner %> | |
47 | + <%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | |
48 | +<% end %> | |
87 | 49 | <div id="range_form" style="display:none"></div> |
88 | 50 | ... | ... |
plugins/mezuro/views/mezuro_plugin_range/_range.html.erb
... | ... | @@ -12,6 +12,13 @@ |
12 | 12 | <%=range.grade%> |
13 | 13 | </td> |
14 | 14 | <td bgcolor="#<%= range.color[2..-1] %>"></td> |
15 | - <td><%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %></td> | |
16 | - <td><%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %></td> | |
15 | + <% if (not user.nil?) && user.id == @profile.id %> | |
16 | + <td><%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %> | |
17 | + </td> | |
18 | + <td><%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %> | |
19 | + </td> | |
20 | + <% else %> | |
21 | + <td></td> | |
22 | + <td></td> | |
23 | + <% end %> | |
17 | 24 | </tr> | ... | ... |
plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | <%= f.label :beginning, "(*) Beginning:" %> |
15 | 15 | </td> |
16 | 16 | <td> |
17 | - <%= f.text_field :beginning, :value => @range.beginning , :id => 'beginning', :value => "" %> <%= link_to('-∞', 'javascript:void(0)', :onClick => "jQuery( '#beginning' ).val('-INF');") %> | |
17 | + <%= f.text_field :beginning, :value => @range.beginning , :id => 'beginning' %> <%= link_to('-∞', 'javascript:void(0)', :onClick => "jQuery( '#beginning' ).val('-INF');") %> | |
18 | 18 | </td> |
19 | 19 | </tr> |
20 | 20 | <tr> | ... | ... |