Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to view records index and show if not logged in. #28

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading