Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 12, 2025

This PR implements a comprehensive course notification system for the We All Code admin interface, allowing administrators to send both email and SMS notifications to parents and volunteers attending/teaching classes.

Overview

The notification system adds a new admin interface accessible from the main dashboard that enables staff to send customized notifications with dynamic template variables. The system integrates seamlessly with existing email infrastructure while adding new SMS capabilities via Dialpad API.

Key Features

Admin Interface

  • Course Status Page: New admin view at /admin/classes/{session_id}/notifications/
  • Dashboard Integration: Added notification column with envelope icon for easy access
  • Dual Notification Types: Separate controls for Email and SMS notifications
  • Recipient Selection: Choose between Parents, Mentors, or Both
  • Real-time Preview: Preview messages with actual data before sending

Email Integration

  • Leverages existing SendGrid email functionality in util.py
  • Sends to all parents of enrolled students and volunteer mentors
  • Custom email template with dynamic content injection
  • Uses existing authentication and delivery infrastructure

SMS Integration

  • Complete Dialpad API integration with proper authentication
  • Automatic phone number validation and formatting
  • Separate SMS templates for parents vs mentors
  • Real-time character counting (160 char limit)
  • Comprehensive error handling and logging

Template System

Dynamic variable replacement supporting:

  • {parent_name}, {student_names}, {mentor_name} - Personal names
  • <class date>, <class start time>, <class location> - Session details
  • <15 minutes before class start time> - Calculated arrival time

Default Templates

Implements the exact templates specified in the issue:

  • Email: Complete multi-point class information template
  • SMS Parents: "👋 Hi {parent_name}. It's Ali from We All Code. We're excited to see {student_names}..."
  • SMS Mentors: "👋 Hi {mentor_name}. It's Ali from We All Code. We're excited to see you tomorrow..."

Technical Implementation

  • Backend: Django views with staff-only access and proper error handling
  • Frontend: Responsive admin interface with JavaScript enhancements
  • API Integration: Requests library for Dialpad SMS API
  • Template Engine: Custom variable replacement using Arrow for date formatting
  • Database: Integrates with existing Session, Guardian, Mentor, and Order models

Usage

  1. Navigate to admin dashboard
  2. Click envelope icon next to any session
  3. Customize email/SMS templates with dynamic variables
  4. Preview messages before sending
  5. Select recipients and send with confirmation

Configuration

Requires new environment variables for SMS functionality:

DIALPAD_API_KEY=your_api_key
DIALPAD_SMS_ENDPOINT=https://dialpad.com/api/v2/sms

The system gracefully handles missing SMS configuration and provides appropriate user feedback.

Testing

Includes comprehensive testing of template variable replacement, phone number formatting, and error handling scenarios. All core functionality has been validated with mock data.

Fixes #1517.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • db
    • Triggering command: /home/REDACTED/work/website/website/.venv/bin/python3 manage.py migrate (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Sep 12, 2025

@karbassi 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Add Course Notification System with Email and SMS Capabilities Add Course Notification System with Email and SMS Capabilities Sep 12, 2025
@Copilot Copilot AI requested a review from karbassi September 12, 2025 18:25
Copilot finished work on behalf of karbassi September 12, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Course Notification System with Email and SMS Capabilities

2 participants