Skip to content

refactor(media-list): enhance media list layout#23

Merged
PascalRepond merged 1 commit intostagingfrom
rep-layout
Dec 27, 2025
Merged

refactor(media-list): enhance media list layout#23
PascalRepond merged 1 commit intostagingfrom
rep-layout

Conversation

@PascalRepond
Copy link
Copy Markdown
Owner

  • Updated the media list table to include "Review" and "Reviewed on" columns for better visibility of user feedback.
  • Adjusted grid layout to optimize display across different screen sizes.
  • Updated dependencies.

@PascalRepond PascalRepond self-assigned this Dec 27, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

Adds HTMX-powered clamped/full media review partials and corresponding views/URLs, changes Media.score choice labels and migration, restructures media list/item and score display templates, updates CSRF hx-headers formatting, CSS class tweaks for filter badge buttons, and adjusts sample fixture review text.

Changes

Cohort / File(s) Summary
Model & Migration
src/core/models.py, src/core/migrations/0007_alter_media_score.py, src/core/fixtures/sample_data.json
Changed Media.score choice labels from emoji-prefixed strings to plain labels (1–10: Detested…Adored). Added migration altering media.score to IntegerField with null/blank, verbose_name "Review score", and explicit choices. Extended media pk 20 review text in fixture.
Views & URLs (HTMX)
src/core/views.py, src/core/urls.py
Added HTMX view functions media_review_clamped_htmx and media_review_full_htmx and registered URL patterns media/<int:pk>/review-full/ and media/<int:pk>/review-clamped/.
Review Partials
src/templates/partials/media-review-clamped.html, src/templates/partials/media-review-full.html
New partials: clamped template truncates review to 120 chars with a "See more" HTMX button; full template shows full review with a "See less" HTMX button. Both target #review-cell-{{ media.id }}.
Item/List Templates
src/templates/partials/media-items.html, src/templates/partials/media-list.html
Reworked grid items to side-layout with smaller figures (200x300), added inline review container and score-readonly include, converted contributors to interactive links, removed load-more, adjusted table columns (replaced Score/Created at with Review/Reviewed on), and reduced grid breakpoints.
Score Display & Base Template
src/templates/partials/score-readonly.html, src/templates/base.html
Replaced textual score display with compact 1–10 masked-star rating and conditional score badge. Updated hx-headers to JSON-style {"X-CSRFToken":"{{ csrf_token }}"}.
Styling / JS / Templates
src/static/js/base.js, src/templates/media.html
Replaced filter-badge remove button classes from hover:opacity-70 filter-badge-remove to btn btn-ghost btn-xs btn-circle filter-badge-remove in JS and template instances.
CI Workflow
.github/workflows/ci.yml
Removed branch filters from push and pull_request triggers so CI runs on all branches.

Sequence Diagram

sequenceDiagram
    actor User
    participant Browser
    participant HTMX
    participant Server as DjangoServer
    participant DB as Database
    participant Template as TemplateEngine

    User->>Browser: Clicks "See more"
    Browser->>HTMX: hx-get /media/{pk}/review-full/
    HTMX->>Server: GET /media/{pk}/review-full/
    Server->>DB: Query Media by pk
    DB-->>Server: Media record
    Server->>Template: Render media-review-full.html
    Template-->>Server: HTML
    Server-->>HTMX: 200 HTML (full review)
    HTMX->>Browser: Swap innerHTML of `#review-cell-`{pk}
    Browser->>User: Shows full review ("See less")

    User->>Browser: Clicks "See less"
    Browser->>HTMX: hx-get /media/{pk}/review-clamped/
    HTMX->>Server: GET /media/{pk}/review-clamped/
    Server->>DB: Query Media by pk
    DB-->>Server: Media record
    Server->>Template: Render media-review-clamped.html (truncate 120 chars)
    Template-->>Server: HTML
    Server-->>HTMX: 200 HTML (clamped review)
    HTMX->>Browser: Swap innerHTML of `#review-cell-`{pk}
    Browser->>User: Shows truncated review ("See more")
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: media list layout enhancements including new review columns and grid layout adjustments.
Description check ✅ Passed The description aligns with the changeset, mentioning review columns, grid layout optimization, and dependency updates that are present in the files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rep-layout

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41f3df0 and 8ec87b0.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • .github/workflows/ci.yml
  • src/core/fixtures/sample_data.json
  • src/core/migrations/0007_alter_media_score.py
  • src/core/models.py
  • src/core/urls.py
  • src/core/views.py
  • src/static/js/base.js
  • src/templates/base.html
  • src/templates/media.html
  • src/templates/partials/media-items.html
  • src/templates/partials/media-list.html
  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-review-full.html
  • src/templates/partials/score-readonly.html
