diff --git a/docker.md b/docker.md index f4cb251..eaeb45c 100644 --- a/docker.md +++ b/docker.md @@ -100,7 +100,13 @@ Or to promote a user to superuser, run: docker compose exec web python manage.py promote_user_to_superuser me@example.com ``` -Commonly used commands can be added to the `Makefile` for convenience. +You can also use the `make manage` command, passing in `ARGS` like so: + +``` +make manage ARGS='promote_user_to_superuser me@example.com' +``` + +You can add any commonly used commands you want to `custom.mk` for convenience. ## Updating Python packages diff --git a/release-notes.md b/release-notes.md index 79fcbc6..1448448 100644 --- a/release-notes.md +++ b/release-notes.md @@ -3,6 +3,110 @@ Version History and Release Notes Releases of [SaaS Pegasus: The Django SaaS Boilerplate](https://www.saaspegasus.com/) are documented here. +## Version 2024.9 + +There are two big updates in this release: + +1. The Pegasus CLI, which allows you to instantly spin up new apps. +2. E-Commerce/Payments improvements. + +### The Pegasus CLI + +The [Pegasus CLI](https://github.com/saaspegasus/pegasus-cli/) is a standalone command-line tool that allows you +to instantly spin up new Django apps. +You can specify as many data models as you want and it will generate a starting CRUD interface for each of them. + +Here's a quick demo: + +
+ +
+ +**At the moment the CLI only supports HTMX build of Pegasus.** +A React-based implementation is planned for a future date. + +Huge thanks to Peter for his excellent [Pegasus example apps](https://github.com/pcherna/pegasus-example-apps-v2) +project which served as a reference for implementing the CRUD application and pagination. + +### E-Commerce / Payments demo improvements + +This is a series of updates designed to make it easier to build a functional end-to-end application +on top of the e-commerce demo. + +- Added a `ProductConfiguration` model to attach additional metadata to products. +- E-Commerce product URLs and views now use the `ProductConfiguration` `slug` field instead of the Stripe Product IDs. +- Added a `@product_required` decorator that can be used to restrict access to views based on whether the user has purchased a product. +- Added a demo "access product" page that shows how to use the `@product_required` decorator. +- Added `user_owns_product` and `get_valid_user_purchase` helper functions. +- Improved the navigation and use of breadcrumbs in the demo UI. +- **See upgrade notes for information about migrating previous data to the new set up.** + +### Other Changes + +#### Added + +- **Added `django-htmx` and `django-template-partials` as first-class dependencies to HTMX builds.** + These libraries are used by the CLI and will be used for more HTMX-based functionality moving forwards. +- Added `make manage` command to run arbitrary `manage.py` commands in a docker environment. + E.g. `make manage ARGS='createsuperuser'`. +- Added the ability to pass arguments to `make test` in docker. E.g. `make tests ARGS='apps.teams --keepdb'`. + (Thanks David for the suggestion!) + +#### Changed + +- Changed links on the tailwind signup page to use `pg-link` class instead of explict tailwind classes. + (Thanks Peter for the suggestion!) +- Silenced extraneous djstripe warnings when running tests. (Thanks Chris for the suggestion!) +- Added `.vscode` and vs workspace files to the project `.gitignore`. +- Switched from `assert` statements to `raise ValueError` in the e-commerce Stripe checkout confirmation view. +- Moved some of the currency helper functions out of the `subscriptions` app into `utils.billing` so they can be + used in ecommerce workflows even if subscriptions are disabled. +- Set `PYTHONUNBUFFERED` and `PYTHONDONTWRITEBYTECODE` in docker compose file for python containers. + (Thanks Richard for the suggestion!) +- Upgraded Django to 5.1.1. + +#### Fixed + +- Fixed a typo in the help text for the `bootstrap_ecommerce` command. +- Fixed a bug where `user_teams` context processor could cause a crash if auth middeware didn't run + (for example, on a 500 error page in production). + +### Upgrade Notes + +If you have existing `Purchase` data in your application you will need to migrate it to the new `ProductConfiguration` structure. + +This is a three-step process: + +First you will need to apply the database updates, but allow `Purchase.product_configuration` to be null. +Instead of running `./manage.py migrate` you will have to run the following command: + +```bash +./manage.py migrate ecommerce 0002 +``` + +After running this, you can run the following command to migrate the existing data: + +```bash +./manage.py migrate_ecommerce +``` + +The `migrate_ecommerce` management command will: + +1. Create `ProductConfiguration` objects for all products in `settings.ACTIVE_ECOMMERCE_PRODUCT_IDS` +2. Create `ProductConfiguration` objects for all products referenced in existing `Purchase` models. +3. Set `purchase.product_configuration` to the new `ProductConfiguration` object for each `Purchase`. + +Finally, you can make the `Purchase.product_configuration` field non-null, by running: + +```bash +./manage.py migrate ecommerce 0003 +``` + +**New projects, or projects without any existing purchase data can skip these steps and run `./manage.py migrate` directly.** +However, you may still want to run `./manage.py migrate_ecommerce` to populate `ProductConfiguration` objects for your active products. + +*Sep 17, 2024* + ## Version 2024.8.2 This is a maintenance release that includes a number of mostly small fixes and updates, @@ -30,7 +134,7 @@ and updates Django to version 5.1. ### Changed - **Upgraded Django to version 5.1.** -- Upgraded all Python packages to their latest versions. +- Upgraded all Python packages to their latest versions. - Updated Pegasus color CSS variables to use the DaisyUI variables, so that they change when you change DaisyUI themes. (Thanks Peter for the suggestion!) - Removed `custom.mk` if your project was not generated with a `Makefile`. (Thanks Finbar for reporting!) @@ -39,7 +143,7 @@ and updates Django to version 5.1. - Simplified Bulma navbar to use bulma native classes instead of custom CSS. (See upgrade note below.) - Updated default Github repo in `app-spec.yml` to use raw project slug instead of the hyphenated version. (Digital Ocean deployments, only, thanks Richard for suggesting) -- Moved `SERVER_EMAIL` and `DEFAULT_FROM_EMAIL` from `settings_production.py` to main `settings.py` file, +- Moved `SERVER_EMAIL` and `DEFAULT_FROM_EMAIL` from `settings_production.py` to main `settings.py` file, and made it possible to set them via the environment/`.env` file. - Added many more common settings and secrets to the Kamal `deploy.yml` file. @@ -74,13 +178,13 @@ This is a maintenance release which upgrades HTMX to version 2.0 and fixes a han - Switched the default celery pool to [solo](https://docs.celeryq.dev/en/stable/internals/reference/celery.concurrency.solo.html) in development, to fix issues running on Windows. See [updated docs](./celery.md). - Updated in-app help hint to recommend running `./manage.py bootstrap_ecommerce` instead of `./manage.py djstripe_sync_models price`. - + ### Upgrading Htmx 2.0 requires loading new extensions. If you were loading HTMX extensions in your own templates, you will have to upgrade the location of those to the 2.0 versions. -Before: +Before: ``` @@ -115,7 +219,7 @@ This is a maintenance release with many small updates and fixes. `ruff` and the pre-commit hooks are included in the project download. Projects that had already enabled auto-formatting are unaffected by this change. (See upgrade notes below.) - **The example landing pages are now used as the project's landing page instead of being listed in the examples**. - (Bulma and Tailwind builds only.) + (Bulma and Tailwind builds only.) - **Team invitation emails are now better styled, matching the same format as account emails.** (Thanks EJ for the suggestion!) - The `EMAIL_BACKEND` setting is now configurable via an environment variable. Also, added a commented-out example of how to set email settings for a production email provider (Mailgun). @@ -164,7 +268,7 @@ To fix this, remove the social application from either your settings or the data This is hotfix release that addresses a few issues from yesterday's update: -- Fix app styles accidentally being purged during the Docker build process. +- Fix app styles accidentally being purged during the Docker build process. This caused styling on Docker-based deployments for tailwind builds. (Thanks Steve for reporting!) - Moved channels url import to after Django initialization. This fixes an `AppRegistryNotReady` error when deploying asynchronous apps with the AI chat app enabled. @@ -239,7 +343,7 @@ Below is the complete set of changes in this release. - Fixed a bug where team names longer than 50 characters could cause a crash during sign up. - Fixed a bug where multi-factor authentication QR codes had a dark background when dark mode was enabled (Tailwind builds only). (Thanks Artem for reporting!) -- Fixed a bug where it was possible to bypass two-factor-authentication when using the API authentication views. +- Fixed a bug where it was possible to bypass two-factor-authentication when using the API authentication views. (Thanks Finbar for reporting and helping with the fix!) - Fixed a bug where deleting the user's only team while impersonating them resulted in a temporary crash. (Thanks EJ for reporting!) @@ -263,7 +367,7 @@ Below is the complete set of changes in this release. - **Changed the formatter/linter from `black` and `isort` to [ruff](https://github.com/astral-sh/ruff).** See above. - Also addressed a handful of minor linting errors that came up as a result of this change. - Codebase linting is now substantially faster. - - Unused imports are now automatically removed when building your projects. + - Unused imports are now automatically removed when building your projects. - **Celerybeat now uses the `django-celery-beat` library to store tasks in the database instead of on the filesystem.** This improves support for celerybeat on Docker-based platforms. (Thanks Peter and Artem for the suggestion!) - Also added a migration to save the default scheduled tasks in the database. @@ -274,7 +378,7 @@ Below is the complete set of changes in this release. - Changed behavior when team role checks fail from raising a `TeamPermissionError` to returning a 403 response, and updated affected tests. One side effect of this is that the stack traces are removed from successful test runs. - Secret keys should no longer change every time you build your Pegasus project. - They are also now clearly prefixed with `django-insecure-` to indicate that they should be changed in production. + They are also now clearly prefixed with `django-insecure-` to indicate that they should be changed in production. - Updated the default OpenAI chat model to gpt-4o. - Upgraded the openapi client generator to version 7.5.0 and also pinned the version used by `make build-api-client` to the same one. @@ -326,7 +430,7 @@ in Docker. Thanks Mohamed for reporting this! - Fix `api-client` path in the frontend docker container and add to `optimizeDeps` in vite config. - Mount `node_modules` as an anonymous volume in the frontend docker container, so it is not overwritten. -- Automatically create `./frontend/.env` when running `make init` if it doesn't exist. +- Automatically create `./frontend/.env` when running `make init` if it doesn't exist. *May 14, 2024* @@ -380,13 +484,13 @@ The complete release notes are below: - **The AI image generation now supports Dall-E 3 and Stability AI.** - **All generated projects now include a `LICENSE.md` file.** The goal of the license file is not to change how Pegasus can be used in any way, but rather to document those - terms in the codebase itself (previously they were only documented on the [terms page](https://www.saaspegasus.com/terms/)). + terms in the codebase itself (previously they were only documented on the [terms page](https://www.saaspegasus.com/terms/)). For more information you can see the new [license page](https://www.saaspegasus.com/license/). - **Added support for "magic-code login", where a user can login to the site by requesting a code to their email address.** [Documentation.](./configuration.md#enabling-sign-in-by-email-code) - **Google cloud run builds now support Redis.** For details, see the [updated documentation](./deployment/google-cloud.md). (Thanks Forrest for suggesting!) -- Added a `custom.mk` file where you can add additional `make` targets without worrying about future Pegasus upgrades. +- Added a `custom.mk` file where you can add additional `make` targets without worrying about future Pegasus upgrades. (Thanks John for proposing this!) ### Changed @@ -417,7 +521,7 @@ The complete release notes are below: - **SQLite build now properly parse `DATABASE_URL` if it is set. This fixes issues deploying to certain platforms when building with SQLite.** (Thanks Manasvini for reporting!) - Updated allauth documentation links in the README to point to the new [allauth docs site](https://docs.allauth.org/). - (Thanks Shantu for reporting!) + (Thanks Shantu for reporting!) ### Removed @@ -429,7 +533,7 @@ The complete release notes are below: - Removed the no-longer-used `openai_example` app (functionality has been moved to `apps.chat` and `apps.ai_images`). - Removed the no-longer-needed `AccountAdapter` class. This class was previously used to add two-factor support to login, which is now handled natively by allauth. - + ### Upgrading **Two-factor authentication** @@ -448,7 +552,7 @@ compromising their security.** The change of adding the `defer` keyword to `