211 lines
6.7 KiB
Markdown
211 lines
6.7 KiB
Markdown
# Communication to Care
|
|
|
|
The Django website for **Communication to Care**, published at **com2care.com**. It presents the
|
|
com2care medical-imaging research platform, product modules, learning videos, downloads, FAQs,
|
|
and support information.
|
|
|
|
## Start with Docker
|
|
|
|
Docker Compose includes working local defaults, database migrations, demo content, and the first
|
|
admin account. No setup command or `.env` file is required for a local demonstration.
|
|
|
|
```bash
|
|
docker compose up -d --build
|
|
```
|
|
|
|
Open:
|
|
|
|
- Website: <http://localhost:8000>
|
|
- Admin: <http://localhost:8000/admin/>
|
|
|
|
Initial local admin credentials:
|
|
|
|
```text
|
|
Username: admin
|
|
Password: cmosV6Tw46Odv7UN
|
|
```
|
|
|
|
Change the password immediately after the first login using **Django Admin → Change password**.
|
|
The startup process never resets an existing admin password unless credential synchronization is
|
|
explicitly enabled.
|
|
|
|
## Automatic startup behavior
|
|
|
|
Every web-container start performs these idempotent steps:
|
|
|
|
1. Wait for PostgreSQL.
|
|
2. Collect static files.
|
|
3. Apply Django migrations.
|
|
4. Normalize public database text and URLs to the Communication to Care identity.
|
|
5. Seed demonstration content only when all public content tables are empty.
|
|
6. Create the configured admin account only when it does not exist.
|
|
7. Start Django or Gunicorn.
|
|
|
|
Demo content includes:
|
|
|
|
- A com2care product with five medical-imaging modules.
|
|
- Articles, structured specifications, FAQs, and release examples.
|
|
- Homepage and About page sections with local images.
|
|
- A generated Communication to Care hero image.
|
|
- Relevant external YouTube tutorials for DICOM review and image segmentation.
|
|
- `support@com2care.com` contact data.
|
|
|
|
Content created or edited by an admin is preserved on later container restarts.
|
|
|
|
## Project permissions in Django Admin
|
|
|
|
Published projects remain visible to everyone on the public website. Project
|
|
permissions apply only inside Django Admin. Users with Staff status can open the
|
|
admin panel; by default, each staff user can view and edit only main projects
|
|
and sub-projects they created. Main and sub-projects have independent access.
|
|
|
|
A superuser can configure a user under **Admin → Users → [user]**:
|
|
|
|
- **Project access policy**: own projects (default), no projects by default,
|
|
view all, or view and edit all.
|
|
- **Project access overrides**: choose one main project or sub-project per row
|
|
and set no access, view only, or view and edit. An override wins over the
|
|
default and the all-projects policy.
|
|
|
|
Project articles and videos inherit the permissions of their parent project.
|
|
Existing projects without a recorded creator remain accessible to superusers;
|
|
assign access overrides for other staff users as needed.
|
|
|
|
## Optional configuration
|
|
|
|
Copy `.env.example` to `.env` only when you want to override the local defaults:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
Important variables:
|
|
|
|
| Variable | Purpose |
|
|
|---|---|
|
|
| `DJANGO_SECRET_KEY` | Required strong secret for production |
|
|
| `ALLOWED_HOSTS` | Hostnames, including `com2care.com` and `comp2care.com` |
|
|
| `CSRF_TRUSTED_ORIGINS` | Full trusted origins with `https://`; both production domains are always included |
|
|
| `POSTGRES_DB` | PostgreSQL database name |
|
|
| `POSTGRES_USER` | PostgreSQL user |
|
|
| `POSTGRES_PASSWORD` | PostgreSQL password |
|
|
| `DJANGO_SUPERUSER_ENABLED` | Set `False` to disable automatic admin creation |
|
|
| `DJANGO_SUPERUSER_USERNAME` | First admin username |
|
|
| `DJANGO_SUPERUSER_EMAIL` | First admin email |
|
|
| `DJANGO_SUPERUSER_PASSWORD` | First admin password |
|
|
| `DJANGO_SUPERUSER_SYNC_PASSWORD` | Set `True` for one restart to rotate an existing admin password from environment values |
|
|
|
|
For a server-side password rotation, set the new `DJANGO_SUPERUSER_PASSWORD`, temporarily set
|
|
`DJANGO_SUPERUSER_SYNC_PASSWORD=True`, restart the web service once, then restore it to `False`.
|
|
An admin can always change their own password through Django Admin without changing server
|
|
configuration.
|
|
|
|
## Production
|
|
|
|
Use strong values in `.env`, terminate TLS with a reverse proxy, and start only the production
|
|
Compose file:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.yml up -d --build
|
|
```
|
|
|
|
At minimum, replace these local defaults in production:
|
|
|
|
- `DJANGO_SECRET_KEY`
|
|
- `POSTGRES_PASSWORD`
|
|
- `DJANGO_SUPERUSER_PASSWORD`
|
|
- `SECURE_SSL_REDIRECT=True`
|
|
|
|
The default production host configuration already includes `com2care.com` and
|
|
`www.com2care.com`.
|
|
|
|
## Manual development
|
|
|
|
Requirements:
|
|
|
|
- Python 3.12+
|
|
- PostgreSQL 14+
|
|
|
|
```bash
|
|
python -m venv .venv
|
|
source .venv/bin/activate
|
|
pip install -r requirements-dev.txt
|
|
cp .env.example .env
|
|
python manage.py migrate
|
|
python manage.py seed_content --if-empty
|
|
python manage.py ensure_superuser
|
|
python manage.py runserver
|
|
```
|
|
|
|
### Persistent local preview without Docker
|
|
|
|
The local preview uses `instance/preview.sqlite3`, which survives server restarts and is
|
|
ignored by Git. Put the preview admin credentials in `instance/preview_admin.env`
|
|
(also ignored by Git):
|
|
|
|
```text
|
|
DJANGO_SUPERUSER_USERNAME=admin
|
|
DJANGO_SUPERUSER_EMAIL=admin@localhost
|
|
DJANGO_SUPERUSER_PASSWORD=your-local-password
|
|
DJANGO_SUPERUSER_SYNC_PASSWORD=False
|
|
```
|
|
|
|
Then start the preview with `./run_preview.sh`. It applies migrations and ensures the
|
|
admin account exists before starting the server. Existing passwords are preserved;
|
|
set `DJANGO_SUPERUSER_SYNC_PASSWORD=True` for one start only if you intentionally
|
|
need to reset the account password. This preview database is separate from the
|
|
PostgreSQL database used by Docker and production.
|
|
|
|
## Management commands
|
|
|
|
```bash
|
|
# Add demo data only to a completely empty public database
|
|
python manage.py seed_content --if-empty
|
|
|
|
# Intentionally replace all public content with the demo dataset
|
|
python manage.py seed_content --flush
|
|
|
|
# Normalize existing public text, slugs, URLs, and email addresses
|
|
python manage.py normalize_brand
|
|
|
|
# Create or optionally synchronize the configured admin
|
|
python manage.py ensure_superuser
|
|
```
|
|
|
|
## Tests
|
|
|
|
```bash
|
|
python manage.py test apps
|
|
```
|
|
|
|
or:
|
|
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
## Project structure
|
|
|
|
```text
|
|
config/ Django settings and root URLs
|
|
apps/core/ Branding, contact settings, bootstrap commands
|
|
apps/pages/ Home, About, FAQ, Contact, custom pages, videos
|
|
apps/products/ Products, articles, releases, product videos
|
|
templates/ Django templates
|
|
static/css/main.css Site design system
|
|
static/images/ com2care brand and editorial assets
|
|
static/js/main.js Navigation and interaction behavior
|
|
docker-compose.yml PostgreSQL and production web service
|
|
docker-compose.override.yml Local development override
|
|
entrypoint.sh Automated database and content bootstrap
|
|
```
|
|
|
|
## Technology
|
|
|
|
- Django
|
|
- PostgreSQL 16
|
|
- Gunicorn
|
|
- WhiteNoise
|
|
- Docker Compose
|
|
- Vanilla HTML, CSS, and JavaScript
|