Skip to content

custom program certificates#29

Merged
muhammadammar-ma merged 5 commits intoulmo/fbrfrom
ammar/custom-program-certificates
Apr 1, 2026
Merged

custom program certificates#29
muhammadammar-ma merged 5 commits intoulmo/fbrfrom
ammar/custom-program-certificates

Conversation

@muhammadammar-ma
Copy link
Copy Markdown
Collaborator

@muhammadammar-ma muhammadammar-ma commented Apr 1, 2026

Summary

  • Add database-backed custom program certificate templates, allowing certificate HTML to be managed via Django admin instead of requiring file-based templates deployed with the code
  • Introduce CertificateAsset model for uploading and referencing images, fonts, and CSS in certificate templates via a {% certificate_asset_url 'slug' %} template tag
  • Gate the feature behind a credentials.custom_program_certificate_templates waffle switch for safe rollout
  • Include FBR program certificate template and assets (fonts, logos) as the first use case

Details

New Models

ProgramCertificateTemplate — Stores Django template HTML with optional organization scoping. Template selection follows a priority hierarchy:

  1. Active template matching both program certificate + organization (most specific)
  2. Active template matching program certificate only (fallback)

Unique constraints enforce a single active template per scope, preventing ambiguous lookups.

CertificateAsset — Stores uploadable files (images, fonts, CSS) identified by a unique slug. Templates reference assets using {% load certificate_assets %}{% certificate_asset_url 'my-slug' %}, which gracefully degrades to an empty string with a logged warning if the slug is missing.

Admin Interface

  • ProgramCertificateTemplateAdmin with autocomplete fields, search by org key/program UUID, and fieldsets separating configuration from template HTML editing
  • CertificateAssetAdmin with slug-based lookup, read-only asset URL preview, and upload guidance

Feature Toggle

Waffle switch credentials.custom_program_certificate_templates (default: off). When enabled, the rendering path checks for a database template before falling back to file-based templates.

Test plan

  • Enable waffle switch credentials.custom_program_certificate_templates
  • Create a CertificateAsset via Django admin and verify the upload path and URL preview
  • Create a ProgramCertificateTemplate via Django admin with template HTML referencing an asset slug
  • Verify program certificate renders using the DB template instead of the file-based one
  • Verify org-scoped template takes priority over program-only template
  • Disable the waffle switch and verify fallback to file-based templates
  • Verify missing asset slugs log a warning and render gracefully (no 500)

Copy link
Copy Markdown

@ahmed-arb ahmed-arb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Could you please add a bit more detailed PR description?

Comment thread credentials/templates/credentials/programs/fbr-program/certificate.html Outdated
@muhammadammar-ma muhammadammar-ma force-pushed the ammar/custom-program-certificates branch from a83579a to 88cb5fe Compare April 1, 2026 12:48
@muhammadammar-ma muhammadammar-ma merged commit b0830c8 into ulmo/fbr Apr 1, 2026
2 checks passed
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.

3 participants