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
4dd6f01e
Commit
4dd6f01e
authored
Jan 21, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ariadne's thread
parent
ea524622
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
8 deletions
+32
-8
forum/models.py
forum/models.py
+5
-2
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+7
-1
forum/templates/forum/main.jinja
forum/templates/forum/main.jinja
+3
-0
forum/templates/forum/topic.jinja
forum/templates/forum/topic.jinja
+11
-1
forum/views.py
forum/views.py
+6
-4
No files found.
forum/models.py
View file @
4dd6f01e
...
...
@@ -56,7 +56,10 @@ class ForumTopic(models.Model):
description
=
models
.
CharField
(
_
(
'description'
),
max_length
=
256
,
default
=
""
)
class
Meta
:
ordering
=
[
'-id'
]
ordering
=
[
'-id'
]
# TODO: add date message ordering
def
__str__
(
self
):
return
"%s"
%
(
self
.
title
)
def
get_absolute_url
(
self
):
return
reverse
(
'forum:view_topic'
,
kwargs
=
{
'topic_id'
:
self
.
id
})
...
...
@@ -72,7 +75,7 @@ class ForumMessage(models.Model):
date
=
models
.
DateTimeField
(
_
(
'date'
),
default
=
timezone
.
now
)
class
Meta
:
ordering
=
[
'
-
id'
]
ordering
=
[
'id'
]
def
get_absolute_url
(
self
):
return
self
.
topic
.
get_absolute_url
()
...
...
forum/templates/forum/forum.jinja
View file @
4dd6f01e
...
...
@@ -21,7 +21,13 @@
{%
endblock
%}
{%
block
content
%}
<p>
{{
forum.get_parent_list
()
}}
</p>
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
{%
for
f
in
forum.get_parent_list
()
%}
>
<a
href=
"
{{
f.get_absolute_url
()
}}
"
>
{{
f
}}
</a>
{%
endfor
%}
>
<a
href=
"
{{
forum.get_absolute_url
()
}}
"
>
{{
forum
}}
</a>
</p>
<h3>
{{
forum.name
}}
</h3>
<a
href=
"
{{
url
(
'forum:new_forum'
)
}}
?parent=
{{
forum.id
}}
"
>
New forum
</a>
{%
for
f
in
forum.children.all
()
%}
...
...
forum/templates/forum/main.jinja
View file @
4dd6f01e
...
...
@@ -17,6 +17,9 @@
{%
endblock
%}
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
>
</p>
<h3>
{%
trans
%}
Forum
{%
endtrans
%}
</h3>
<a
href=
"
{{
url
(
'forum:new_forum'
)
}}
"
>
New forum
</a>
{%
for
f
in
forum_list
%}
...
...
forum/templates/forum/topic.jinja
View file @
4dd6f01e
{%
extends
"core/base.jinja"
%}
{%
from
'core/macros.jinja'
import
user_profile_link
%}
{%
block
head
%}
{{
super
()
}}
...
...
@@ -20,13 +21,22 @@
{%
endblock
%}
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
Forum
</a>
{%
for
f
in
topic.forum.get_parent_list
()
%}
>
<a
href=
"
{{
f.get_absolute_url
()
}}
"
>
{{
f
}}
</a>
{%
endfor
%}
>
<a
href=
"
{{
topic.forum.get_absolute_url
()
}}
"
>
{{
topic.forum
}}
</a>
>
<a
href=
"
{{
topic.get_absolute_url
()
}}
"
>
{{
topic
}}
</a>
</p>
<h3>
{{
topic.title
}}
</h3>
<p>
{{
topic.description
}}
</p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
Reply
</a></p>
{%
for
m
in
topic.messages.all
()
%}
<hr>
<div>
<h5>
{{
m.title
}}
</h5>
<p><strong>
{{
m.author.get_display_name
(
)
}}
</strong>
-
{{
m.date
|
date
(
DATETIME_FORMAT
)
}}
<p><strong>
{{
user_profile_link
(
m.author
)
}}
</strong>
-
{{
m.date
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
time
(
DATETIME_FORMAT
)
}}
-
<a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
?quote_id=
{{
m.id
}}
"
>
Reply as quote
</a></p>
<p>
{{
m.message
|
markdown
}}
</p>
...
...
forum/views.py
View file @
4dd6f01e
...
...
@@ -38,8 +38,8 @@ class ForumDetailView(DetailView):
pk_url_kwarg
=
"forum_id"
class
ForumTopicCreateView
(
CreateView
):
model
=
Forum
Topic
fields
=
[
'title'
]
model
=
Forum
Message
fields
=
[
'title'
,
'message'
]
template_name
=
"core/create.jinja"
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -49,13 +49,15 @@ class ForumTopicCreateView(CreateView):
return
super
(
ForumTopicCreateView
,
self
).
dispatch
(
request
,
*
args
,
**
kwargs
)
def
form_valid
(
self
,
form
):
form
.
instance
.
forum
=
self
.
forum
topic
=
ForumTopic
(
title
=
form
.
instance
.
title
,
author
=
self
.
request
.
user
,
forum
=
self
.
forum
)
topic
.
save
()
form
.
instance
.
topic
=
topic
form
.
instance
.
author
=
self
.
request
.
user
return
super
(
ForumTopicCreateView
,
self
).
form_valid
(
form
)
class
ForumTopicEditView
(
UpdateView
):
model
=
ForumTopic
fields
=
[
'title'
]
fields
=
[
'title'
,
'forum'
]
pk_url_kwarg
=
"topic_id"
template_name
=
"core/edit.jinja"
...
...
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