make_post_sell/CLAUDE.md
Russell Ballestrini f58bd3e628 Add email deduplication to prevent duplicate crypto payment emails
- Add sales_email_sent, purchase_email_sent, refund_email_sent columns to CryptoPayment model
- Update finalize_invoice to check email flags before sending confirmation emails
- Add alembic migration for new email tracking columns
- Update CLAUDE.md with database safety warnings
2025-09-26 13:48:36 -04:00

3.4 KiB

Claude Development Notes

Project Setup

This project uses a Makefile for most development operations. Use make commands instead of running tools directly.

Common Development Tasks

Testing

  • Run tests: make test
    • This installs development dependencies and runs the test suite with py.test
    • Tests are located in make_post_sell/tests/

Installation & Setup

  • Install from source for development: make install-from-source
  • Install from PyPI: make install-from-pypi
  • Initialize database: make init-db

Development Server

  • Start development server: make serve
    • Runs with auto-reload enabled
    • Uses data/development.ini configuration

Environment Management

  • Create virtual environment: make venv
  • Clean up environment: make clean
  • Activate environment: source env/bin/activate

Code Structure

Key Directories

  • make_post_sell/views/ - View controllers
  • make_post_sell/models/ - Database models
  • make_post_sell/tests/ - Test suite

Important Files

  • make_post_sell/views/cart.py - Cart and checkout logic
  • development.ini - Configuration file

Testing Notes

The project uses pytest with unittest framework. There are three types of tests:

Test Types

  • Unit tests (test_models.py) - Test individual model methods and properties in isolation
  • Integration tests (test_integration.py) - Test interactions between models and business logic
  • Functional tests (test_functional.py) - End-to-end tests through the web interface

Running Tests

Before running tests: Source environment variables with source vars.sh to set required Stripe API keys and other configuration.

# Run all tests
make test

# Run specific test types
env/bin/py.test make_post_sell/tests/test_models.py     # Unit tests
env/bin/py.test make_post_sell/tests/test_integration.py # Integration tests  
env/bin/py.test make_post_sell/tests/test_functional.py  # Functional tests

# Run with coverage
env/bin/py.test --cov=make_post_sell.models.cart --cov-report=term-missing make_post_sell/tests/test_models.py::TestCart

Current Coverage

  • Cart model unit tests cover critical business logic like requires_payment threshold (64 cents)
  • Integration tests verify the original AttributeError bug fix for free coupon checkout
  • Functional tests provide end-to-end coverage of cart/checkout/payment flows

Database Location

The SQLite database is located at: data/make_post_sell.sqlite

CRITICAL WARNING: NEVER delete or remove database files without explicit user permission. The database contains production data and cannot be easily recovered. Always ask before any destructive operations.

MANDATORY: ALWAYS create a backup of the database before any database operations (migrations, schema changes, etc.):

cp data/make_post_sell.sqlite data/make_post_sell.sqlite.backup-$(date +%Y%m%d-%H%M%S)

Query crypto payments:

SELECT * FROM mps_crypto_payment WHERE id = 'payment-uuid-here';

Common Issues and Solutions

UUID Objects

Always use uuid_str when you need a string copy of the identifier. Models inherit uuid_str property from RBase.

Commit Message Guidelines

CRITICAL: Do not include Claude Code attribution in commit messages. Attributing human work to Claude is inappropriate and misrepresents the actual authorship of the code. All code changes should be attributed to the human developer who reviewed, approved, and committed the work.