Skip to content
Snippets Groups Projects
Commit 647c153bca16 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

backport stable

No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,9 @@
__docformat__ = "restructuredtext en"
from cubicweb.entities import AnyEntity, fetch_config
from cubicweb.web.views.embedding import IEmbedableAdapter
from cubicweb.selectors import is_instance
class Link(AnyEntity):
"""customized class for Link entities"""
__regid__ = 'Link'
fetch_attrs, fetch_order = fetch_config(['title', 'url'])
......@@ -12,13 +10,12 @@
class Link(AnyEntity):
"""customized class for Link entities"""
__regid__ = 'Link'
fetch_attrs, fetch_order = fetch_config(['title', 'url'])
def dc_title(self):
return u'%s (%s)' % (self.title, self.url)
def actual_url(self):
if not self.embed:
return self.url
......@@ -19,14 +16,7 @@
def dc_title(self):
return u'%s (%s)' % (self.title, self.url)
def actual_url(self):
if not self.embed:
return self.url
return self._cw.build_url('embed', url=self.url, rql=self._cw.form.get('rql'))
class LinkIEmbedableAdapter(IEmbedableAdapter):
__select__ = is_instance('Link')
def embeded_url(self):
"""embed action interface"""
return self.entity.url
return self._cw.build_url('embed', url=self.url, rql=self._cw.form.get('rql') or u'')
......@@ -14,13 +14,16 @@
def test_possible_actions(self):
req = self.request()
rset = self.execute('Any X WHERE X is Link')
self.assertEqual(self.pactionsdict(req, rset),
{'moreactions': [embedding.EmbedAction],
'mainactions': [actions.ModifyAction, views.LinkFollowAction],
'moreactions': [actions.ManagePermissionsAction, actions.AddRelatedActions,
actions.DeleteAction, actions.CopyAction,
embedding.EmbedAction],
})
allactions = self.pactionsdict(req, rset)
self.assertEqual(allactions['mainactions'],
[actions.ModifyAction,
views.LinkFollowAction])
self.assertEqual(allactions['moreactions'],
[actions.ManagePermissionsAction,
actions.AddRelatedActions,
actions.DeleteAction,
actions.CopyAction,
embedding.EmbedAction])
def test_relations_by_category(self):
def rbc(iterable):
......
"""Specific views for links
:organization: Logilab
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
......@@ -12,6 +12,8 @@
from cubicweb.selectors import is_instance
from cubicweb.view import EntityView
from cubicweb.web import uicfg, formwidgets
from cubicweb.web.views import primary, baseviews
from cubicweb.web.views import xbel, bookmark
from cubicweb.web.views import primary, baseviews, xbel, bookmark, embedding
class LinkIEmbedableAdapter(embedding.IEmbedableAdapter):
__select__ = is_instance('Link')
......@@ -17,5 +19,9 @@
for attr in ('title', 'url', 'embed', 'description'):
def embeded_url(self):
"""embed action interface"""
return self.entity.url
for attr in ('title', 'url', 'embed'):
uicfg.primaryview_section.tag_attribute(('Link', attr), 'hidden')
uicfg.autoform_field_kwargs.tag_attribute(('Link', 'url'),
......@@ -32,9 +38,6 @@
self.w(u'<h1><span class="etype">%s</span> %s</h1>'
% (entity.dc_type().capitalize(), title))
def summary(self, entity):
return entity.view('reledit', rtype='description')
class LinkOneLineView(baseviews.OneLineView):
__select__ = is_instance('Link')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment