Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
comment
Commits
3e9b0974739c
Commit
3e9b0974739c
authored
16 years ago
by
sylvain thenault
Browse files
Options
Downloads
Patches
Plain Diff
3.2 update
parent
2ee5820ef5b9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
views.py
+24
-29
24 additions, 29 deletions
views.py
with
24 additions
and
29 deletions
views.py
+
24
−
29
View file @
3e9b0974
"""
Specific views and actions for application using the Comment entity type
:organization: Logilab
:copyright: 2003-200
8
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-200
9
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__
=
"
restructuredtext en
"
...
...
@@ -9,6 +9,7 @@
from
itertools
import
count
from
logilab.mtconverter
import
html_escape
from
logilab.common.decorators
import
monkeypatch
from
simplejson
import
dumps
...
...
@@ -12,5 +13,8 @@
from
simplejson
import
dumps
from
cubicweb.selectors
import
one_line_rset
,
but_etype
,
implements
,
has_permission
from
cubicweb.selectors
import
(
one_line_rset
,
but_etype
,
implements
,
has_permission
,
relation_possible
,
yes
)
from
cubicweb.view
import
EntityView
from
cubicweb.selectors
import
match_kwargs
,
accept
from
cubicweb.common.uilib
import
rql_for_eid
,
cut
,
safe_cut
,
ajax_replace_url
...
...
@@ -16,3 +20,2 @@
from
cubicweb.common.uilib
import
rql_for_eid
,
cut
,
safe_cut
,
ajax_replace_url
from
cubicweb.common.view
import
EntityView
from
cubicweb.common.mixins
import
TreeViewMixIn
...
...
@@ -18,6 +21,3 @@
from
cubicweb.common.mixins
import
TreeViewMixIn
from
cubicweb.common.selectors
import
(
match_kwargs
,
accept
)
from
cubicweb.web
import
stdmsgs
from
cubicweb.web.action
import
(
LinkToEntityAction
,
Action
)
...
...
@@ -22,9 +22,11 @@
from
cubicweb.web
import
stdmsgs
from
cubicweb.web.action
import
(
LinkToEntityAction
,
Action
)
from
cubicweb.web.views
import
baseviews
from
cubicweb.web.views
import
baseviews
,
baseforms
from
cubicweb.web.component
import
EntityVComponent
from
cubicweb.web.views.basecontrollers
import
JSonController
_
=
unicode
# comment views ###############################################################
class
CommentPrimaryView
(
baseviews
.
PrimaryView
):
...
...
@@ -25,10 +27,10 @@
_
=
unicode
# comment views ###############################################################
class
CommentPrimaryView
(
baseviews
.
PrimaryView
):
accepts
=
(
'
Comment
'
,
)
__select__
=
implements
(
'
Comment
'
)
def
cell_call
(
self
,
row
,
col
):
self
.
req
.
add_css
(
'
cubes.comment.css
'
)
...
...
@@ -61,7 +63,7 @@
class
CommentSecondaryView
(
baseviews
.
SecondaryView
):
accepts
=
(
'
Comment
'
,
)
__select__
=
implements
(
'
Comment
'
)
def
cell_call
(
self
,
row
,
col
,
**
kwargs
):
entity
=
self
.
entity
(
row
,
col
)
...
...
@@ -81,6 +83,4 @@
class
CommentTreeItemView
(
baseviews
.
ListItemView
):
accepts
=
(
'
Comment
'
,)
id
=
'
treeitem
'
...
...
@@ -86,4 +86,5 @@
id
=
'
treeitem
'
__select__
=
implements
(
'
Comment
'
)
def
cell_call
(
self
,
row
,
col
,
**
kwargs
):
_
=
self
.
req
.
_
...
...
@@ -123,7 +124,7 @@
class
CommentThreadView
(
TreeViewMixIn
,
baseviews
.
ListView
):
"""
a recursive tree view
"""
accepts
=
(
'
Comment
'
,
)
__select__
=
implements
(
'
Comment
'
)
title
=
_
(
'
thread view
'
)
def
open_item
(
self
,
entity
):
...
...
@@ -132,7 +133,5 @@
# comment edition views #######################################################
from
cubicweb.web.views
import
baseforms
class
InlineCommentView
(
EntityView
):
id
=
'
inlinecomment
'
...
...
@@ -137,6 +136,6 @@
class
InlineCommentView
(
EntityView
):
id
=
'
inlinecomment
'
__select
ors
__
=
(
yes
,
)
# explicit call when it makes sense
,
__select__
=
yes
(
)
# explicit call when it makes sense
def
cell_call
(
self
,
row
,
col
):
entity
=
self
.
entity
(
row
,
col
)
...
...
@@ -145,7 +144,7 @@
class
InlineCommentForm
(
baseforms
.
CreationForm
):
id
=
'
inlinecommentform
'
__select
ors
__
=
(
match_kwargs
(
'
commented
'
)
,)
# explicit call when it makes sense
,
__select__
=
match_kwargs
(
'
commented
'
)
# explicit call when it makes sense
title
=
None
# hidden
...
...
@@ -219,10 +218,8 @@
# comment component ###########################################################
from
cubicweb.web.component
import
EntityVComponent
class
CommentSectionVComponent
(
EntityVComponent
):
"""
a component to display a <div> html section including comments
related to an object
"""
id
=
'
commentsection
'
...
...
@@ -224,11 +221,10 @@
class
CommentSectionVComponent
(
EntityVComponent
):
"""
a component to display a <div> html section including comments
related to an object
"""
id
=
'
commentsection
'
etype
=
'
Comment
'
rtype
=
'
comments
'
target
=
'
subject
'
__select__
=
EntityVComponent
.
__select__
&
relation_possible
(
'
comments
'
,
'
object
'
,
'
Comment
'
)
context
=
'
navcontentbottom
'
def
cell_call
(
self
,
row
,
col
,
view
=
None
,
orderby
=
'
diem
'
):
...
...
@@ -270,7 +266,8 @@
baseviews
.
PRIMARY_SKIP_RELS
.
add
(
'
comments
'
)
# displayed by the above component
# comment actions #############################################################
class
ReplyCommentAction
(
LinkToEntityAction
):
id
=
'
reply_comment
'
...
...
@@ -273,8 +270,8 @@
# comment actions #############################################################
class
ReplyCommentAction
(
LinkToEntityAction
):
id
=
'
reply_comment
'
__select
ors
__
=
LinkToEntityAction
+
(
implements
(
'
Comments
'
)
,)
__select__
=
LinkToEntityAction
.
__select__
&
implements
(
'
Comments
'
)
etype
=
'
Comment
'
rtype
=
'
comments
'
...
...
@@ -297,7 +294,7 @@
class
AddCommentAction
(
LinkToEntityAction
):
"""
add comment is like reply for everything but Comment
"""
id
=
'
reply_comment
'
__select
ors
__
=
LinkToEntityAction
+
(
implements
(
'
Any
'
),
but_etype
(
'
Comment
'
)
,)
__select__
=
LinkToEntityAction
.
__select__
&
but_etype
(
'
Comment
'
)
etype
=
'
Comment
'
rtype
=
'
comments
'
...
...
@@ -310,7 +307,7 @@
class
EditCommentAction
(
Action
):
id
=
'
edit_comment
'
__select
ors
__
=
(
one_line_rset
,
implements
(
'
Comment
'
)
,
has_permission
(
'
update
'
)
)
__select__
=
one_line_rset
()
&
implements
(
'
Comment
'
)
&
has_permission
(
'
update
'
)
title
=
_
(
'
edit comment
'
)
category
=
'
hidden
'
...
...
@@ -319,5 +316,6 @@
def
url
(
self
):
return
self
.
build_url
(
rql
=
self
.
rset
.
printable_rql
(),
vid
=
'
edition
'
)
# add some comments related methods to the Jsoncontroller #####################
...
...
@@ -322,9 +320,8 @@
# add some comments related methods to the Jsoncontroller #####################
from
cubicweb.web.views.basecontrollers
import
JSonController
@monkeypatch
(
JSonController
)
def
js_add_comment
(
self
,
commented
,
text
,
format
):
rql
=
'
INSERT Comment C: C content %(text)s, C content_format %(format)s, C comments X WHERE X eid %(x)s
'
rset
=
self
.
req
.
execute
(
rql
,
{
'
format
'
:
format
,
'
text
'
:
text
,
'
x
'
:
commented
},
'
x
'
)
return
u
''
...
...
@@ -326,12 +323,11 @@
def
js_add_comment
(
self
,
commented
,
text
,
format
):
rql
=
'
INSERT Comment C: C content %(text)s, C content_format %(format)s, C comments X WHERE X eid %(x)s
'
rset
=
self
.
req
.
execute
(
rql
,
{
'
format
'
:
format
,
'
text
'
:
text
,
'
x
'
:
commented
},
'
x
'
)
return
u
''
JSonController
.
js_add_comment
=
js_add_comment
@monkeypatch
(
JSonController
)
def
js_edit_comment
(
self
,
comment
,
text
,
format
):
rql
=
'
SET C content %(text)s, C content_format %(format)s WHERE C eid %(x)s
'
rset
=
self
.
req
.
execute
(
rql
,
{
'
format
'
:
format
,
'
text
'
:
text
,
'
x
'
:
comment
},
'
x
'
)
return
u
''
...
...
@@ -333,6 +329,5 @@
def
js_edit_comment
(
self
,
comment
,
text
,
format
):
rql
=
'
SET C content %(text)s, C content_format %(format)s WHERE C eid %(x)s
'
rset
=
self
.
req
.
execute
(
rql
,
{
'
format
'
:
format
,
'
text
'
:
text
,
'
x
'
:
comment
},
'
x
'
)
return
u
''
JSonController
.
js_edit_comment
=
js_edit_comment
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment