-
Notifications
You must be signed in to change notification settings - Fork 161
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
Le forum évite de remonter les sujets dont le dernier message est masqué #6056
Open
Rowin
wants to merge
34
commits into
zestedesavoir:dev
Choose a base branch
from
Rowin:feature-lastposthidden
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8ea40c1
Fix #5980
Rowin 3a8256e
Ajout des tests
Rowin 55d9662
Ajout d'un filtre par tag sur les flux RSS/Atom des contenus
entwanne 39cdb47
fixup! Ajout d'un filtre par tag sur les flux RSS/Atom des contenus
entwanne 2f2b880
fixup! Ajout d'un filtre par tag sur les flux RSS/Atom des contenus
entwanne ea8302e
Strip des valeurs des filtres category/subcategory sur les flux RSS/Atom
entwanne 469ad1a
Relaie les paramTres GET de la page courante aux flux RSS
entwanne bc02384
Correction de l'affichage des membres sur les pages des casquettes
Situphen 7e7a914
Survoler le sous-titre d'une cartouche de sujet du forum ne souligne …
Situphen 1fd1fd5
Rend moins visible un paragraphe
Situphen 3cebb75
On cache le bouton Modifier dans les MPs si quelqu'un a répondu après
Situphen 41e56d0
Un membre ne peut pas modifier son message s'il est masqué
Situphen 8cb1a6a
Cache les boutons Spam potentiel et Réponse utile pour les messages m…
Situphen fde6149
Fix hauteur body et z-index header
viki53 83c99c5
Change l'URL de la page de profil en /@pseudo (#6057)
Rowin 03e2227
Passage à zmarkdown 9.1.4 pour corriger un bug
Situphen 4ed1610
Création d'une méthode last_visible_post
Rowin 434e34f
Créé un filtre pour trier les topics par date
Rowin bde3301
Ajout d'un test de l'anti-spam
Rowin 59001b6
Ajout d'un test du filtre de tri des topics
Rowin b20aa9a
Merge branch 'dev' into feature-lastposthidden
Rowin 65ded0c
Merge branch 'dev' into feature-lastposthidden
Rowin 82d583c
Changement dans les tests
Rowin 8457537
Merge branch 'dev' into feature-lastposthidden
Situphen 1b45c77
Changement de update pour last_update
Rowin 2dda367
Merge branch 'feature-lastposthidden' of github.com:Rowin/zds-site in…
Rowin 794f1db
Merge branch 'dev' into feature-lastposthidden
Rowin f7d681f
Linting
Rowin ff3aea2
Merge branch 'dev' into feature-lastposthidden
Rowin 267ec15
Merge branch 'dev' into feature-lastposthidden
AmauryCarrade 9a9d5b1
Corrige un problème d'ordre des derniers sujets lorsque les sujets so…
Rowin eaa0b01
Corrige un problème d'ordre des sujets lorsqu'un message a été modifié
Rowin 814ac8d
Merge branch 'dev' into feature-lastposthidden
Rowin 046f4bf
Merge branch 'dev' into feature-lastposthidden
Rowin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,10 +127,15 @@ def get_post_count(self): | |
|
||
def get_last_message(self): | ||
""" | ||
:return: the last message on the forum, if there are any. | ||
:return: the last visible message on the forum, if there are any. | ||
""" | ||
try: | ||
last_post = Post.objects.select_related("topic").filter(topic__forum=self).order_by("-pubdate").all()[0] | ||
last_post = ( | ||
Post.objects.select_related("topic") | ||
.filter(topic__forum=self, is_visible=True) | ||
.order_by("-pubdate") | ||
.all()[0] | ||
) | ||
last_post.topic.forum = self | ||
return last_post | ||
except IndexError: | ||
|
@@ -232,6 +237,11 @@ def meta_description(self): | |
return first_post.text | ||
return Topic.__remove_greetings(first_post)[: settings.ZDS_APP["forum"]["description_size"]] | ||
|
||
@property | ||
def last_update(self): | ||
last_visible_post = self.get_last_visible_post() | ||
return last_visible_post.pubdate | ||
Comment on lines
+242
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
@staticmethod | ||
def __remove_greetings(post): | ||
greetings = settings.ZDS_APP["forum"]["greetings"] | ||
|
@@ -257,6 +267,15 @@ def get_post_count(self): | |
""" | ||
return Post.objects.filter(topic__pk=self.pk).count() | ||
|
||
def get_last_visible_post(self): | ||
""" | ||
:return: the last visible post in the thread. | ||
""" | ||
try: | ||
return self.post_set.filter(is_visible=True).latest("pubdate") | ||
except Post.DoesNotExist: | ||
return None | ||
|
||
def get_last_post(self): | ||
""" | ||
:return: the last post in the thread. | ||
|
@@ -270,7 +289,7 @@ def get_last_answer(self): | |
return `None`. | ||
:return: the last answer in the thread, if any. | ||
""" | ||
last_post = self.get_last_post() | ||
last_post = self.get_last_visible_post() | ||
|
||
if last_post == self.first_post(): | ||
return None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django import template | ||
from django.core.cache import cache | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter("topics_sort") | ||
def topics_sort(topics): | ||
""" | ||
:return: the topics sorted by last update (last updated first) | ||
""" | ||
return sorted(topics, key=lambda topic: topic.last_update, reverse=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puisque le tri est fait dans
get_all_topics_of_a_forum()
, on n'a plus besoin de trier ici, non ?