bartczak-pa / Cookbook

0 stars 0 forks source link

Added support for Category and Recipe slugs #15

Closed bartczak-pa closed 2 months ago

bartczak-pa commented 2 months ago

Summary by Sourcery

Add support for slugs in Category and Recipe models to enhance URL structure and navigation. Implement a new view to list recipes by category and update existing views and templates to utilize slugs. Introduce tests to validate the new functionality.

New Features:

Enhancements:

Tests:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request adds support for Category and Recipe slugs, enhancing URL structure and improving SEO. It introduces new views, updates existing ones, modifies models to include slug fields, adjusts URL patterns, and adds corresponding tests. The changes also include template updates to reflect the new URL structure and minor improvements to the user interface.

File-Level Changes

Change Details Files
Added slug fields to Category and Recipe models
  • Introduced AutoSlugField for Category and Recipe models
  • Updated migrations to include new slug fields
  • Modified existing migrations to incorporate slug fields
recipes/models.py
recipes/migrations/0001_initial.py
recipes/migrations/0002_recipe_slug.py
recipes/migrations/0003_alter_recipe_slug.py
recipes/migrations/0004_alter_category_slug.py
Updated views to support new URL structure with slugs
  • Modified RecipeDetailView to use category_slug in get_queryset
  • Added CategoryRecipeListView for displaying recipes by category
  • Updated get_context_data methods to include necessary information
recipes/views.py
Adjusted URL patterns to use slugs instead of primary keys
  • Updated recipe detail URL to use category_slug and recipe slug
  • Added new URL pattern for recipes by category
recipes/urls.py
Updated templates to reflect new URL structure and improve UI
  • Modified recipe list template to use new URL structure
  • Updated category list template to link to category-specific recipe lists
  • Added new template for displaying recipes by category
recipes/templates/recipes/recipe_list.html
recipes/templates/recipes/category_list.html
recipes/templates/recipes/category_recipes_list.html
Added comprehensive tests for new and modified views
  • Created tests for CategoryRecipeListView
  • Added tests for updated RecipeDetailView
  • Included parameterized tests for various scenarios
recipes/tests/test_views.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.