Skip to content

Updated new pagination feature. #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025

Conversation

Antoliny0919
Copy link
Contributor

I added a new pagination system. The previous one only provided "Previous" and "Next" buttons, but now users can navigate more freely using numbered page buttons.

Screenshot 2025-06-02 at 5 28 25 PM

Comment on lines 42 to 46
<li><a hx-get="{% url 'cab_top_authors' %}" hx-target="#base-container" hx-swap="innerHTML" hx-trigger="click">By author</a></li>
<li><a hx-get="{% url 'cab_language_list' %}" hx-target="#base-container" hx-swap="innerHTML" hx-trigger="click" >By language</a></li>
<li><a hx-get="{% url 'cab_top_tags' %}" hx-target="#base-container" hx-swap="innerHTML" hx-trigger="click">By tag</a></li>
<li><a hx-get="{% url 'cab_top_rated' %}" hx-target="#base-container" hx-swap="innerHTML" hx-trigger="click">Highest rated</a></li>
<li><a hx-get="{% url 'cab_top_bookmarked' %}" hx-target="#base-container" hx-swap="innerHTML" hx-trigger="click">Most bookmarked</a></li>
<li><a href="{% url 'cab_top_authors' %}">By author</a></li>
<li><a href="{% url 'cab_language_list' %}">By language</a></li>
<li><a href="{% url 'cab_top_tags' %}">By tag</a></li>
<li><a href="{% url 'cab_top_rated' %}">Highest rated</a></li>
<li><a href="{% url 'cab_top_bookmarked' %}">Most bookmarked</a></li>
Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Jun 2, 2025

Choose a reason for hiding this comment

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

I removed the use of htmx from the homepage.
I'm wondering if there was a specific reason for using htmx in this part.
Personally, I felt that this section didn’t need to be served via htmx or a partial template. 🧐

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I recall it was going for avoiding a full page refresh when clicking on a header

Comment on lines 9 to 10
class Pagination:
def __init__(
Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Jun 2, 2025

Choose a reason for hiding this comment

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

I added pagination related features to the cab app.
That said, I believe introducing a base app for shared components like pagination would be a cleaner approach.
Please let me know if you're open to this direction — I’d be happy to move the related code (e.g. templatetags, templates ...) into the base app.

Copy link
Contributor Author

@Antoliny0919 Antoliny0919 left a comment

Choose a reason for hiding this comment

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

Although I haven’t added test code yet and the work is not fully complete, I believe it’s sufficient to demonstrate the new pagination approach I have in mind, so I went ahead and opened this PR.
I’d appreciate any feedback you may have 🥰

Comment on lines 37 to 47
def get_query_string(self, new_params=None):
if new_params is None:
new_params = {}
params = self.params.copy()
for param, value in new_params.items():
if value is None:
if param in params:
del params[param]
else:
params[param] = value
return "?%s" % urlencode(sorted(params.items()), doseq=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is almost identical to the get_query_string method of Django’s ChangeList class.
I think it would be better to replace this with the querystring template tag that will be added in Django 6.0, especially considering that the table page is likely to use many query parameters in the future.
The current Django version is 3.2 — would it be acceptable to copy and use the querystring template tag from 6.0 as is for now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Go for it

@Antoliny0919
Copy link
Contributor Author

I have a question that’s not directly related to this PR.
Do you know where the templates under cab/templates/cab are used?
I’ve been looking for where these templates are used, but honestly, I just can’t find them 😥. Could you please let me know?

@Antoliny0919 Antoliny0919 force-pushed the new_pagination_feature branch 2 times, most recently from a69d916 to 347a55f Compare June 3, 2025 14:05
@chriswedgwood
Copy link
Collaborator

I have a question that’s not directly related to this PR. Do you know where the templates under cab/templates/cab are used? I’ve been looking for where these templates are used, but honestly, I just can’t find them 😥. Could you please let me know?

Yes it is confusing and I also wondered what the cab directory was for. I think it had something to do with testing but a really old approach. If memory serves I removed code that running it , so we can definitely look to remove it

Also cab is one of Django Reinharts songs :)

https://open.spotify.com/track/5OrylisFUck3PdkLnOg5Xf

@chriswedgwood
Copy link
Collaborator

The build is failing due to us using an older python version. Give me a day or so to get the CI/CD working well. Hasnt been loved for a while

@Antoliny0919
Copy link
Contributor Author

Antoliny0919 commented Jun 4, 2025

Yes it is confusing and I also wondered what the cab directory was for. I think it had something to do with testing but a really old approach. If memory serves I removed code that running it , so we can definitely look to remove it

Also cab is one of Django Reinharts songs :)

https://open.spotify.com/track/5OrylisFUck3PdkLnOg5Xf

Oh, I knew where the name Django came from, but I had no idea about this part.
I’ll have to listen to it on my way home today. 😎
I think it would be better to remove the templates under the cab directory.(I will create a separate PR for this part.)
I imagine many others might feel the same confusion I did.

@Antoliny0919
Copy link
Contributor Author

The build is failing due to us using an older python version. Give me a day or so to get the CI/CD working well. Hasnt been loved for a while

Thank you @chriswedgwood .
I'll do my best to wrap up my work for now as well!

@Antoliny0919 Antoliny0919 force-pushed the new_pagination_feature branch 3 times, most recently from 17f37ab to 0c79cc4 Compare June 4, 2025 08:54
@Antoliny0919
Copy link
Contributor Author

With the changes made in commit 0c79cc4, the search functionality is now working again. However, all tests passed previously, which suggests that there are no tests related to the search feature 😢

@Antoliny0919 Antoliny0919 force-pushed the new_pagination_feature branch from 0c79cc4 to b0e868a Compare June 4, 2025 10:24
Comment on lines +31 to -34
"base.tests",
"comments_spamfighter",
"cab",
"ratings",
"taggit",
"ratings.tests",
Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Jun 4, 2025

Choose a reason for hiding this comment

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

Since multiple tests apps cannot coexist, I made base.tests the main test app and moved the test models to base.tests.models (along with the fixture).

@Antoliny0919 Antoliny0919 force-pushed the new_pagination_feature branch 2 times, most recently from cdfecd0 to 9a2007c Compare June 5, 2025 00:56
@chriswedgwood chriswedgwood reopened this Jun 6, 2025
@Antoliny0919 Antoliny0919 force-pushed the new_pagination_feature branch from 9a2007c to 4e1a63e Compare June 6, 2025 20:46
@chriswedgwood chriswedgwood merged commit 2375bec into django:main Jun 6, 2025
1 check passed
@Antoliny0919
Copy link
Contributor Author

@chriswedgwood It seems like the SCSS changes are not being reflected on the actual site. What could be the reason? 🧐

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