33 lines
1.4 KiB
Ruby
Executable File
33 lines
1.4 KiB
Ruby
Executable File
# Controller for static pages and user dashboard
|
|
# Handles basic page rendering and user-specific content
|
|
class PagesController < ApplicationController
|
|
# Skip authentication for public pages
|
|
# skip_before_action :authenticate_user!, only: [ :home ]
|
|
before_action :authenticate_user!, only: [ :dashboard ]
|
|
|
|
# Homepage showing featured parties
|
|
def home
|
|
# @parties = Party.published.featured.limit(3)
|
|
@parties = Party.where(state: :published).order(created_at: :desc)
|
|
|
|
if user_signed_in?
|
|
return redirect_to(dashboard_path)
|
|
end
|
|
end
|
|
|
|
# User dashboard showing personalized content
|
|
# Accessible only to authenticated users
|
|
def dashboard
|
|
@available_parties = Party.published.count
|
|
@events_this_week = Party.published.where("start_time BETWEEN ? AND ?", Date.current.beginning_of_week, Date.current.end_of_week).count
|
|
@today_parties = Party.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc)
|
|
@tomorrow_parties = Party.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc)
|
|
@other_parties = Party.published.upcoming.where.not("DATE(start_time) IN (?)", [Date.current, Date.current + 1]).order(start_time: :asc).page(params[:page])
|
|
end
|
|
|
|
# Events page showing all published parties with pagination
|
|
def events
|
|
@parties = Party.published.order(created_at: :desc).page(params[:page])
|
|
end
|
|
end
|