本文整理汇总了Python中plone.app.event.dx.behaviors.IEventBasic类的典型用法代码示例。如果您正苦于以下问题:Python IEventBasic类的具体用法?Python IEventBasic怎么用?Python IEventBasic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IEventBasic类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_related_contacts_behavior_view_for_contact
def test_related_contacts_behavior_view_for_contact(self):
add_behavior('Event', IRelatedContacts.__identifier__)
timezone = 'Europe/Brussels'
now = datetime.datetime.now()
self.event = api.content.create(
container=self.portal,
type='Event',
id='event')
self.event.timezone = timezone
eventbasic = IEventBasic(self.event)
eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
self.event.reindexObject()
view = getMultiAdapter(
(self.event, self.request), name='event_summary')
person, organization1, organization2 = add_test_contents(self.portal)
# set related contact
intids = getUtility(IIntIds)
to_id = intids.getId(organization1)
rv = RelationValue(to_id)
self.event.contact = rv
self.assertEqual(
view.get_website(organization1),
None
)
organization1.website = 'www.foo.bar'
self.assertEqual(
view.get_website(organization1),
'<a class="event_website" href="http://www.foo.bar" target="_blank">www.foo.bar</a>' # noqa
)
示例2: test_phone_or_cellphone
def test_phone_or_cellphone(self):
add_behavior('Event', IRelatedContacts.__identifier__)
timezone = 'Europe/Brussels'
now = datetime.datetime.now()
self.event = api.content.create(
container=self.portal,
type='Event',
id='event')
self.event.timezone = timezone
eventbasic = IEventBasic(self.event)
eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
self.event.reindexObject()
view = getMultiAdapter(
(self.event, self.request), name='event_summary')
person, organization1, organization2 = add_test_contents(self.portal)
organization1.phone = ['081/586.100']
phone_or_cellphone = view.get_phone_or_cellphone(organization1)
self.assertEqual(phone_or_cellphone[0].get('formated'),
'+32 (0) 81 58 61 00')
organization1.phone = []
phone_or_cellphone = view.get_phone_or_cellphone(organization1)
self.assertEqual(len(phone_or_cellphone), 0)
organization1.cell_phone = ['081/586.101']
phone_or_cellphone = view.get_phone_or_cellphone(organization1)
self.assertEqual(phone_or_cellphone[0].get('formated'),
'+32 (0) 81 58 61 01')
示例3: test_related_contacts_behavior_view_for_partners
def test_related_contacts_behavior_view_for_partners(self):
add_behavior('Event', IRelatedContacts.__identifier__)
timezone = 'Europe/Brussels'
now = datetime.datetime.now()
self.event = api.content.create(
container=self.portal,
type='Event',
id='event')
self.event.timezone = timezone
eventbasic = IEventBasic(self.event)
eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
self.event.reindexObject()
view = getMultiAdapter(
(self.event, self.request), name='event_summary')
self.assertNotIn('partners', view())
person, organization1, organization2 = add_test_contents(self.portal)
# set related contact
intids = getUtility(IIntIds)
to_id1 = intids.getId(person)
to_id2 = intids.getId(organization2)
rv1 = RelationValue(to_id1)
rv2 = RelationValue(to_id2)
self.event.partners = [rv1, rv2]
self.assertIn('partners', view())
示例4: test_validate_invariants_ok
def test_validate_invariants_ok(self):
mock = MockEvent()
mock.start = datetime(2009, 1, 1)
mock.end = datetime(2009, 1, 2)
try:
IEventBasic.validateInvariants(mock)
except:
self.fail()
示例5: set_event_fields
def set_event_fields(self, obj, data):
self.set_fields(obj, data)
#
event = IEventBasic(obj)
start = DateTime(data["startDate"]["value"])
event.start = self.format_datetime(start)
end = DateTime(data["endDate"]["value"])
event.end = self.format_datetime(end)
event.timezone = 'CET'
示例6: test_validate_invariants_edge
def test_validate_invariants_edge(self):
data = MockEvent()
data.start = datetime.datetime(2009, 1, 2)
data.end = datetime.datetime(2009, 1, 2)
try:
IEventBasic.validateInvariants(data)
except:
self.fail()
示例7: test_validate_invariants_edge
def test_validate_invariants_edge(self):
mock = MockEvent()
mock.start = datetime(2009, 1, 2)
mock.end = datetime(2009, 1, 2)
mock.open_end = False
try:
IEventBasic.validateInvariants(mock)
except:
self.fail()
示例8: test_validate_invariants_fail
def test_validate_invariants_fail(self):
mock = MockEvent()
mock.start = datetime(2009, 1, 2)
mock.end = datetime(2009, 1, 1)
try:
IEventBasic.validateInvariants(mock)
self.fail()
except StartBeforeEnd:
pass
示例9: test_validate_invariants_fail
def test_validate_invariants_fail(self):
data = MockEvent()
data.start = datetime.datetime(2009, 1, 2)
data.end = datetime.datetime(2009, 1, 1)
try:
IEventBasic.validateInvariants(data)
self.fail()
except StartBeforeEnd:
pass
示例10: test_event_view_without_behavior
def test_event_view_without_behavior(self):
timezone = 'Europe/Brussels'
now = datetime.datetime.now()
self.event = api.content.create(
container=self.portal,
type='Event',
id='event')
self.event.timezone = timezone
self.event.location = u'Mon adresse'
eventbasic = IEventBasic(self.event)
eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18)
eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21)
self.event.reindexObject()
view = getMultiAdapter(
(self.event, self.request), name='event_summary')
self.assertNotIn('partners', view())
示例11: test_validate_dont_validate_incomplete
def test_validate_dont_validate_incomplete(self):
"""Don't validate validate_start_end invariant, if start or end are
None.
"""
mock = MockEvent()
mock.open_end = False
mock.start = datetime(2016, 5, 18)
mock.end = None
try:
IEventBasic.validateInvariants(mock)
except:
self.fail()
mock.start = None
mock.end = datetime(2016, 5, 18)
try:
IEventBasic.validateInvariants(mock)
except:
self.fail()
mock.start = None
mock.end = None
try:
IEventBasic.validateInvariants(mock)
except:
self.fail()
示例12: EventSchema
from zope import schema
from plone.autoform.interfaces import WIDGETS_KEY
from plone.app.event.dx.behaviors import IEventBasic
from plone.supermodel import model
from plone.namedfile.field import NamedBlobImage
from collective.rcse.i18n import _
from collective.z3cform.html5widgets.widget_datetime import DateTimeWidget
#override event basic widgets
IEventBasic.setTaggedValue(
WIDGETS_KEY, {'start': DateTimeWidget,
'end': DateTimeWidget}
)
class EventSchema(model.Schema):
"""event extra fields"""
image = NamedBlobImage(title=_(u"Image"),
description=_(u"image_description"),
required=False)
urlMedia = schema.URI(title=_(u"Media URL"),
description=_(u"urlMedia_description"),
required=False)
urlGMaps = schema.URI(title=_(u"Google Maps URL"),
description=_(u"urlGMaps_description"),
required=False)