Skip to main content

Subscription Overview

Core Relationships Diagram

Subscription

Serves as the central model for managing access rights to content (courses, ebooks). Key features:

  • Tracks access duration through expiry_date (null means unlimited access)
  • Groups related course subscriptions through bundle_id
  • Supports gifting functionality
  • Manages activation status and renewal state
  • Provides additional features like summary and certificate access

Bundle Subscription Mechanism

When a bundle is purchased:

  1. Individual subscriptions are created for each course in the bundle
  2. These subscriptions are linked through a common bundle_id

SubscriptionRecord

Tracks the complete history of subscription changes including:

  • Ownership transfers
  • Activation status changes
  • Renewal events
  • Video access modifications

The record system uses polymorphic relationships (causer_type/causer_id) to track which entity caused the change.

Subscription Operations

The system defines several operation types through SubscriptionRecordOperation:

// Core Operations
NEW_SUBSCRIPTION = 'اشتراك جديد' // New subscription creation
RENEWED_SUBSCRIPTION = 'تجديد اشتراك' // Subscription renewal

// Activation Management
SUBSCRIPTION_ACTIVATION = 'تفعيل' // Activation of subscription
SUBSCRIPTION_DEACTIVATION = 'الغاء تفعيل' // Deactivation of subscription

// Ownership & Updates
SUBSCRIPTION_TRANSFER = 'نقل اشتراك' // Transfer between customers
EXPIRY_DATE_UPDATE = 'تحديث تاريخ الإنتهاء' // Expiration date modification

// Video Management
NEW_VIDEO = 'إضافة فيديو للاشتراك' // Adding video access
VIDEO_REMOVAL = 'إلغاء فيديو من الاشتراك' // Removing video access

Each operation is recorded with:

  • The current and previous owner (for transfers)
  • The entity that caused the change (admin, system, etc.)
  • A description of the change
  • Timestamp of the operation