|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the Python Ireland (python.ie / pycon.ie) website, built with Django 5.0 and Wagtail CMS 6.2. It manages content for the Python Ireland community including meetups, sponsors, speakers, and PyCon talks/sessions. |
| 8 | + |
| 9 | +### Python Version |
| 10 | + |
| 11 | +This project requires **Python 3.12**. All code must be compatible with Python 3.12 and should not use features from newer versions. When developing locally without Docker, ensure you are using Python 3.12.x. |
| 12 | + |
| 13 | +## Architecture |
| 14 | + |
| 15 | +### Django Apps Structure |
| 16 | + |
| 17 | +The project follows a modular Django app structure within the `pythonie/` directory: |
| 18 | + |
| 19 | +- **core**: Base Wagtail pages (HomePage, SimplePage) with StreamField content blocks. Implements PageSegment snippets and mixins (MeetupMixin, SponsorMixin) for common functionality. |
| 20 | +- **meetups**: Manages Meetup.com integration for Python Ireland meetups. Includes a management command `updatemeetups` to sync with Meetup API. |
| 21 | +- **sponsors**: Sponsor management with SponsorshipLevel relationships. |
| 22 | +- **speakers**: Speaker and Session (talk/workshop) management for conferences. Includes Sessionize integration via management commands (`import-sessionize`, `update-sessionize-json-stream`). |
| 23 | + |
| 24 | +### Settings Configuration |
| 25 | + |
| 26 | +Multiple settings files in `pythonie/pythonie/settings/`: |
| 27 | +- `base.py`: Shared settings, uses `dj_database_url` for database configuration |
| 28 | +- `dev.py`: SQLite database, local Redis, DEBUG=True |
| 29 | +- `tests.py`: Test-specific settings with SQLite and mock Redis |
| 30 | +- `production.py`: Heroku production settings |
| 31 | +- `pgdev.py`: PostgreSQL development settings |
| 32 | + |
| 33 | +Always specify settings module: `--settings=pythonie.settings.dev` (or `tests`, `production`, etc.) |
| 34 | + |
| 35 | +### Database |
| 36 | + |
| 37 | +- Development (default): SQLite at `pythonie/db.sqlite3` |
| 38 | +- Docker/Tests: PostgreSQL 13 in docker-compose |
| 39 | +- Production: PostgreSQL on Heroku via `DATABASE_URL` environment variable |
| 40 | + |
| 41 | +### Key Dependencies |
| 42 | + |
| 43 | +- Django ~5.0.0 |
| 44 | +- Wagtail ~6.2.0 (CMS framework) |
| 45 | +- Redis (caching, configured via `REDISCLOUD_URL`) |
| 46 | +- WhiteNoise (static file serving) |
| 47 | +- boto3/django-storages (S3 integration) |
| 48 | +- Delorean/python-dateutil (date handling) |
| 49 | + |
| 50 | +## Common Commands |
| 51 | + |
| 52 | +### Local Development (without Docker) |
| 53 | + |
| 54 | +```bash |
| 55 | +# Setup |
| 56 | +python3 -m venv pythonie-venv |
| 57 | +source pythonie-venv/bin/activate |
| 58 | +pip install -r requirements.txt |
| 59 | + |
| 60 | +# Database |
| 61 | +python pythonie/manage.py migrate --settings=pythonie.settings.dev |
| 62 | +python pythonie/manage.py createsuperuser --settings=pythonie.settings.dev |
| 63 | + |
| 64 | +# Run server |
| 65 | +python pythonie/manage.py runserver --settings=pythonie.settings.dev |
| 66 | + |
| 67 | +# Access admin at http://127.0.0.1:8000/admin/ |
| 68 | +``` |
| 69 | + |
| 70 | +### Docker Development (preferred) |
| 71 | + |
| 72 | +Uses Task for most operations. Requires docker-compose with services: web, postgres, redis, minio. |
| 73 | + |
| 74 | +```bash |
| 75 | +# Build docker image |
| 76 | +task docker:build |
| 77 | +# or: make docker-build |
| 78 | + |
| 79 | +# Run development server |
| 80 | +task run |
| 81 | +# or: docker compose run --rm --service-ports web python pythonie/manage.py runserver 0.0.0.0:8000 |
| 82 | + |
| 83 | +# Shell access |
| 84 | +task shell |
| 85 | +# or: docker compose run --rm web /bin/bash |
| 86 | + |
| 87 | +# Django shell |
| 88 | +task django:shell-plus |
| 89 | + |
| 90 | +# Database migrations |
| 91 | +task django:make-migrations |
| 92 | +task django:migrate |
| 93 | +``` |
| 94 | + |
| 95 | +### Testing |
| 96 | + |
| 97 | +```bash |
| 98 | +# Run all tests (local) |
| 99 | +python pythonie/manage.py test pythonie --settings=pythonie.settings.tests --verbosity=2 |
| 100 | + |
| 101 | +# Run all tests (docker) |
| 102 | +make docker-tests |
| 103 | +# or: task tests |
| 104 | + |
| 105 | +# Run single test |
| 106 | +python pythonie/manage.py test pythonie.meetups.test_meetups --settings=pythonie.settings.tests |
| 107 | +``` |
| 108 | + |
| 109 | +### Code Quality |
| 110 | + |
| 111 | +```bash |
| 112 | +# Format code with ruff |
| 113 | +task code:format |
| 114 | +# or: toast code:format |
| 115 | +# or: python -m ruff format pythonie |
| 116 | + |
| 117 | +# Lint (legacy, may still be used) |
| 118 | +flake8 pythonie/ |
| 119 | +``` |
| 120 | + |
| 121 | +### Dependency Management |
| 122 | + |
| 123 | +Uses `uv` for fast Python package management. Dependencies are defined in `.in` files and compiled to `.txt` files: |
| 124 | + |
| 125 | +```bash |
| 126 | +# Recompile all dependencies |
| 127 | +task dependencies:compute |
| 128 | +# or: toast deps:compute |
| 129 | + |
| 130 | +# Check outdated packages |
| 131 | +task dependencies:outdated |
| 132 | + |
| 133 | +# Upgrade all dependencies |
| 134 | +task dependencies:upgrade |
| 135 | + |
| 136 | +# Upgrade only Wagtail |
| 137 | +task dependencies:upgrade:wagtail |
| 138 | + |
| 139 | +# Upgrade specific package |
| 140 | +task upgrade:package PACKAGE=django |
| 141 | +``` |
| 142 | + |
| 143 | +### Database Operations (Heroku) |
| 144 | + |
| 145 | +```bash |
| 146 | +# Pull production database to local |
| 147 | +task database:pull |
| 148 | + |
| 149 | +# Push local database to production |
| 150 | +task database:push |
| 151 | + |
| 152 | +# Reset local with fresh production copy |
| 153 | +task database:reset |
| 154 | + |
| 155 | +# View Heroku backups |
| 156 | +task heroku:database:backups |
| 157 | + |
| 158 | +# Create new backup |
| 159 | +task heroku:database:run-backup |
| 160 | +``` |
| 161 | + |
| 162 | +### Conference Management |
| 163 | + |
| 164 | +```bash |
| 165 | +# Import speakers/sessions from Sessionize |
| 166 | +task pycon:import:sessionize |
| 167 | +# or: docker compose run web python pythonie/manage.py import-sessionize --file sessionize.xlsx |
| 168 | + |
| 169 | +# Update from Sessionize JSON stream |
| 170 | +task pycon:import:sessionize:json |
| 171 | +``` |
| 172 | + |
| 173 | +## Important Implementation Notes |
| 174 | + |
| 175 | +### Wagtail Page Models |
| 176 | + |
| 177 | +All page types inherit from `wagtail.models.Page`. The page tree structure: |
| 178 | +- HomePage (root, can have child HomePage or SimplePage) |
| 179 | +- SimplePage |
| 180 | +- SpeakersPage → Speaker pages |
| 181 | +- TalksPage → Session pages |
| 182 | + |
| 183 | +Pages use StreamFields for flexible content blocks (heading, paragraph, video, image, slide, html). |
| 184 | + |
| 185 | +### Settings Module Requirement |
| 186 | + |
| 187 | +Django commands MUST include `--settings=pythonie.settings.<module>`. The default in `manage.py` is `pythonie.settings` which won't work without proper environment setup. |
| 188 | + |
| 189 | +### Redis Configuration |
| 190 | + |
| 191 | +Development expects Redis at `127.0.0.1:6379` or via `REDISCLOUD_URL` environment variable. Configure via `pythonie.settings.configure.configure_redis()`. |
| 192 | + |
| 193 | +### Environment Variables |
| 194 | + |
| 195 | +Key variables (see `development.env` / `production.env`): |
| 196 | +- `DJANGO_SECRET_KEY`: Required for production |
| 197 | +- `DJANGO_SETTINGS_MODULE`: Settings module path |
| 198 | +- `DATABASE_URL`: PostgreSQL connection (Heroku format) |
| 199 | +- `REDISCLOUD_URL`: Redis connection |
| 200 | +- `MEETUP_KEY`: Meetup.com API key |
| 201 | +- `PGDATABASE`, `PGUSER`, `PGPASSWORD`, `PGHOST`: PostgreSQL credentials for Docker |
| 202 | + |
| 203 | +### Static Files |
| 204 | + |
| 205 | +Static files collected via WhiteNoise with `CompressedManifestStaticFilesStorage`. SCSS compiled via django-compressor and django-libsass. |
| 206 | + |
| 207 | +### Testing Strategy |
| 208 | + |
| 209 | +Tests use `pythonie.settings.tests` which configures SQLite and mock Redis. Run with `--verbosity=2` or `--verbosity=3` for detailed output. |
| 210 | + |
| 211 | +### Deployment |
| 212 | + |
| 213 | +The project is hosted on Heroku. |
| 214 | + |
| 215 | +### Documentation Language |
| 216 | + |
| 217 | +All documentation and code comments must be written in English to ensure all contributors can collaborate effectively. |
| 218 | + |
| 219 | +### Git Commits |
| 220 | + |
| 221 | +When creating git commits, do not include any mention of Claude, Claude Code, or AI assistance in commit messages. Commit messages should focus solely on describing the changes made, without attribution to the tool used to make them. |
0 commit comments