Skip to content

Commit

Permalink
Remove display_on_home_page from Site
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Rass committed Oct 17, 2024
1 parent 46eb859 commit d0cde74
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 37 deletions.
4 changes: 1 addition & 3 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def set_site

# Never trust parameters from the scary internet, only allow the white list through.
def site_params
params.require(:site).permit(
:name, :description, :position, :display_on_home_page , :street, :country, :city, :latitude, :longitude
)
params.require(:site).permit(:name, :description, :position , :street, :country, :city, :latitude, :longitude)
end
end
1 change: 0 additions & 1 deletion app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Room < ApplicationRecord

scope :sorted, -> { order(:site_id, :position, :name) }
scope :not_empty, -> { joins(:servers) }
scope :visible_on_home_page, -> { where(display_on_home_page: true) }

def to_s
name.to_s
Expand Down
1 change: 0 additions & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Site < ApplicationRecord
after_validation :geocode

scope :sorted, -> { order(:position) }
scope :visible_on_home_page, -> { where(display_on_home_page: true) }

def to_s
name
Expand Down
4 changes: 2 additions & 2 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class="img-fluid m-0 py-5 px-2 rounded"
style="background: url(<%= asset_path('_78A0587-nb.jpg') %>) no-repeat center; background-size: cover;">
<div class="container-fluid mt-4">
<% Site.visible_on_home_page.joins(:rooms).distinct.order(:position).each do |site| %>
<% Site.joins(:rooms).where('display_on_home_page = ?', true).distinct.order(:position).each do |site| %>
<div class="container-fluid mb-4 py-2 bg-body-tertiary bg-opacity-75 rounded border">
<div class="text-center fs-4 mb-2"><%= site %></div>
<div class="d-flex justify-content-between flex-wrap">
<% rooms = site.rooms.visible_on_home_page.order(:position) %>
<% rooms = site.rooms.where(display_on_home_page: true).order(:position) %>
<% rooms.each do |room| %>
<div class="flex-fill border border-primary-subtle m-2 p-2 rounded">
<div class="text-start mb-1 fs-5"><%= link_to room.name, room %></div>
Expand Down
7 changes: 0 additions & 7 deletions app/views/sites/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
<%= f.label :position, class: "form-label" %>
<%= f.text_field :position, class: "form-control" %>
</fieldset>

<div class="col-12 mt-4">
<fieldset class="form-check">
<%= f.check_box :display_on_home_page, class: "form-check-input" %>
<%= f.label :display_on_home_page, class: "form-check-label" %>
</fieldset>
</div>
<% end %>
<%= render CardComponent.new(type: :primary, extra_classes: "mt-4 bg-body-tertiary") do |card| %>
Expand Down
6 changes: 0 additions & 6 deletions app/views/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
<% end %>
<% end %>
<% table.with_column(Site.human_attribute_name(:display_on_home_page),
sort_by: :display_on_home_page,
class: "text-center") do |site| %>
<input type="checkbox" <%= site.display_on_home_page ? "checked" : "" %> disabled>
<% end %>
<% table.with_column(style: "min-width: 70px; width: 70px") do |site| %>
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<%= link_to edit_site_path(site), class: "btn btn-info" do %>
Expand Down
5 changes: 0 additions & 5 deletions app/views/sites/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
<dt class="pb-2"><%= Site.human_attribute_name(attribute_name) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @site.public_send(attribute_name) %></dd>
<% end %>

<dt class="pb-2"><%= Site.human_attribute_name(:display_on_home_page) %></dt>
<dd class="mb-0 pb-2 ps-3">
<span><%= t("boolean.#{@site.display_on_home_page}") %></span>
</dd>
</dl>
<% end %>
</div>
Expand Down
1 change: 0 additions & 1 deletion config/locales/activerecord.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ fr:
name: Nom
description: Description
position: Position
display_on_home_page: Afficher sur la page d'accueil
street: Rue
city: Ville
country: Pays
Expand Down
1 change: 0 additions & 1 deletion db/migrate/20241017143515_add_attributes_to_sites_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class AddAttributesToSitesTable < ActiveRecord::Migration[7.2]
def change
change_table :sites, bulk: true do |t|
t.text :description
t.boolean :display_on_home_page, default: true, null: false
end
end
end
1 change: 0 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions spec/models/room_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@
describe "#should_generate_new_friendly_id?" do
pending
end

describe ".visible_on_home_page" do
it { expect(described_class.visible_on_home_page).to match_array([rooms(:one), rooms(:two)]) }
end
end
4 changes: 0 additions & 4 deletions spec/models/site_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@
describe "#address" do
it { expect(site.address).to eq "Rue du Cactus, 92055 La Défense, France" }
end

describe ".visible_on_home_page" do
it { expect(described_class.visible_on_home_page).to match_array([sites(:one)]) }
end
end
1 change: 0 additions & 1 deletion test/fixtures/sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ one:
two:
id: 2
name: Site 2
display_on_home_page: false

0 comments on commit d0cde74

Please sign in to comment.