Skip to content

Conversation

@Inkwhs
Copy link

@Inkwhs Inkwhs commented May 17, 2025

登陆后可收藏,收藏后会显示在‘我的收藏’里,点击可跳转

liangliangyy and others added 3 commits May 12, 2025 22:57
增加k8s部署配置 && 升级依赖
登陆后可收藏,收藏后会显示在‘我的收藏’里,点击可跳转
@liangliangyy
Copy link
Owner

你好,感谢提交,脚本可否统一放在 blog.js中?或者直接使用form提交。

@liangliangyy
Copy link
Owner

另外麻烦修改下到dev分支哈。

@liangliangyy liangliangyy requested a review from Copilot May 20, 2025 10:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a favorite system allowing logged-in users to bookmark articles, view them in “我的收藏”, and toggle favorite status directly from article details.

  • Added a "我的收藏" menu item in the navigation.
  • Introduced a new favorite list view and template to display user favorites.
  • Implemented new endpoints, models, and migrations for handling favorite actions.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/share_layout/nav.html Added a new menu item linking to the favorite list page.
templates/blog/favorite_list.html Created a new template for displaying the user’s favorites.
templates/blog/article_detail.html Added favorite toggle functionality in the article detail view.
blog/views.py Introduced new endpoints for adding, removing, checking, and listing favorites.
blog/urls.py Added URL routes for the favorite related endpoints.
blog/models.py Added the Favorite model with a unique-together constraint.
blog/migrations/0007_favorite.py Added migration for the Favorite model.

@Inkwhs Inkwhs changed the base branch from master to dev May 21, 2025 01:24
@Inkwhs
Copy link
Author

Inkwhs commented May 21, 2025

好的,已经改了

@liangliangyy liangliangyy requested a review from Copilot May 21, 2025 02:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a collection system that allows authenticated users to favorite articles, view them in their favorites list, and remove them when desired. Key changes include adding navigation links and pages for favorites, creating new view functions and URL routes for favorite-related actions, and implementing client‐side JavaScript to handle favorite toggling.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/share_layout/nav.html Added a navigation menu entry linking to the favorites list.
templates/blog/favorite_list.html Created a new page to display the user's favorited articles.
templates/blog/article_detail.html Inserted a favorite button on article detail pages for logged-in users.
deploy/k8s/configmap.yaml Updated database credentials for improved security.
blog/views.py Added view functions to manage favorite actions.
blog/urls.py Introduced new URL routes for favorite functionalities.
blog/static/blog/js/blog.js Added JavaScript to handle favorite checking, adding, and removal.
blog/models.py Created a new model to represent a favorited article.
blog/migrations/0007_favorite.py Added the migration for the new Favorite model.


<li class="menu-item">
<a href="{% url 'blog:favorite_list' %}">
<i class="fa fa-star"></i> 我的收藏
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider wrapping the text '我的收藏' with a translation tag (e.g. {% trans '我的收藏' %}) for consistency with other localized strings.

Suggested change
<i class="fa fa-star"></i> 我的收藏
<i class="fa fa-star"></i> {% trans '我的收藏' %}

Copilot uses AI. Check for mistakes.
<div class="favorite-container" style="margin: 20px 0;">
<button id="favoriteBtn" class="btn btn-primary" data-article-id="{{ article.id }}">
<i class="fa fa-star"></i>
<span id="favoriteText">收藏文章</span>
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider wrapping '收藏文章' in a translation function to ensure consistent internationalization support as seen elsewhere in the application.

Suggested change
<span id="favoriteText">收藏文章</span>
<span id="favoriteText">{% trans "收藏文章" %}</span>

Copilot uses AI. Check for mistakes.
const isFavorite = favoriteBtn.classList.contains('btn-danger');
const url = isFavorite ? `/favorite/remove/${articleId}/` : `/favorite/add/${articleId}/`;

fetch(url, {
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

Adding error handling (e.g. catch blocks) for fetch requests will make the client-side interactions more robust in case of network failures.

Copilot uses AI. Check for mistakes.
@liangliangyy liangliangyy merged commit 99a37f9 into liangliangyy:dev May 27, 2025
14 of 17 checks passed
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.

2 participants