profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?) and enabled=?', @profile.language, @profile.id, @profile.name, true], :order => 'name')
@select_parent = [['None', nil]] + profiles.collect{ |profile| [profile.name, profile.name] }
end
-
+
#
#
# GET /profiles/changelog?id=<profile id>
#
def changelog
@profile = Profile.find(params[:id])
-
- @changes=ActiveRuleChange.find(:all, :conditions => ['profile_id=?', @profile.id], :order => 'id desc')
-
+
+ @versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version')
+ @versions.sort! { |a,b| b.profile_version <=> a.profile_version }
+
+ if @versions.empty?
+ @last_version = 1
+ else
+ @last_version = @versions[0].profile_version
+ @past_versions = @versions[1, @versions.length]
+ if params[:since].blank?
+ @since_version = @last_version - 1
+ else
+ @since_version = params[:since].to_i
+ end
+ @changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and profile_version>?', @profile.id, @since_version], :order => 'id desc')
+ end
end
-
-
+
+
#
#
# POST /profiles/change_parent?id=<profile id>&parent_name=<parent profile name>
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %>
<div class="tabs-panel marginbottom10">
+ <% if @versions.empty? %>
+ No changes has been done on this quality profile.
+ <% else %>
+
+ <% if !@past_versions.empty? %>
+ <% form_tag({:action => 'changelog'}, {:method => 'post'}) do %>
+ <%= hidden_field_tag "id", @profile.id %>
+ Changelog between last version (<%= @versions[0].change_date.strftime("%Y/%m/%d %H:%M:%S") %>) and
+ <%= select_tag "since", options_for_select(@past_versions.map {|u| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]}, @since_version) %>
+ <%= submit_tag "Load", :id => 'submit_since'%>
+ <% end %>
+ <% end %>
<table class="data width100">
<thead>
<% end %>
</table>
+ <% end %>
</div>