💤 Files with no reviewable changes (1)
  • .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/templates/partials/media-list.html
  • src/core/fixtures/sample_data.json
  • src/templates/partials/media-review-full.html
  • src/core/urls.py
  • src/templates/partials/score-readonly.html
  • src/static/js/base.js
  • src/templates/base.html
🧰 Additional context used
📓 Path-based instructions (4)
**/*.html

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.html: Prefer HTMX for dynamic interactions rather than vanilla JavaScript
Use Tailwind CSS classes for styling before adding custom CSS
Use HTMX instead of traditional JavaScript AJAX calls

Files:

  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-items.html
  • src/templates/media.html
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: Use English docstrings in Python code
Follow PEP 8 style guidelines for Python code

Files:

  • src/core/models.py
  • src/core/views.py
  • src/core/migrations/0007_alter_media_score.py
**/models.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Models must have an explicit __str__ method

Files:

  • src/core/models.py
**/views.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function-based views (FBV) by default, only use class-based views (CBV) when more appropriate

Files:

  • src/core/views.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: PascalRepond/datakult PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-26T16:12:32.381Z
Learning: Respond in French
📚 Learning: 2025-12-26T15:18:46.932Z
Learnt from: PascalRepond
Repo: PascalRepond/datakult PR: 21
File: src/templates/accounts/profile_edit.html:23-58
Timestamp: 2025-12-26T15:18:46.932Z
Learning: In Django projects, attributes added to a form field's widget via field.widget.attrs.update(...) in the form's __init__ are rendered when using {{ form.field }} in templates. No explicit attribute definitions are needed in the template. This applies to templates under src/templates in Django apps; ensure you update attrs in __init__ for consistent HTMX behavior.

Applied to files:

  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-items.html
  • src/templates/media.html
📚 Learning: 2025-12-27T17:59:56.022Z
Learnt from: PascalRepond
Repo: PascalRepond/datakult PR: 23
File: src/templates/partials/score-readonly.html:2-33
Timestamp: 2025-12-27T17:59:56.022Z
Learning: In src/templates/partials/score-readonly.html, the DaisyUI read-only rating pattern correctly uses `aria-current="true"` on the selected star and applies the same color class (bg-orange-400) to all star elements. DaisyUI's CSS automatically handles which stars are visually filled based on the aria-current position.

Applied to files:

  • src/templates/media.html
🧬 Code graph analysis (2)
src/templates/partials/media-review-clamped.html (1)
src/core/forms.py (1)
  • MediaForm (7-30)
src/core/views.py (2)
src/tests/conftest.py (1)
  • media (20-31)
src/core/models.py (1)
  • Media (23-111)
🪛 Ruff (0.14.10)
src/core/migrations/0007_alter_media_score.py

8-10: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


12-18: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

🔇 Additional comments (8)
src/templates/media.html (1)

75-75: LGTM! Mise à jour cohérente des classes CSS.

Le remplacement des classes de survol par les classes de composants bouton DaisyUI (btn btn-ghost btn-xs btn-circle) améliore la cohérence visuelle et suit les conventions Tailwind CSS. Les 5 boutons de suppression de badge utilisent maintenant le même style.

Also applies to: 83-83, 93-93, 103-103, 113-113

src/core/views.py (1)

206-217: LGTM! Implémentation correcte des vues HTMX.

