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
fe07ee09
Commit
fe07ee09
authored
Feb 24, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Still lot of forum improvements, both rights and cosmetic
parent
10d96de3
Pipeline
#770
passed with stage
in 3 minutes and 34 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
23 deletions
+86
-23
core/static/core/style.css
core/static/core/style.css
+25
-5
forum/models.py
forum/models.py
+3
-3
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+33
-0
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+1
-1
forum/templates/forum/topic.jinja
forum/templates/forum/topic.jinja
+15
-13
forum/views.py
forum/views.py
+9
-1
No files found.
core/static/core/style.css
View file @
fe07ee09
...
...
@@ -414,23 +414,43 @@ textarea {
.message
{
padding
:
2px
;
margin
:
2px
;
background
:
skyblue
;
}
.unread
{
background
:
#e6ddad
;
background
:
#eff7ff
;
}
.message
h5
{
font-size
:
100%
;
}
.unread
{
background
:
#d8e7f3
;
}
.msg_author.deleted
{
background
:
#ffcfcf
;
}
.msg_content.deleted
{
background
:
#ffefef
;
}
.msg_content
{
display
:
inline-block
;
width
:
80%
;
vertical-align
:
top
;
}
.msg_author
{
display
:
inline-block
;
width
:
19%
;
text-align
:
center
;
background
:
#d8e7f3
;
}
.msg_author
img
{
max-width
:
8
0%
;
max-width
:
7
0%
;
margin
:
0px
auto
;
}
.msg_meta
{
font-size
:
small
;
list-style-type
:
none
;
}
.msg_meta
li
{
padding
:
2px
;
margin
:
2px
;
}
/*------------------------------SAS------------------------------------*/
.album
{
display
:
inline-block
;
...
...
forum/models.py
View file @
fe07ee09
...
...
@@ -126,7 +126,7 @@ class ForumTopic(models.Model):
ordering
=
[
'-id'
]
# TODO: add date message ordering
def
is_owned_by
(
self
,
user
):
return
self
.
forum
.
is_owned_by
(
user
)
or
user
.
id
==
self
.
author
.
id
return
self
.
forum
.
is_owned_by
(
user
)
def
can_be_edited_by
(
self
,
user
):
return
user
.
can_edit
(
self
.
forum
)
...
...
@@ -169,10 +169,10 @@ class ForumMessage(models.Model):
return
user
.
can_edit
(
self
.
topic
.
forum
)
def
can_be_viewed_by
(
self
,
user
):
return
user
.
can_view
(
self
.
topic
)
return
(
not
self
.
deleted
and
user
.
can_view
(
self
.
topic
)
)
def
can_be_moderated_by
(
self
,
user
):
return
self
.
topic
.
forum
.
is_owned_by
(
user
)
return
self
.
topic
.
forum
.
is_owned_by
(
user
)
or
user
.
id
==
self
.
author
.
id
def
get_absolute_url
(
self
):
return
self
.
topic
.
get_absolute_url
()
+
"#msg_"
+
str
(
self
.
id
)
...
...
forum/templates/forum/forum.jinja
View file @
fe07ee09
...
...
@@ -20,12 +20,45 @@
{%
endif
%}
<a
href=
"
{{
url
(
'forum:new_topic'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
New topic
{%
endtrans
%}
</a>
</p>
{%
if
forum.children.exists
()
%}
<div>
<div
class=
"ib w_big"
>
Title
</div>
<div
class=
"ib w_small"
>
<div
class=
"ib w_medium"
>
Topics
</div>
<div
class=
"ib w_small"
>
Last message
</div>
</div>
</div>
{%
for
f
in
forum.children.all
()
%}
{{
display_forum
(
f
,
user
)
}}
{%
endfor
%}
{%
endif
%}
{%
if
topics
%}
<div>
<div
class=
"ib w_medium"
>
Title
</div>
<div
class=
"ib w_medium"
>
<div
class=
"ib w_small"
>
Author
</div>
<div
class=
"ib w_medium"
>
Messages
</div>
<div
class=
"ib w_small"
>
Last message
</div>
</div>
</div>
{%
for
t
in
topics
%}
{{
display_topic
(
t
,
user
)
}}
{%
endfor
%}
{%
endif
%}
{%
endblock
%}
...
...
forum/templates/forum/macros.jinja
View file @
fe07ee09
...
...
@@ -47,7 +47,7 @@
<h5>
{{
topic.title
}}
</h5>
<p>
{{
topic.description
}}
</p>
</a>
{%
if
user.
is_owner
(
topic
)
%}
{%
if
user.
can_edit
(
topic
)
%}
<div
class=
"ib"
style=
"text-align: center;"
>
<a
href=
"
{{
url
(
'forum:edit_topic'
,
topic_id
=
topic.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a>
</div>
...
...
forum/templates/forum/topic.jinja
View file @
fe07ee09
...
...
@@ -37,23 +37,23 @@
<p>
{{
topic.description
}}
</p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
Reply
</a></p>
{%
for
m
in
topic.messages.select_related
(
'author__profile_pict'
)
.
all
()
%}
{%
for
m
in
topic.messages.select_related
(
'author__avatar_pict'
)
.
all
()
%}
{%
if
user.can_view
(
m
)
%}
{%
if
m.id
>=
first_unread_message_id
%}
<div
id=
"msg_
{{
m.id
}}
"
class=
"message unread"
>
{%
else
%}
<div
id=
"msg_
{{
m.id
}}
"
class=
"message"
>
{%
endif
%}
<div
class=
"msg_author"
>
{%
if
m.author.
profile
_pict
%}
<img
src=
"
{{
m.author.
profile
_pict.get_download_url
()
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
<div
class=
"msg_author
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
>
{%
if
m.author.
avatar
_pict
%}
<img
src=
"
{{
m.author.
avatar
_pict.get_download_url
()
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
else
%}
<img
src=
"
{{
static
(
'core/img/unknown.jpg'
)
}}
"
alt=
"
{%
trans
%}
Profile
{%
endtrans
%}
"
id=
"picture"
/>
{%
endif
%}
<br/>
<strong>
{{
user_profile_link
(
m.author
)
}}
</strong>
<strong>
<a
href=
"
{{
m.author.get_absolute_url
()
}}
"
>
{{
m.author.get_short_name
()
}}
</a>
</strong>
</div>
<div
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
style=
"display: inline-block; width:
80%; vertical-align: top;
{%
if
m.deleted
%}
background: #FFAAAA;
{%
endif
%}
"
>
<div
class=
"msg_content
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
>
<div
style=
"display: inline-block; width: 74%;"
>
{%
if
m.title
%}
<h5>
{{
m.title
}}
</h5>
...
...
@@ -73,24 +73,26 @@
{%
endif
%}
{%
endif
%}
<br/>
<span>
{{
m.date
|
date
(
DATETIME_FORMAT
)
}}
{{
m.dat
e
|
time
(
DATETIME_FORMAT
)
}}
</span>
<span>
{{
m.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
localtim
e
|
time
(
DATETIME_FORMAT
)
}}
</span>
</div>
<hr>
<div>
{{
m.message
|
markdown
}}
</div>
{%
if
m.can_be_moderated_by
(
user
)
%}
<ul>
{%
for
meta
in
m.metas.select_related
(
'user'
)
.
all
()
%}
<li>
{{
meta.get_action_display
()
}}
{{
meta.user.get_display_name
()
}}
{%
trans
%}
at
{%
endtrans
%}{{
meta.date
|
time
(
DATETIME_FORMAT
)
}}
{%
trans
%}
the
{%
endtrans
%}{{
meta.date
|
date
(
DATETIME_FORMAT
)
}}
</li>
<ul
class=
"msg_meta"
>
{%
for
meta
in
m.metas.select_related
(
'user'
)
.
order_by
(
'id'
)
%}
<li
style=
"background:
{%
if
m.author
==
meta.user
%}
#bfffbf
{%
else
%}
#ffffbf
{%
endif
%}
"
>
{{
meta.get_action_display
()
}}
{{
meta.user.get_display_name
()
}}
{%
trans
%}
at
{%
endtrans
%}{{
meta.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
{%
trans
%}
the
{%
endtrans
%}{{
meta.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
</li>
{%
endfor
%}
</ul>
{%
endif
%}
</div>
</div>
{{
m.mark_as_read
(
user
)
or
""
}}
{%
endif
%}
{%
endfor
%}
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
Reply
</a></p>
{%
endblock
%}
...
...
forum/views.py
View file @
fe07ee09
...
...
@@ -58,6 +58,8 @@ class ForumCreateView(CanCreateMixin, CreateView):
parent
=
Forum
.
objects
.
filter
(
id
=
self
.
request
.
GET
[
'parent'
]).
first
()
init
[
'parent'
]
=
parent
init
[
'owner_club'
]
=
parent
.
owner_club
init
[
'edit_groups'
]
=
parent
.
edit_groups
.
all
()
init
[
'view_groups'
]
=
parent
.
view_groups
.
all
()
except
:
pass
return
init
...
...
@@ -93,9 +95,15 @@ class ForumDetailView(CanViewMixin, DetailView):
kwargs
[
'topics'
]
=
self
.
object
.
topics
.
annotate
(
models
.
Max
(
'messages__date'
)).
order_by
(
'-messages__date__max'
)
return
kwargs
class
TopicForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
ForumMessage
fields
=
[
'title'
,
'message'
]
title
=
forms
.
CharField
(
required
=
True
)
class
ForumTopicCreateView
(
CanCreateMixin
,
CreateView
):
model
=
ForumMessage
f
ields
=
[
'title'
,
'message'
]
f
orm_class
=
TopicForm
template_name
=
"core/create.jinja"
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
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