Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit 1cf5219

Browse files
fix #4 : last commented view now display only clients comments using the super duper mega request of the death
1 parent 6a7e484 commit 1cf5219

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

bugboard/templates/bugboard/task_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ <h6 class="card-subtitle mb-2 text-muted">
132132

133133
</div>
134134
</div>
135-
{% endblock %}
135+
{% endblock %}

bugboard/views.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Third party
2-
from bugboard.models import Project, Task
3-
from django.db.models import Max
2+
from bugboard.models import Project, Task, Comment
3+
from django.db.models import Max, Subquery, OuterRef
44
from django.views import generic
55

66

@@ -46,10 +46,16 @@ class CommentedView(generic.ListView):
4646
template_name = "bugboard/task_list.html"
4747
paginate_by = 100
4848

49+
# Thanks https://docs.djangoproject.com/fr/2.2/ref/models/expressions/#subquery-expressions
50+
newest = Comment.objects.filter(task=OuterRef('pk')).order_by('-created_at')
51+
4952
queryset = (
50-
Task.objects.exclude(comment=None)
51-
.annotate(last_com=Max("comment__created_at"))
52-
.order_by("-last_com")
53+
Task.objects
54+
.exclude(comment=None) # exclude tasks with no comments
55+
.annotate(last_com=Max("comment__created_at")) # add last com in queryset
56+
.annotate(last_comment_member=Subquery(newest.values('member__member')[:1])) # add last com mail
57+
.exclude(last_comment_member=True) # exclude when last com contain out url in email (member)
58+
.order_by("-last_com") # order by last com
5359
)
5460

5561
def get_context_data(self, **kwargs):

randomdjangoprojectname/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
# Application definition
3434

3535
INSTALLED_APPS = [
36-
"sslserver",
37-
"django_extensions",
3836
"django.contrib.auth",
3937
"django.contrib.admin",
4038
"django.contrib.sessions",

0 commit comments

Comments
 (0)