Diff
Modified: branches/snapshots/app/controllers/packs_controller.rb (3200 => 3201)
--- branches/snapshots/app/controllers/packs_controller.rb 2012-11-26 13:55:31 UTC (rev 3200)
+++ branches/snapshots/app/controllers/packs_controller.rb 2012-11-26 13:56:31 UTC (rev 3201)
@@ -403,6 +403,24 @@
end
end
+ def snapshot
+
+ success = @pack.snapshot!
+
+ respond_to do |format|
+ format.html {
+ if success
+ @pack.reload
+ flash[:notice] = 'Pack snapshot was successfully created.'
+ redirect_to pack_version_path(@pack, @pack.versions.last.version)
+ else
+ flash[:error] = 'There was a problem with creating the snapshot.'
+ redirect_to pack_path(@pack)
+ end
+ }
+ end
+ end
+
protected
# Check that a protocol is specified in the URI; prepend HTTP:// otherwise
@@ -438,7 +456,8 @@
"statistics" => "view",
"tag" => "view",
"update" => "edit",
- "update_item" => "edit"
+ "update_item" => "edit",
+ "snapshot" => "edit"
}
begin
Copied: branches/snapshots/app/views/packs/_version_selector.rhtml (from rev 3197, branches/snapshots/app/views/contributions/_version_selector.rhtml) (0 => 3201)
--- branches/snapshots/app/views/packs/_version_selector.rhtml (rev 0)
+++ branches/snapshots/app/views/packs/_version_selector.rhtml 2012-11-26 13:56:31 UTC (rev 3201)
@@ -0,0 +1,82 @@
+<script type="text/_javascript_">
+ function showVersion(form) {
+ var url = ""
+ location.href = ""
+ form.submit
+ }
+</script>
+
+<div class="contribution_version_selector_box">
+
+ <table>
+ <tbody>
+ <tr>
+ <td class="heading" style="vertical-align: top;">
+ <% if version %>
+ <%= info_icon_with_tooltip("This box shows version #{version.version.to_s} for this entry") -%>
+ <span><%= "Version #{version.version.to_s} #{resource.describe_version(version.version)}" -%></span>
+ <span class="count_text">(of <%= resource.versions.length -%>)</span>
+ <% else %>
+ <%= info_icon_with_tooltip("This box shows the live version for this entry") -%>
+ <span>Live view</span>
+ <% if resource.versions.length > 0 %>
+ <span class="count_text">(<%= resource.versions.length -%> versions available)</span>
+ <% end %>
+ <% end %>
+ <a name="versions"></a>
+ </td>
+ <td>
+ <% if resource.versions.length > 0 %>
+ <form return false;" style="text-align: right;">
+ <b>View version: </b>
+ <select id="resource_versions"
+ <option value="<%= polymorphic_path(resource) %>" <%= "selected" if version.nil? -%>>Live view</option>
+ <% resource.versions.reverse.each do |v| %>
+ <option value="<%= send(path, resource, v.version.to_s) %>" <%= "selected" if !version.nil? && v.version == version.version -%>>
+ <%= "#{v.version.to_s} #{resource.describe_version(v.version)}" %>
+ </option>
+ <% end %>
+ </select>
+ </form>
+ <% end %>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <% if version %>
+ <div id="version_info_box" style="color: #666666; font-size: 85%; margin: 0.6em 0.5em 0.2em 0.5em; border-top: 1px solid #DDDDDD; padding-top: 0.4em;">
+ <p style="text-align: center;">
+ <b>Version created on:</b>
+ <span><%= datetime version.created_at, false %></span>
+ <% if version.respond_to?(:contributor_id) && version.respond_to?(:contributor_type) %>
+ <b>by:</b>
+ <span><%= contributor(version.contributor_id, version.contributor_type) %></span>
+ <% end %>
+ <% if !version.revision_comments.blank? %>
+ <span> | </span>
+ <span><%= link_to_function "Revision comment " + expand_image, visual_effect(:toggle_blind, "version_info_box_comments", :duration => 0.3) %></span>
+ <% end %>
+ </p>
+
+ <% unless version.created_at == version.updated_at %>
+ <p style="text-align: center;">
+ <b>Last edited on:</b>
+ <span><%= datetime version.updated_at, false %></span>
+ <% if version.respond_to?(:last_edited_by) %>
+ <b>by:</b>
+ <span><%= contributor(version.last_edited_by, "User") %></span>
+ <% end %>
+ </p>
+ <% end %>
+ </div>
+ <% end %>
+
+ <% if version && !version.revision_comments.blank? -%>
+ <div id="version_info_box_comments" style="display: none; border: 1px dotted #CCCCCC; padding: 0.3em 0.5em;">
+ <%= white_list version.revision_comments %>
+ </div>
+ <% end %>
+
+</div>
+
Modified: branches/snapshots/app/views/packs/show.rhtml (3200 => 3201)
--- branches/snapshots/app/views/packs/show.rhtml 2012-11-26 13:55:31 UTC (rev 3200)
+++ branches/snapshots/app/views/packs/show.rhtml 2012-11-26 13:56:31 UTC (rev 3201)
@@ -9,6 +9,9 @@
<% if mine?(@pack) -%>
<li><%= icon('manage', edit_pack_path(@pack), nil, nil, 'Manage Pack') -%></li>
<% end -%>
+ <% if @authorised_to_edit -%>
+ <li><%= icon('new', snapshot_pack_path(@pack), nil, { :confirm => 'Are you sure that you would like to create a new snapshot of this Pack?', :method => :post }, 'Create snapshot') %></li>
+ <% end -%>
<% if Authorization.check("destroy", @pack, current_user) %>
<li><%= icon('destroy', pack_path(@pack), nil, { :confirm => 'This deletes the Pack and all metadata such as tags and comments, BUT does not delete the actual items pointed to in the Pack. Are you sure you would like to delete this Pack?', :method => :delete }, 'Delete Pack') %></li>
<% end %>
@@ -41,6 +44,9 @@
<div class="contribution_left_box">
<div class="contribution_version_box">
+
+ <%= render(:partial => "packs/version_selector", :locals => { :resource => @pack, :version => @version, :path => :pack_version_path }) %>
+
<div class="contribution_version_inner_box">
<p>
<b>Title:</b>
Modified: branches/snapshots/config/tables.xml
(Binary files differ)