Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
classifiedad
Commits
f1e439509272
Commit
d68ebc88
authored
Sep 28, 2010
by
Nicolas Chauvat
Browse files
similar entities box moved to cube similarity
parent
e60a4b7efaf7
Changes
1
Hide whitespace changes
Inline
Side-by-side
views.py
View file @
f1e43950
...
...
@@ -10,12 +10,12 @@ from logilab.mtconverter import xml_escape
from
cubicweb.selectors
import
has_related_entities
,
is_instance
from
cubicweb.web
import
uicfg
,
component
,
box
from
cubicweb.web
import
uicfg
,
component
from
cubicweb.web.views
import
primary
,
baseviews
from
cubicweb.web.facet
import
RelationFacet
,
AttributeFacet
,
RangeFacet
,
DateRangeFacet
from
cubes.similarity
import
get_vspace
from
cubes.similarity.views
import
SimilarAction
from
cubes.similarity.views
import
SimilarAction
,
SimilarEntitiesBox
uicfg
.
primaryview_section
.
tag_subject_of
((
'ClassifiedAd'
,
'same_as'
,
'*'
),
'hidden'
)
uicfg
.
primaryview_section
.
tag_subject_of
((
'ClassifiedAd'
,
'url'
,
'*'
),
'hidden'
)
...
...
@@ -82,25 +82,9 @@ class ProximityOfAds(baseviews.EntityView):
self
.
w
(
u
'</ul></td></tr>'
)
self
.
w
(
u
'</table>'
)
class
ClosestAdsBox
(
box
.
EntityBoxTemplate
):
__regid__
=
'closest_ads_box'
__select__
=
box
.
EntityBoxTemplate
.
__select__
&
is_instance
(
'ClassifiedAd'
,)
order
=
25
def
cell_call
(
self
,
row
,
col
,
**
kwargs
):
entity
=
self
.
cw_rset
.
get_entity
(
row
,
col
)
vspace
=
get_vspace
(
'ClassifiedAd'
,
self
.
_cw
)
scores
=
vspace
.
similarity_by_id
(
entity
.
eid
)
if
scores
:
self
.
w
(
u
'<div class="sideBox">'
)
self
.
w
(
u
'<div class="sideBoxTitle"><span>%s</span></div>'
%
_
(
'Similar ads'
))
self
.
w
(
u
'<div class="%s"><div class="sideBoxBody">'
%
'sideBox'
)
for
score
,
eids
in
scores
[:
5
]:
for
eid
in
eids
:
self
.
w
(
u
'<span>%.2f - %s</span><br />'
%
(
score
,
self
.
_cw
.
entity_from_eid
(
eid
).
view
(
'outofcontext'
)))
self
.
w
(
u
'</div>'
)
self
.
w
(
u
'</div>'
)
self
.
w
(
u
'</div>'
)
class
ClosestAdsBox
(
SimilarEntitiesBox
):
__select__
=
SimilarEntitiesBox
.
__select__
&
is_instance
(
'ClassifiedAd'
,)
etype
=
'ClassifiedAd'
class
ClassifiedAdSimilarAction
(
SimilarAction
):
__select__
=
is_instance
(
'ClassifiedAd'
)
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