Les deux nouvelles vues suivent les bonnes pratiques Django :

  • Décorateur @login_required pour la sécurité
  • Utilisation de get_object_or_404 pour la gestion des erreurs
  • Docstrings en anglais conformes aux directives
  • Patron FBV approprié selon les guidelines du projet
src/core/migrations/0007_alter_media_score.py (1)

1-18: LGTM! Migration correcte.

La migration met à jour les choix du champ score en supprimant les préfixes emoji, ce qui simplifie l'affichage. La structure est conforme aux standards Django.

Note : Les avertissements Ruff (RUF012) concernant ClassVar sont des faux positifs connus pour les migrations Django et peuvent être ignorés.

src/core/models.py (1)

86-95: LGTM! Simplification appropriée des libellés.

La suppression des préfixes emoji (⭐) des choix de score améliore la lisibilité tout en conservant les clés numériques (1-10) et les descriptions textuelles. Cela permet un affichage plus flexible dans l'interface utilisateur.

src/templates/partials/media-items.html (3)

6-20: LGTM! Amélioration du layout responsive de la grille.

La restructuration en card-side avec des proportions basis-1/4 pour la figure et basis-3/4 pour le contenu, ainsi que la réduction de la taille d'image (200×300), optimise l'affichage sur différentes tailles d'écran.


25-35: LGTM! Intégration HTMX pour les contributeurs.

La transformation des contributeurs en liens interactifs avec HTMX permet un filtrage dynamique sans rechargement de page. L'utilisation de séparateurs point-virgule améliore la lisibilité, et les attributs HTMX (hx-get, hx-target, hx-include, hx-push-url) suivent les bonnes pratiques définies dans les coding guidelines.

Also applies to: 62-72


36-38: LGTM! Intégration cohérente des évaluations et critiques.

L'ajout de score-readonly et du conteneur de critique avec HTMX (review-cell-{{ media.id }}) dans les deux modes d'affichage (grille et tableau) améliore la visibilité des retours utilisateurs. La structure permet l'expansion/réduction dynamique du texte de la critique via les vues HTMX correspondantes.

Also applies to: 79-82

src/templates/partials/media-review-clamped.html (1)

1-9: Petite incohérence dans la logique de troncature.

Le commentaire mentionne "3 lines" mais l'implémentation utilise truncatechars:120. De plus, il y a un léger décalage dans la condition :

  • truncatechars:120 inclut les ... dans le décompte (donc tronque à ~117 caractères + "...")
  • La condition vérifie media.review|length > 120
  • Si le texte original fait exactement 118-120 caractères, il sera tronqué mais le bouton "See more" ne s'affichera pas
