This commit implements a complete promoter system that allows professional users (is_professionnal: true) to manage events with advanced analytics and controls. ## Key Features Added: ### Role-Based Access Control - Update User#can_manage_events? to use is_professionnal field - Add promoter? alias method for semantic clarity - Restrict event management to professional users only ### Enhanced Navigation - Add conditional "Créer un événement" and "Mes événements" links - Display promoter navigation only for professional users - Include responsive mobile navigation with appropriate icons - Maintain clean UI for regular users ### Comprehensive Promoter Dashboard - Revenue metrics with total earnings calculation - Tickets sold counter across all events - Published vs draft events statistics - Monthly revenue trend chart (6 months) - Recent events widget with quick management actions - Recent orders table with customer information ### Advanced Analytics - Real-time revenue calculations from order data - Monthly revenue trends with visual progress bars - Event performance metrics and status tracking - Customer order history and transaction details ### Event Management Workflow - Verified existing event CRUD operations are comprehensive - Maintains easy-to-use interface for event creation/editing - State management system (draft → published → cancelled) - Quick action buttons for common operations ### Documentation - Comprehensive implementation guide in docs/ - Technical details and architecture explanations - Future enhancement recommendations - Testing and deployment considerations ## Technical Implementation: - Optimized database queries to prevent N+1 problems - Proper eager loading for dashboard performance - Responsive design with Tailwind CSS components - Clean separation of promoter vs regular user features - Maintainable code structure following Rails conventions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
52 lines
1.9 KiB
Ruby
Executable File
52 lines
1.9 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
|
|
has_many :orders, dependent: :destroy
|
|
|
|
# Validations - allow reasonable name lengths
|
|
validates :last_name, length: { minimum: 2, maximum: 50, allow_blank: true }
|
|
validates :first_name, length: { minimum: 2, maximum: 50, allow_blank: true }
|
|
validates :company_name, length: { minimum: 2, maximum: 100, allow_blank: true }
|
|
|
|
# Onboarding methods
|
|
def needs_onboarding?
|
|
!onboarding_completed?
|
|
end
|
|
|
|
def complete_onboarding!
|
|
update!(onboarding_completed: true)
|
|
end
|
|
|
|
# Authorization methods
|
|
def can_manage_events?
|
|
# Only professional users can manage events
|
|
is_professionnal?
|
|
end
|
|
|
|
def promoter?
|
|
# Alias for can_manage_events? to make views more semantic
|
|
can_manage_events?
|
|
end
|
|
end
|