Beispiel #1
0
 def render(self):
     context = aq_inner(self.context)
     source = getCurrentUsersHitList(context)
     if source is not None:
         if source.hasRelationshipTo(context, relationship='bookmarked'):
             return ""
     return self.template()
Beispiel #2
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('.')
Beispiel #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())
Beispiel #4
0
 def list(self):
     return getCurrentUsersHitList(self.context)