Ejemplo n.º 1
0
def getDraftContainer(principal, dct):
    space = IPersonalSpace(principal, None)
    if space is not None:
        wf = getAdapter(space, IContentWorkspaceFactory, 'content')
        if space.isEnabled(wf):
            ws = wf.install()
            return ws['draft']
Ejemplo n.º 2
0
 def update(self):
     space = getSpace(self.context)
     if IPersonalSpace.providedBy(space):
         principal = space.principal
     else:
         principal = self.request.principal
     try:
         self.engine = IPersonalFriendConnect(principal).engine
     except (TypeError, AttributeError):
         return
     self.siteUrl = absoluteURL(getSite(), self.request)
     super(PersonalFriendConnectPortlet, self).update()
Ejemplo n.º 3
0
    def getMemberInfo(self, hf):
        if IPersonalSpace.providedBy(hf):
            principal = hf.principal
        else:
            principal = getattr(IOwnership(hf, None), 'owner', None)
            if principal is None:
                return
        try:
            profile = IPersonalProfile(principal)
        except TypeError:
            return

        image = profile.profileImage
        if IImage.providedBy(image) and image:
            w, h = image.width, image.height
            if w > 128:
                xscale = 128.0/w
            else:
                xscale = 1.0
            if h > 120:
                yscale = 120.0/h
            else:
                yscale = 1.0
            scale = xscale < yscale and xscale or yscale
            image = (int(round(w*scale)), int(round(h*scale)))
            default = False
        else:
            image = (128, 98)
            default = True

        info = {
            'id': hf.__name__,
            'title': profile.title,
            'description': principal.description,
            'manager': hf.title,
            'joined': profile.registered,
            'imagex': image[0],
            'imagey': image[1],
            'default': default,
            'photo': profile.photoUrl(self.request)}
        return info
Ejemplo n.º 4
0
    def update(self):
        space = self.context
        while space is not None and not IPersonalSpace.providedBy(space):
            space = space.__parent__
        self.space = space

        if space is not None:
            self.container = IFavoriteStorage(space.principal, None)
            if self.container is not None:
                if space.principal.id != self.request.principal.id:
                    self.title = _(u"${title}'s links",
                                   mapping=dict(title=space.principal.title))
        else:
            self.container = IFavoriteStorage(self.request.principal, None)

        if self.container is not None:
            self.container_url = '%s/'%(
                            absoluteURL(self.container, self.request),)

        self.favorites = self.listFavorites()

        super(YourFavoritesPortlet, self).update()