This commit adds a complete event management interface allowing promoters to create, edit, and manage their events with full CRUD operations. ## Backend Features - New Promoter::EventsController with full CRUD operations - Event state management (draft, published, canceled, sold_out) - User authorization system with can_manage_events? method - Proper scoping to ensure users only see their own events ## Frontend Features - Modern responsive UI with Tailwind CSS styling - Event listing with status indicators and quick actions - Comprehensive event creation and editing forms - Detailed event show page with metrics and management options - Integration with main dashboard via promoter action buttons ## JavaScript Improvements - Refactored inline JavaScript to dedicated Stimulus controller - Auto-slug generation from event names with proper sanitization - Improved code organization following Rails conventions ## Routes & Navigation - Namespaced promoter routes under /promoter/ - RESTful endpoints with state management actions - Proper breadcrumb navigation and user flow ## Files Added/Modified - app/controllers/promoter/events_controller.rb (new) - app/javascript/controllers/event_form_controller.js (new) - app/views/promoter/events/*.html.erb (4 new view files) - app/models/user.rb (added authorization methods) - app/views/pages/dashboard.html.erb (added promoter buttons) - config/routes.rb (added promoter namespace) - app/javascript/controllers/index.js (registered new controller) 🎯 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
43 lines
1.7 KiB
Ruby
Executable File
43 lines
1.7 KiB
Ruby
Executable File
# User model for authentication and user management
|
|
# Handles user accounts, authentication, and authorization using Devise
|
|
class User < ApplicationRecord
|
|
# Include default devise modules. Others available are:
|
|
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
|
#
|
|
# Include default devise modules for authentication
|
|
# :database_authenticatable - encrypts and stores password in database
|
|
# :registerable - allows users to sign up and edit their accounts
|
|
# :recoverable - handles password reset functionality
|
|
# :rememberable - manages token-based user remembering
|
|
# :validatable - provides email and password validation
|
|
# Other available modules are:
|
|
# :confirmable - requires email confirmation
|
|
# :lockable - locks account after failed login attempts
|
|
# :timeoutable - expires sessions after inactivity
|
|
# :trackable - tracks sign-in count, timestamps, and IP
|
|
# :omniauthable - allows authentication via OAuth providers
|
|
devise :database_authenticatable, :registerable,
|
|
:recoverable, :rememberable, :validatable
|
|
|
|
# Relationships
|
|
has_many :events, dependent: :destroy
|
|
has_many :tickets, dependent: :destroy
|
|
|
|
# Validations
|
|
validates :last_name, length: { minimum: 3, maximum: 12, allow_blank: true }
|
|
validates :first_name, length: { minimum: 3, maximum: 12, allow_blank: true }
|
|
validates :company_name, length: { minimum: 3, maximum: 12, allow_blank: true }
|
|
|
|
# Authorization methods
|
|
def can_manage_events?
|
|
# For now, all authenticated users can manage events
|
|
# This can be extended later with role-based permissions
|
|
true
|
|
end
|
|
|
|
def promoter?
|
|
# Alias for can_manage_events? to make views more semantic
|
|
can_manage_events?
|
|
end
|
|
end
|