Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> This commit refactors the entire application to replace the 'parties' concept with 'events'. All controllers, models, views, and related files have been updated to reflect this change. The parties table has been replaced with an events table, and all related functionality has been updated accordingly.
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 events
|
|
def home
|
|
# @events = Event.published.featured.limit(3)
|
|
# @events = Event.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_events = Event.published.count
|
|
@events_this_week = Event.published.where("start_time BETWEEN ? AND ?", Date.current.beginning_of_week, Date.current.end_of_week).count
|
|
@today_events = Event.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc)
|
|
@tomorrow_events = Event.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc)
|
|
@other_events = Event.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 events with pagination
|
|
def events
|
|
@events = Event.published.order(created_at: :desc).page(params[:page])
|
|
end
|
|
end
|