Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ The project follows a modular Django app structure within the `pythonie/` direct

Multiple settings files in `pythonie/pythonie/settings/`:
- `base.py`: Shared settings, uses `dj_database_url` for database configuration
- `dev.py`: SQLite database, local Redis, DEBUG=True
- `tests.py`: Test-specific settings with SQLite and mock Redis
- `dev.py`: SQLite database, DEBUG=True
- `tests.py`: Test-specific settings with SQLite
- `production.py`: Heroku production settings
- `pgdev.py`: PostgreSQL development settings

Expand All @@ -43,7 +43,6 @@ Always specify settings module: `--settings=pythonie.settings.dev` (or `tests`,

- Django 6.0
- Wagtail 8.1 (CMS framework)
- Redis (caching, configured via `REDISCLOUD_URL`)
- WhiteNoise (static file serving)
- boto3/django-storages (S3 integration)
- Delorean/python-dateutil (date handling)
Expand All @@ -68,7 +67,7 @@ uv run python pythonie/manage.py runserver --settings=pythonie.settings.dev

### Docker Development (preferred)

Uses Task for most operations. Requires docker-compose with services: web, postgres, redis.
Uses Task for most operations. Requires docker-compose with services: web, postgres.

```bash
# Build docker image
Expand Down Expand Up @@ -237,17 +236,12 @@ Pages use StreamFields for flexible content blocks (heading, paragraph, video, i

Django commands MUST include `--settings=pythonie.settings.<module>`. The default in `manage.py` is `pythonie.settings` which won't work without proper environment setup.

### Redis Configuration

Development expects Redis at `127.0.0.1:6379` or via `REDISCLOUD_URL` environment variable. Configure via `pythonie.settings.configure.configure_redis()`.

### Environment Variables

Key variables (see `development.env` / `production.env`):
- `DJANGO_SECRET_KEY`: Required for production
- `DJANGO_SETTINGS_MODULE`: Settings module path
- `DATABASE_URL`: PostgreSQL connection (Heroku format)
- `REDISCLOUD_URL`: Redis connection
- `MEETUP_KEY`: Meetup.com API key
- `PGDATABASE`, `PGUSER`, `PGPASSWORD`, `PGHOST`: PostgreSQL credentials for Docker
- `HEROKU_APP`: Heroku application name (set in Taskfile.yaml)
Expand All @@ -258,7 +252,7 @@ Static files collected via WhiteNoise with `CompressedManifestStaticFilesStorage

### Testing Strategy

Tests use `pythonie.settings.tests` which configures SQLite and mock Redis. Run with `--verbosity=2` or `--verbosity=3` for detailed output.
Tests use `pythonie.settings.tests` which configures SQLite. Test data is generated with `model_bakery`. Run with `--verbosity=2` or `--verbosity=3` for detailed output.

### Deployment

Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ task docker:build
# or: make docker-build

# Start services
docker-compose up -d postgres redis
docker-compose up -d postgres

# Run migrations
task django:migrate
Expand Down Expand Up @@ -322,7 +322,7 @@ Place tests in `test_*.py` files within each app:

```python
from django.test import TestCase
from model_mommy import mommy
from model_bakery import baker

from pythonie.sponsors.models import Sponsor

Expand All @@ -332,15 +332,15 @@ class SponsorTestCase(TestCase):

def setUp(self):
"""Set up test fixtures."""
self.sponsor = mommy.make(Sponsor, name="Test Sponsor")
self.sponsor = baker.make(Sponsor, name="Test Sponsor")

def test_sponsor_str(self):
"""Test string representation."""
self.assertEqual(str(self.sponsor), "Test Sponsor")

def test_sponsor_creation(self):
"""Test sponsor can be created."""
sponsor = mommy.make(Sponsor)
sponsor = baker.make(Sponsor)
self.assertIsNotNone(sponsor.id)
```

Expand Down
59 changes: 8 additions & 51 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
- **CMS**: Wagtail 8.1
- **Python**: 3.13.11 (or any Python 3.13.x - required)
- **Database**: PostgreSQL 17 (prod and dev via Docker)
- **Cache**: Redis 6.2
- **Storage**: AWS S3 (prod), Local (dev)
- **Server**: Gunicorn (prod), Runserver (dev)
- **Containerization**: Docker + docker-compose
Expand Down Expand Up @@ -70,7 +69,6 @@ pythonie/
│ ├── production.py # Heroku, S3, PostgreSQL
│ ├── tests.py # Tests with in-memory SQLite
│ └── pgdev.py # Local PostgreSQL
├── configure.py # Helpers (configure_redis)
└── patches.py # Third-party patches (SlideShare OEmbed)
```

Expand Down Expand Up @@ -118,8 +116,8 @@ prek install
# 2. Build Docker image
task docker:build

# 3. Start PostgreSQL and Redis
docker-compose up -d postgres redis
# 3. Start PostgreSQL
docker-compose up -d postgres

# 4. Create/migrate the database
task django:migrate
Expand Down Expand Up @@ -172,9 +170,6 @@ PGUSER=postgres
PGPASSWORD=postgres
PGHOST=postgres

# Redis
REDISCLOUD_URL=redis://redis:6379/0

# Meetup.com (optional)
MEETUP_KEY=your-meetup-api-key

Expand Down Expand Up @@ -660,15 +655,15 @@ uv run python pythonie/manage.py test pythonie.meetups.test_meetups.MeetupTestCa

### Test Tools

**model_mommy**: Test data generation
**model_bakery**: Test data generation
```python
from model_mommy import mommy
from model_bakery import baker

# Create Meetup with random data
meetup = mommy.make(Meetup)
meetup = baker.make(Meetup)

# With specific values
meetup = mommy.make(Meetup, name="Test Meetup", rsvps=10)
meetup = baker.make(Meetup, name="Test Meetup", rsvps=10)
```

**unittest.mock**: Mock external APIs
Expand All @@ -684,19 +679,12 @@ def test_update_meetups(self, mock_get):
update() # Call function with mock
```

**fakeredis**: Mock Redis
```python
# Automatically configured in pythonie.settings.tests
REDIS = configure_redis(None, test=True) # Returns FakeStrictRedis
```

### Test Configuration

**Settings** (`pythonie/pythonie/settings/tests.py`):
```python
DEBUG = True
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
REDIS = configure_redis(None, test=True) # FakeRedis
LOGGING = {
"loggers": {
"pythonie": {"level": "ERROR"} # Less verbose
Expand All @@ -709,12 +697,12 @@ LOGGING = {
**Model test example**:
```python
from django.test import TestCase
from model_mommy import mommy
from model_bakery import baker
from pythonie.meetups.models import Meetup

class MeetupTestCase(TestCase):
def setUp(self):
self.meetup = mommy.make(
self.meetup = baker.make(
Meetup,
name="Python Ireland Monthly Meetup",
id="test-meetup-1"
Expand Down Expand Up @@ -752,7 +740,6 @@ class HomePageTestCase(TestCase):

**Addons**:
- **Heroku Postgres**: Main database
- **RedisCloud**: Redis cache
- **AWS S3**: Media storage (external)

**Buildpacks**:
Expand All @@ -773,7 +760,6 @@ web: gunicorn --chdir pythonie pythonie.wsgi --log-file -
```bash
# Heroku sets these automatically:
DATABASE_URL
REDISCLOUD_URL

# Configure manually:
heroku config:set DJANGO_SECRET_KEY=$(python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")
Expand Down Expand Up @@ -868,35 +854,6 @@ export DJANGO_SETTINGS_MODULE=pythonie.settings.dev
uv run python pythonie/manage.py runserver
```

### Problem: Redis Connection Error

**Error**:
```
ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
```

**Solution Docker**:
```bash
# Check if Redis is running
docker-compose ps redis

# Start Redis
docker-compose up -d redis
```

**Solution Local**:
```bash
# Install Redis
brew install redis # macOS

# Start Redis
redis-server

# Or disable Redis in dev:
# pythonie/pythonie/settings/dev.py
REDIS = None
```

### Problem: Meetup update returns nothing

**Error**: `update()` returns 0 meetups
Expand Down
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This is the Python Ireland (https://python.ie) website, built with Django 6.0 an
- Python 3.13, [uv](https://docs.astral.sh/uv/) and [prek](https://github.com/j178/prek) (git hooks), all pinned in `mise.toml`: run `mise install`, or see [Git Hooks](#git-hooks-prek) for other ways to install prek
- Docker & Docker Compose (for containerized development - recommended)
- [Task](https://taskfile.dev/) (optional but recommended)
- Redis (only for local non-Docker development)
- Environment variables file as per [the instructions here](#environment-variables)

## Quick Start (Docker - Recommended)
Expand All @@ -26,7 +25,7 @@ This is the Python Ireland (https://python.ie) website, built with Django 6.0 an

3. Start supporting services:
```bash
docker compose up -d postgres redis
docker compose up -d postgres
```

4. Run database migrations:
Expand Down Expand Up @@ -66,11 +65,9 @@ If you prefer to develop without Docker:
6. Set up the database: `uv run python pythonie/manage.py migrate --settings=pythonie.settings.dev`
7. Generate sample data: `task django:generate-sample-data` (or `uv run python pythonie/manage.py generate_sample_data --settings=pythonie.settings.dev`)
8. Create a superuser: `uv run python pythonie/manage.py createsuperuser --settings=pythonie.settings.dev`
9. Install and run Redis server locally: `redis-server`
10. Set Redis environment variable: `export REDISCLOUD_URL=127.0.0.1:6379`
11. Run the server: `uv run python pythonie/manage.py runserver --settings=pythonie.settings.dev`
12. Visit http://127.0.0.1:8000/ to see the site with sample content
13. Visit http://127.0.0.1:8000/admin/ to log in to Wagtail admin
9. Run the server: `uv run python pythonie/manage.py runserver --settings=pythonie.settings.dev`
10. Visit http://127.0.0.1:8000/ to see the site with sample content
11. Visit http://127.0.0.1:8000/admin/ to log in to Wagtail admin

## Project Structure

Expand Down Expand Up @@ -222,13 +219,11 @@ PGDATABASE=pythonie
PGUSER=postgres
PGPASSWORD=pythonie
PGHOST=postgres
REDISCLOUD_URL=redis://redis:6379 # Optional, for Redis integration
MEETUP_KEY=your_meetup_api_key # Optional, for Meetup.com sync
```

For local development without Docker:
```bash
export REDISCLOUD_URL=127.0.0.1:6379
export MEETUP_KEY=your_meetup_api_key # Get from https://secure.meetup.com/meetup_api/key/
```

Expand Down Expand Up @@ -261,10 +256,6 @@ This project uses several tools to streamline development:

## Troubleshooting

### Redis Connection Errors
- **Docker**: Redis should work automatically via `docker compose`
- **Local**: Ensure Redis is running (`redis-server`) and set `REDISCLOUD_URL=127.0.0.1:6379`

### Database Issues
- Reset with production data: `task database:reset`
- Check PostgreSQL is running: `docker compose ps postgres`
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ tasks:
stack:pull:
desc: Pull the docker images for the stack
cmds:
- docker compose pull postgres redis
- docker compose pull postgres

stack:services:
desc: List the services from the docker compose file
Expand Down
1 change: 0 additions & 1 deletion development.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ PGDATABASE=pythonie
PGUSER=postgres
PGPASSWORD=pythonie
PGHOST=postgres
REDISCLOUD_URL=redis://redis:6379
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ services:
command: /usr/bin/fish
depends_on:
- postgres
- redis
env_file:
- development.env
environment:
Expand All @@ -26,9 +25,6 @@ services:
environment:
POSTGRES_PASSWORD: pythonie

redis:
image: redis:6.2

test:
image: python.ie/website-dev
environment:
Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ dependencies = [
"django-storages>=1.14.6",
"django-taggit>=6.1.0",
"gunicorn>=26.2.0",
"pandas>=3.0.6",
"psycopg[binary]>=3.3.6",
"pydantic>=2.13.5",
"python-dateutil>=2.9.0.post0",
"pytz>=2026.4",
"redis>=8.1.0",
"requests>=2.34.2",
"wagtail>=8.1,<8.2",
"whitenoise>=6.12.0",
Expand All @@ -34,9 +30,8 @@ dependencies = [
dev = [
"coverage>=7.16.1",
"django-debug-toolbar>=8.0.0",
"fakeredis>=2.38.0",
"isort>=9.0.1",
"model_mommy>=2.0.0",
"model-bakery>=1.25.0",
"pip-audit>=2.10.1",
"pipdeptree>=4.2.5",
"ruff==0.16.9", # pinned: ruff minor releases change the default lint rule set
Expand Down
7 changes: 3 additions & 4 deletions pythonie/meetups/test_meetups.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import datetime
from datetime import UTC, datetime
from unittest.mock import patch

from django.test import TestCase
from django.utils import timezone
from model_mommy import mommy
from pytz import UTC
from model_bakery import baker

from meetups import utils
from meetups.models import Meetup, next_n_months
Expand All @@ -22,7 +21,7 @@
class MeetupModelTests(TestCase):
def test_create_meetup(self):
now = timezone.now()
meetup = mommy.make(Meetup, time=now, created=now, updated=now)
meetup = baker.make(Meetup, time=now, created=now, updated=now)
self.assertIsNotNone(meetup.id)
self.assertIsNotNone(meetup.name)
self.assertIsNotNone(meetup.description)
Expand Down
22 changes: 0 additions & 22 deletions pythonie/pythonie/settings/configure.py

This file was deleted.

Loading