handle public dashboards
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
Christophe Robillard 2026-02-20 10:30:12 +01:00
parent 858c535c3c
commit cbe73af9bf
6 changed files with 27 additions and 4 deletions

View file

@ -0,0 +1,14 @@
class HomeController < ApplicationController
allow_unauthenticated_access
def index
user = User.find_by(username: request.subdomain)
if user&.public?
@mode = user.current_mood
@history = user.history
render template: "moods/index"
else
redirect_to dashboard_path
end
end
end

View file

@ -1,6 +1,6 @@
class MoodsController < ApplicationController
def index
@mode = current_user.moods.last&.mode || "croisiere"
@history = current_user.history
@mode = Current.user.current_mood
@history = Current.user.history
end
end

View file

@ -33,4 +33,8 @@ class User < ApplicationRecord
def history
MoodCalendarService.generate_calendar(moods)
end
def current_mood
self.moods.last&.mode || "croisiere"
end
end

View file

@ -0,0 +1 @@
%h1 Comment ça KLUK ?

View file

@ -73,5 +73,7 @@ Rails.application.configure do
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
#
config.hosts << "bipodokrat:3000"
config.hosts << "localhost.localdomain:3000"
config.hosts << "robi.localhost.localdomain:3000"
config.hosts << "marie.localhost.localdomain:3000"
end

View file

@ -15,8 +15,10 @@ Rails.application.routes.draw do
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
# Defines the root path route ("/")
root "moods#index"
root "home#index"
get "/invite/:token", to: "invitations#edit", as: :edit_invitation
patch "/invite/:token", to: "invitations#update", as: :invitation
get "/moods", to: "moods#index", as: :dashboard
end