🔎 Correction proposée
-{# Display the review truncated to 3 lines with a 'See more' button (HTMX) #}
+{# Display the review truncated to 120 characters with a 'See more' button (HTMX) #}
 {% load i18n %}
 {{ media.review | truncatechars:120 }}
-{% if media.review and media.review|length > 120 %}
+{% if media.review and media.review|length > 117 %}
   <button class="btn btn-xs btn-ghost mt-1"
           hx-get="{% url 'media_review_full_htmx' media.id %}"
           hx-target="#review-cell-{{ media.id }}"
           hx-swap="innerHTML">{% translate "See more" %}</button>
 {% endif %}

Note : La valeur 117 tient compte des 3 caractères de l'ellipse ajoutés par truncatechars.

Likely an incorrect or invalid review comment.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/templates/partials/media-review-full.html (1)

5-5: Préférer le tag Django {% url %} au lieu d'URL codée en dur.

L'URL /media/{{ media.id }}/review-clamped/ est codée en dur. Utilisez le tag {% url %} pour maintenir la cohérence avec les patterns d'URL Django.

🔎 Correction proposée
-        hx-get="/media/{{ media.id }}/review-clamped/"
+        hx-get="{% url 'media_review_clamped_htmx' media.id %}"
src/templates/partials/media-review-clamped.html (1)

6-6: Préférer le tag Django {% url %} au lieu d'URL codée en dur.

L'URL /media/{{ media.id }}/review-full/ est codée en dur. Utilisez le tag {% url %} pour maintenir la cohérence avec les patterns d'URL Django.

🔎 Correction proposée
-          hx-get="/media/{{ media.id }}/review-full/"
+          hx-get="{% url 'media_review_full_htmx' media.id %}"
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a17880b and d860a28.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • src/core/fixtures/sample_data.json
  • src/core/migrations/0007_alter_media_score.py
  • src/core/models.py
  • src/core/urls.py
  • src/core/views.py
  • src/static/js/base.js
  • src/templates/base.html
  • src/templates/media.html
  • src/templates/partials/media-items.html
  • src/templates/partials/media-list.html
  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-review-full.html
  • src/templates/partials/score-readonly.html
🧰 Additional context used
📓 Path-based instructions (4)
**/*.html

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.html: Prefer HTMX for dynamic interactions rather than vanilla JavaScript
Use Tailwind CSS classes for styling before adding custom CSS
Use HTMX instead of traditional JavaScript AJAX calls

Files:

  • src/templates/partials/media-list.html
  • src/templates/media.html
  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-items.html
  • src/templates/base.html
  • src/templates/partials/media-review-full.html
  • src/templates/partials/score-readonly.html
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: Use English docstrings in Python code
Follow PEP 8 style guidelines for Python code

Files:

  • src/core/migrations/0007_alter_media_score.py
  • src/core/urls.py
  • src/core/views.py
  • src/core/models.py
**/views.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function-based views (FBV) by default, only use class-based views (CBV) when more appropriate

Files:

  • src/core/views.py
**/models.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Models must have an explicit __str__ method

Files:

  • src/core/models.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: PascalRepond/datakult PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-26T16:12:32.381Z
Learning: Respond in French
📚 Learning: 2025-12-26T15:18:46.932Z
Learnt from: PascalRepond
Repo: PascalRepond/datakult PR: 21
File: src/templates/accounts/profile_edit.html:23-58
Timestamp: 2025-12-26T15:18:46.932Z
Learning: In Django projects, attributes added to a form field's widget via field.widget.attrs.update(...) in the form's __init__ are rendered when using {{ form.field }} in templates. No explicit attribute definitions are needed in the template. This applies to templates under src/templates in Django apps; ensure you update attrs in __init__ for consistent HTMX behavior.

Applied to files:

  • src/templates/partials/media-list.html
  • src/templates/media.html
  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-items.html
  • src/templates/base.html
  • src/templates/partials/media-review-full.html
  • src/templates/partials/score-readonly.html
🧬 Code graph analysis (6)
src/core/fixtures/sample_data.json (1)
src/core/migrations/0003_media_review_media_review_date_media_score_and_more.py (1)
  • Migration (9-41)
src/templates/partials/media-review-clamped.html (4)
src/core/migrations/0003_media_review_media_review_date_media_score_and_more.py (1)
  • Migration (9-41)
src/core/forms.py (1)
  • MediaForm (7-30)
src/core/migrations/0005_media_cover_alter_media_score.py (1)
  • Migration (6-23)
src/core/migrations/0001_initial.py (1)
  • Migration (7-34)
src/templates/partials/media-items.html (1)
src/core/migrations/0003_media_review_media_review_date_media_score_and_more.py (1)
  • Migration (9-41)
src/core/migrations/0007_alter_media_score.py (3)
src/core/migrations/0003_media_review_media_review_date_media_score_and_more.py (1)
  • Migration (9-41)
src/core/migrations/0005_media_cover_alter_media_score.py (1)
  • Migration (6-23)
src/core/forms.py (1)
  • MediaForm (7-30)
src/core/urls.py (1)
src/core/views.py (2)
  • media_review_full_htmx (214-217)
  • media_review_clamped_htmx (207-210)
src/core/views.py (2)
src/tests/conftest.py (1)
  • media (20-31)
src/core/models.py (1)
  • Media (23-111)
🪛 Ruff (0.14.10)
src/core/migrations/0007_alter_media_score.py

8-10: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


12-18: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

🔇 Additional comments (11)
src/core/fixtures/sample_data.json (1)

388-388: LGTM!

Le texte de revue étendu avec Lorem ipsum est approprié pour tester la fonctionnalité d'affichage des avis tronqués et complets.

src/static/js/base.js (1)

77-77: LGTM!

La mise à jour des classes de bouton pour utiliser les composants DaisyUI (btn btn-ghost btn-xs btn-circle) assure une cohérence avec les changements de template et améliore le style visuel.

src/templates/media.html (1)

75-75: LGTM!

La mise à jour cohérente des classes de boutons de suppression de badges avec les composants DaisyUI améliore le style visuel et s'aligne avec les modifications de src/static/js/base.js.

Also applies to: 83-83, 93-93, 103-103, 113-113

src/templates/base.html (1)

23-23: LGTM!

Le format JSON pour hx-headers avec le jeton CSRF est correct et supporte correctement les nouvelles vues HTMX pour les avis.

src/core/migrations/0007_alter_media_score.py (1)

1-18: LGTM!

La migration met à jour correctement les libellés de score en supprimant les préfixes emoji. Les avertissements de Ruff concernant ClassVar sont des faux positifs pour les fichiers de migration Django.

src/core/models.py (1)

86-96: LGTM!

Les labels simplifiés pour les choix de score améliorent la lisibilité. Les clés entières (1-10) sont préservées, assurant la compatibilité avec les données existantes. La migration correspondante gère correctement ce changement.

src/core/views.py (1)

206-217: LGTM!

Les deux nouvelles vues HTMX suivent les conventions établies du projet : décorateur @login_required, utilisation de get_object_or_404, docstrings en anglais, et approche FBV conforme aux guidelines. L'implémentation est cohérente avec les autres vues HTMX existantes comme agent_select_htmx.

src/templates/partials/media-list.html (2)

11-11: Vérifier la suppression de table-pin-rows.

La classe table-pin-rows a été retirée, ce qui signifie que l'en-tête du tableau ne restera plus fixe lors du défilement. Si c'est intentionnel (par exemple pour éviter des conflits avec les nouvelles colonnes), c'est acceptable. Sinon, envisagez de la restaurer pour améliorer l'UX sur les longues listes.


21-22: LGTM!

Les nouvelles colonnes "Review" et "Reviewed on" sont correctement ajoutées avec la traduction i18n, conformément aux objectifs du PR.

src/core/urls.py (1)

15-16: LGTM!

Les nouvelles routes HTMX suivent la structure URL existante et sont cohérentes avec les patterns établis du projet. Les noms de vues correspondent aux fonctions dans views.py.

src/templates/partials/media-items.html (1)

6-41: LGTM!

La refonte de la vue grille est bien structurée avec une mise en page responsive (lg:card-side). L'utilisation de Tailwind CSS et des attributs HTMX pour les liens de contributeurs suit les conventions du projet. L'intégration des partials score-readonly et media-review-clamped est correcte.

Comment thread src/templates/partials/media-items.html Outdated
Comment thread src/templates/partials/score-readonly.html
@PascalRepond PascalRepond force-pushed the rep-layout branch 2 times, most recently from c65f03b to 41f3df0 Compare December 27, 2025 18:00
- Updated the media list table to include "Review" and "Reviewed on" columns for better visibility of user feedback.
- Adjusted grid layout to optimize display across different screen sizes.
- Updated dependencies.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/templates/partials/media-items.html (1)

6-41: Bonne refonte du layout grid avec HTMX.

La structure responsive card lg:card-side est bien implémentée. Les liens contributeurs avec attributs HTMX (hx-get, hx-target, hx-include, hx-push-url) suivent les bonnes pratiques.

Suggestion mineure : Pour l'accessibilité, considérez ajouter aria-label sur les liens contributeurs pour clarifier l'action de filtrage.

🔎 Amélioration optionnelle d'accessibilité
           <a href="#"
              class="link link-secondary contributor-link"
              data-contributor-id="{{ contributor.id }}"
              data-contributor-name="{{ contributor.name }}"
              hx-get="{% url 'home' %}?contributor={{ contributor.id }}"
              hx-target="#media-list"
              hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to"
-              hx-push-url="true">{{ contributor.name }}</a>
+              hx-push-url="true"
+              aria-label="{% translate 'Filter by contributor' %}: {{ contributor.name }}">{{ contributor.name }}</a>
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d860a28 and 41f3df0.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • src/core/fixtures/sample_data.json
  • src/core/migrations/0007_alter_media_score.py
  • src/core/models.py
  • src/core/urls.py
  • src/core/views.py
  • src/static/js/base.js
  • src/templates/base.html
  • src/templates/media.html
  • src/templates/partials/media-items.html
  • src/templates/partials/media-list.html
  • src/templates/partials/media-review-clamped.html
  • src/templates/partials/media-review-full.html
  • src/templates/partials/score-readonly.html
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/templates/partials/media-review-clamped.html
  • src/templates/media.html
  • src/core/urls.py
  • src/templates/partials/score-readonly.html
  • src/core/fixtures/sample_data.json
  • src/core/models.py
  • src/templates/base.html
  • src/static/js/base.js
  • src/templates/partials/media-review-full.html
  • src/templates/partials/media-list.html
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: Use English docstrings in Python code
Follow PEP 8 style guidelines for Python code

Files:

  • src/core/views.py
  • src/core/migrations/0007_alter_media_score.py
**/views.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function-based views (FBV) by default, only use class-based views (CBV) when more appropriate

Files:

  • src/core/views.py
**/*.html

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.html: Prefer HTMX for dynamic interactions rather than vanilla JavaScript
Use Tailwind CSS classes for styling before adding custom CSS
Use HTMX instead of traditional JavaScript AJAX calls

Files:

  • src/templates/partials/media-items.html
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: PascalRepond/datakult PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-26T16:12:32.381Z
Learning: Respond in French
📚 Learning: 2025-12-26T15:18:46.932Z
Learnt from: PascalRepond
Repo: PascalRepond/datakult PR: 21
File: src/templates/accounts/profile_edit.html:23-58
Timestamp: 2025-12-26T15:18:46.932Z
Learning: In Django projects, attributes added to a form field's widget via field.widget.attrs.update(...) in the form's __init__ are rendered when using {{ form.field }} in templates. No explicit attribute definitions are needed in the template. This applies to templates under src/templates in Django apps; ensure you update attrs in __init__ for consistent HTMX behavior.

Applied to files:

  • src/templates/partials/media-items.html
🧬 Code graph analysis (1)
src/core/views.py (2)
src/tests/conftest.py (1)
  • media (20-31)
src/core/models.py (1)
  • Media (23-111)
🪛 Ruff (0.14.10)
src/core/migrations/0007_alter_media_score.py

8-10: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


12-18: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

🔇 Additional comments (3)
src/core/views.py (1)

206-217: Bonnes implémentations HTMX.

Les deux nouvelles vues suivent correctement les patterns établis dans le fichier :

  • Utilisation de @login_required pour la sécurité
  • get_object_or_404 pour une gestion propre des erreurs 404
  • Docstrings en anglais conformément aux guidelines
  • Vues basées sur des fonctions (FBV) comme recommandé

L'approche HTMX pour l'expansion/réduction des reviews est élégante et conforme aux guidelines du projet.

src/templates/partials/media-items.html (1)

79-83: Design combiné score + review confirmé.

La combinaison du score et de la review dans une seule cellule (max-w-md) semble être un choix de design intentionnel selon le summary ("removal of the Score column in favor of the inline score-readonly and review UI"). Cette approche offre une vue compacte cohérente entre les modes grid et table.

src/core/migrations/0007_alter_media_score.py (1)

1-18: Migration correctly structured.

The migration properly reflects the Media.score field changes with the new choice labels. Static analysis warnings about ClassVar are false positives for auto-generated Django migration files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant