示例#1
0
 def add(self):
     context = aq_inner(self.context)
     source = getCurrentUsersHitList(context)
     utils = getToolByName(context,'plone_utils')
     if source is None:
         if not self.hasPermission():
             raise Unauthorized
         else:
             mship = getToolByName(context,'portal_membership')
             homefolder = mship.getHomeFolder()
             if homefolder is None:
                 mship.createMemberarea()
                 homefolder = mship.getHomeFolder()
             typestool = getToolByName(context, 'portal_types')
             typestool.constructContent(type_name='HitList', container=homefolder, id='hitlist')
             source = homefolder['hitlist']
     if source is not None:
         if not source.hasRelationshipTo(context, relationship='bookmarked'):
             source.addReference(context, relationship='bookmarked')
             if source.hasRelationshipTo(context, relationship='bookmarked'):
                 utils.addPortalMessage(_(u'Item successfully added to your hitlist.'), 'info')
             else:
                 utils.addPortalMessage(_(u'Adding the item to your hitlist failed.'), 'error')
         else:
             utils.addPortalMessage(_(u'You already added this item to your hitlist.'), 'info')
     self.request.response.redirect('.')
示例#2
0
 def Title(self):
     """
     """
     try:
         return safe_unicode(translate(_('hitlist_title', default=u'Hitlist'), context=self.REQUEST)).encode('utf-8')
     except:
         return 'Hitlist'
示例#3
0
 def remove(self):
     context = aq_inner(self.context)
     source = getCurrentUsersHitList(context)
     utils = getToolByName(context,'plone_utils')
     if source is None and self.hasPermission():
         raise Unauthorized
     else:
         if source.hasRelationshipTo(context, relationship='bookmarked'):
             source.deleteReference(context, relationship='bookmarked')
             utils.addPortalMessage(_(u'Item successfully removed from your hitlist.'), 'info')
     self.request.response.redirect(source.absolute_url())
示例#4
0
from Products.ATContentTypes.content.base import ATCTMixin

from Products.HitList.config import PROJECTNAME
from Products.HitList.interfaces import IHitList
from Products.HitList import HitListMessageFactory as _

HitListSchema = BaseContentMixin.schema.copy() + Schema((

    ReferenceField(
        name='bookmarks',
        required=0,
        relationship='bookmarked',
        multiValued=1,
        widget=ReferenceWidget(
            label=_('label_bookmarks', default=u'Bookmarks'),
            visible=0,
        ),
    ),

))

HitListSchema.delField('title')


class HitList(BaseContentMixin, ATCTMixin):
    """ A users hitlist
    """
    implements(IHitList)

    portal_type = meta_type = "HitList"