Skip to content
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

Allow no posts pagination #47

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Conversation

ClmntBcqt
Copy link
Contributor

PR for issue #46

@ClmntBcqt ClmntBcqt requested a review from lebouquetin July 25, 2024 09:33
jssg/models.py Outdated
self.nb_pages = ceil(len(list(filter(lambda p: p.metadata["category"] == self.category, Post.load_glob(all=True)))) / self.posts_by_page) # number of posts of the category / number of posts by page
nb_posts = len(list(filter(lambda p: p.metadata["category"] == self.category, Post.load_glob(all=True))))

if hasattr(settings, "JFME_NUMBER_OF_POSTS_BY_PAGE") :
Copy link
Member

Choose a reason for hiding this comment

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

It's not a common way to disable a feature to remove the parameter ; the right way is to have a default value.

I suggest here to replace

if hasattr(settings, "JFME_NUMBER_OF_POSTS_BY_PAGE") :

With

if settings.JFME_NUMBER_OF_POSTS_BY_PAGE <= 0:

This way the parameter is always available; this is a common pattern to set to 0 or -1 an attribute in order to tell "this is unlimited"

@ClmntBcqt ClmntBcqt requested a review from lebouquetin July 26, 2024 14:08
@ClmntBcqt ClmntBcqt merged commit ff758f2 into main Jul 29, 2024
2 checks passed
@ClmntBcqt ClmntBcqt deleted the feat__46_allow_no_posts_pagination branch July 29, 2024 14:44
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