Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blog
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
blog
Commits
45510a9bb345
Commit
45510a9bb345
authored
14 years ago
by
Nicolas Chauvat
Browse files
Options
Downloads
Patches
Plain Diff
[views] use has_creator when available. add cwuri facet.
parent
fe739ada925c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
views/facet.py
+7
-0
7 additions, 0 deletions
views/facet.py
views/primary.py
+21
-4
21 additions, 4 deletions
views/primary.py
with
28 additions
and
4 deletions
views/facet.py
0 → 100644
+
7
−
0
View file @
45510a9b
from
cubicweb.selectors
import
is_instance
from
cubicweb.web.facet
import
AttributeFacet
class
CWUriFacet
(
AttributeFacet
):
__regid__
=
'
cwuri-facet
'
__select__
=
AttributeFacet
.
__select__
&
is_instance
(
'
BlogEntry
'
,
'
MicroBlogEntry
'
)
rtype
=
'
cwuri
'
This diff is collapsed.
Click to expand it.
views/primary.py
+
21
−
4
View file @
45510a9b
...
...
@@ -61,8 +61,14 @@
w
(
u
'
<h1>%s</h1>
'
%
entity
.
view
(
'
incontext
'
))
w
(
u
'
<div class=
"
author_date
"
><div>%s
'
%
req
.
format_date
(
entity
.
creation_date
))
creator
=
entity
.
creator
if
creator
:
vtitle
=
_
(
'
blog entries created by %s
'
)
%
creator
.
name
()
rql
=
None
if
entity
.
has_creator
:
creator
=
entity
.
has_creator
[
0
]
name
=
creator
.
name
rql
=
'
Any X ORDERBY D DESC WHERE X is BlogEntry, X has_creator Y,
'
\
'
Y eid %s, X creation_date D
'
%
creator
.
eid
elif
entity
.
creator
:
creator
=
entity
.
creator
name
=
creator
.
name
()
rql
=
'
Any X ORDERBY D DESC WHERE X is BlogEntry, X created_by Y,
'
\
'
Y eid %s, X creation_date D
'
%
creator
.
eid
...
...
@@ -67,4 +73,6 @@
rql
=
'
Any X ORDERBY D DESC WHERE X is BlogEntry, X created_by Y,
'
\
'
Y eid %s, X creation_date D
'
%
creator
.
eid
if
rql
:
vtitle
=
_
(
'
blog entries created by %s
'
)
%
name
url
=
req
.
build_url
(
'
view
'
,
rql
=
rql
,
vtitle
=
vtitle
,
page_size
=
10
)
w
(
u
'
%s <a title=
"
%s
"
href=
"
%s
"
>%s</a>
'
%
(
...
...
@@ -69,9 +77,9 @@
url
=
req
.
build_url
(
'
view
'
,
rql
=
rql
,
vtitle
=
vtitle
,
page_size
=
10
)
w
(
u
'
%s <a title=
"
%s
"
href=
"
%s
"
>%s</a>
'
%
(
_
(
'
by
'
),
xml_escape
(
vtitle
),
xml_escape
(
url
),
creator
.
name
()
))
_
(
'
by
'
),
xml_escape
(
vtitle
),
xml_escape
(
url
),
name
))
w
(
u
'
</div></div>
'
)
class
BlogEntryPrimaryView
(
primary
.
PrimaryView
):
__select__
=
is_instance
(
'
BlogEntry
'
)
show_attr_label
=
False
...
...
@@ -72,9 +80,18 @@
w
(
u
'
</div></div>
'
)
class
BlogEntryPrimaryView
(
primary
.
PrimaryView
):
__select__
=
is_instance
(
'
BlogEntry
'
)
show_attr_label
=
False
def
render_entity_toolbox
(
self
,
entity
):
# copy from PrimaryView
context
=
'
ctxtoolbar
'
self
.
w
(
u
'
<div class=
"
%s
"
>
'
%
context
)
for
comp
in
self
.
_cw
.
vreg
[
'
toolbar
'
].
poss_visible_objects
(
self
.
_cw
,
rset
=
self
.
cw_rset
,
row
=
self
.
cw_row
,
view
=
self
,
context
=
context
):
comp
.
render
(
w
=
self
.
w
,
row
=
self
.
cw_row
,
view
=
self
)
self
.
w
(
u
'
</div>
'
)
def
render_entity_relations
(
self
,
entity
):
rset
=
entity
.
related
(
'
entry_of
'
,
'
subject
'
)
if
rset
:
...
...
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