Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
24c02f46
Commit
24c02f46
authored
Apr 10, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix last message when the real last is deleted
parent
9e61b118
Pipeline
#884
failed with stage
in 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
forum/models.py
forum/models.py
+7
-3
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+3
-1
No files found.
forum/models.py
View file @
24c02f46
...
...
@@ -116,10 +116,8 @@ class Forum(models.Model):
last_msg
=
None
for
m
in
ForumMessage
.
objects
.
select_related
(
'topic__forum'
,
'author'
).
order_by
(
'-id'
):
forum
=
m
.
topic
.
forum
if
self
in
(
forum
.
parent_list
+
[
forum
]):
if
self
in
(
forum
.
parent_list
+
[
forum
])
and
not
m
.
deleted
:
return
m
last_msg
=
m
return
last_msg
class
ForumTopic
(
models
.
Model
):
forum
=
models
.
ForeignKey
(
Forum
,
related_name
=
'topics'
)
...
...
@@ -151,6 +149,12 @@ class ForumTopic(models.Model):
except
:
return
None
@
cached_property
def
last_message
(
self
):
for
msg
in
self
.
messages
.
order_by
(
'id'
).
select_related
(
'author'
).
order_by
(
'-id'
).
all
():
if
not
msg
.
deleted
:
return
msg
@
property
def
title
(
self
):
return
self
.
messages
.
order_by
(
'date'
).
first
().
title
...
...
forum/templates/forum/macros.jinja
View file @
24c02f46
...
...
@@ -67,11 +67,13 @@
</div>
</div>
<div
class=
"ib w_medium"
style=
"text-align: center;"
>
{%
set
last_msg
=
topic.messages.order_by
(
'id'
)
.
select_related
(
'author'
)
.
last
()
%}
{%
set
last_msg
=
topic.last_message
%}
{%
if
last_msg
%}
{{
user_profile_link
(
last_msg.author
)
}}
<br/>
<a
href=
"
{{
last_msg.get_absolute_url
()
}}
"
>
{{
last_msg.date
|
date
(
DATETIME_FORMAT
)
}}
{{
last_msg.date
|
time
(
DATETIME_FORMAT
)
}}
</a>
{%
endif
%}
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment