Skip to content

Commit

Permalink
Merge pull request #28 from co-cddo/allow-public-access-to-record-list
Browse files Browse the repository at this point in the history
Allow users to view records index and show if not logged in.
  • Loading branch information
RobNicholsGDS authored Dec 9, 2024
2 parents dbc6a91 + dc45981 commit 625e246
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/controllers/records_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RecordsController < ApplicationController
before_action :set_record, only: %i[show edit update destroy publish unpublish]
before_action :authenticate_user!
before_action :authenticate_user!, except: %i[index show]

# GET /records
def index
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
text: 'Records',
href: records_path,
active: current_page?(records_path)
) if user_signed_in?
)

header.with_navigation_item(
text: 'Users',
Expand Down
2 changes: 1 addition & 1 deletion app/views/records/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<h1 class="govuk-heading-l">Records</h1>

<%= govuk_link_to "New record", new_record_path %>
<%= govuk_link_to("New record", new_record_path) if user_signed_in? %>

<div id="records">
<table class="govuk-table">
Expand Down
33 changes: 17 additions & 16 deletions app/views/records/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
<%= JSON.pretty_generate(@record.metadata) %>
</pre>


<div class="govuk-!-padding-bottom-4">
<%= govuk_link_to "Edit this record", edit_record_path(@record) %>
</div>

<div class="govuk-!-padding-bottom-2">
<% if @record.published? %>
<p class="govuk-body">Any edits to the record will be pushed to the Data Marketplace</p>
<%= govuk_button_to "Remove this record from the Data Marketplace", unpublish_record_path(@record), warning: true %>
<% else %>
<%= govuk_button_to "Publish this record on the Data Marketplace", publish_record_path(@record), class: "govuk-!-padding-bottom-2" %>

<%= govuk_button_to "Destroy this record", @record, method: :delete, warning: true %>
<% end %>
</div>

<% if user_signed_in? %>
<div class="govuk-!-padding-bottom-4">
<%= govuk_link_to "Edit this record", edit_record_path(@record) %>
</div>


<div class="govuk-!-padding-bottom-2">
<% if @record.published? %>
<p class="govuk-body">Any edits to the record will be pushed to the Data Marketplace</p>
<%= govuk_button_to "Remove this record from the Data Marketplace", unpublish_record_path(@record), warning: true %>
<% else %>
<%= govuk_button_to "Publish this record on the Data Marketplace", publish_record_path(@record), class: "govuk-!-padding-bottom-2" %>

<%= govuk_button_to "Destroy this record", @record, method: :delete, warning: true %>
<% end %>
</div>
<% end %>


<% if @remote_metadata %>
Expand Down

0 comments on commit 625e246

Please sign in to comment.