handle public dashboards
This commit is contained in:
parent
858c535c3c
commit
cbe73af9bf
6 changed files with 27 additions and 4 deletions
14
app/controllers/home_controller.rb
Normal file
14
app/controllers/home_controller.rb
Normal 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
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class MoodsController < ApplicationController
|
class MoodsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@mode = current_user.moods.last&.mode || "croisiere"
|
@mode = Current.user.current_mood
|
||||||
@history = current_user.history
|
@history = Current.user.history
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,8 @@ class User < ApplicationRecord
|
||||||
def history
|
def history
|
||||||
MoodCalendarService.generate_calendar(moods)
|
MoodCalendarService.generate_calendar(moods)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_mood
|
||||||
|
self.moods.last&.mode || "croisiere"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
1
app/views/home/index.html.haml
Normal file
1
app/views/home/index.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
%h1 Comment ça KLUK ?
|
||||||
|
|
@ -73,5 +73,7 @@ Rails.application.configure do
|
||||||
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
||||||
# config.generators.apply_rubocop_autocorrect_after_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
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,10 @@ Rails.application.routes.draw do
|
||||||
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
|
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
|
||||||
|
|
||||||
# Defines the root path route ("/")
|
# Defines the root path route ("/")
|
||||||
root "moods#index"
|
root "home#index"
|
||||||
|
|
||||||
get "/invite/:token", to: "invitations#edit", as: :edit_invitation
|
get "/invite/:token", to: "invitations#edit", as: :edit_invitation
|
||||||
patch "/invite/:token", to: "invitations#update", as: :invitation
|
patch "/invite/:token", to: "invitations#update", as: :invitation
|
||||||
|
|
||||||
|
get "/moods", to: "moods#index", as: :dashboard
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue