Skip to content
Snippets Groups Projects
Commit af044176e815 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

flake8

parent 63f8548dad12
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@
:copyright: 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
from cubicweb.entities import AnyEntity, fetch_config
......@@ -8,6 +7,7 @@
from cubicweb.entities import AnyEntity, fetch_config
class Link(AnyEntity):
"""customized class for Link entities"""
__regid__ = 'Link'
......@@ -15,4 +15,3 @@
def dc_title(self):
return u'%s (%s)' % (self.title, self.url)
from cubicweb.predicates import is_instance
from cubicweb.sobjects.notification import ContentAddedView
class LinkAddedView(ContentAddedView):
"""get notified from new links"""
__select__ = is_instance('Link')
......
from yams.buildobjs import EntityType, RelationType, String, Boolean, RichString
_ = unicode
......@@ -2,4 +1,5 @@
_ = unicode
from yams.buildobjs import EntityType, String, RichString
class Link(EntityType):
"""a link to an external internet resource"""
......@@ -7,5 +7,4 @@
url = String(required=True, fulltextindexed=True, maxsize=512,
description=_("link's url"))
description = RichString(fulltextindexed=True,
description=_("description of the linked page's content"))
description=_("description of the linked page's content"))
LINK_ICON = data('icon_link.gif')
LINK_ICON = data('icon_link.gif') # noqa: F821
......@@ -13,7 +13,7 @@
from cubicweb.view import EntityView
from cubicweb.web import formwidgets
from cubicweb.web import action
from cubicweb.web.views import uicfg, primary, baseviews, xbel, bookmark
from cubicweb.web.views import uicfg, primary, baseviews, xbel
for attr in ('title', 'url'):
......@@ -66,6 +66,7 @@
self.w(u'<a href="%(url)s" title="%(description)s">%(title)s</a>'
% values)
class XbelItemLinkView(xbel.XbelItemView):
__select__ = is_instance('Link')
......
from logilab.common.testlib import unittest_main
from cubicweb.devtools.testlib import AutomaticWebTest
class AutomaticWebTest(AutomaticWebTest):
def to_test_etypes(self):
......@@ -9,5 +10,6 @@
def list_startup_views(self):
return ()
if __name__ == '__main__':
unittest_main()
......@@ -6,6 +6,7 @@
afs = uicfg.autoform_section
class LinkTC(CubicWebTC):
def setup_database(self):
......@@ -33,11 +34,11 @@
with self.admin_access.web_request() as req:
e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
[('title', 'subject'), ('url', 'subject'),
('description', 'subject')])
[('title', 'subject'), ('url', 'subject'),
('description', 'subject')])
with self.admin_access.repo_cnx() as cnx:
self.create_user(cnx, u'toto')
with self.new_access(u'toto').web_request() as req:
# create a new instance with the new connection
e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
......@@ -38,11 +39,12 @@
with self.admin_access.repo_cnx() as cnx:
self.create_user(cnx, u'toto')
with self.new_access(u'toto').web_request() as req:
# create a new instance with the new connection
e = self.vreg["etypes"].etype_class('Link')(req)
self.assertEqual(rbc(afs.relations_by_section(e, 'main', 'attributes', 'update')),
[('title', 'subject'), ('url', 'subject'),
('description', 'subject')])
[('title', 'subject'), ('url', 'subject'),
('description', 'subject')])
if __name__ == '__main__':
from unittest import main
......
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