Beispiel #1
0
    def items(self):
        request = self.request
        results = self.context['members'].values()
        auth = getUtility(IAuthentication)
        for member in results:
            try:
                principal = auth.getPrincipal(member.__name__)
            except PrincipalLookupError:
                principal = None

            space = IPersonalSpace(principal, None)
            profile = IPersonalProfile(principal, None)

            image = getattr(profile, 'profileImage', None)
            if image and IImage.providedBy(image):
                w, h = image.width, image.height
                if w > 128:
                    xscale = 128.0/w
                else:
                    xscale = 1.0
                if h > 128:
                    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, 97)
                default = True

            info = {
                'id': member.__name__,
                'title': getattr(profile, 'title', _(u'Unknown')),
                'description': getattr(principal, 'description', u''),
                'manager': u'',
                'personalspace': u'',
                'joined': member.joined,
                'imagex': image[0],
                'imagey': image[1],
                'default': default}

            if space is not None:
                info['manager'] = space.title
                info['personalspace'] = absoluteURL(space, self.request)

            info = {
                'title': info['title'],
                'description': info['description'],
                'guid': info['personalspace'] or info['id'],
                'pubDate': rfc822.formatdate(time.mktime(
                        info['joined'].timetuple())),
                'isPermaLink': True}

            if profile is not None:
                info['author'] = u'%s (%s)'%(profile.email, profile.title)

            yield info
Beispiel #2
0
    def getMemberInfo(self, id):
        member = self.context[id]

        try:
            principal = self.auth.getPrincipal(member.__name__)
        except PrincipalLookupError:
            principal = None

        try:
            profile = IPersonalProfile(principal)
        except:
            return

        image = profile.profileImage
        if image and IImage.providedBy(image):
            w, h = image.width, image.height
            if w > 128:
                xscale = 128.0/w
            else:
                xscale = 1.0
            if h > 128:
                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, 97)
            default = True

        info = {
            'id': id,
            'title': getattr(profile, 'title', _(u'Unknown')),
            'description': getattr(principal, 'description', u''),
            'manager': u'',
            'personalspace': u'',
            'joined': member.joined,
            'imagex': image[0],
            'imagey': image[1],
            'default': default,
            'photo': profile.photoUrl(self.request)}

        space = profile.space
        if space is not None:
            info['manager'] = space.title
            info['personalspace'] = absoluteURL(space, self.request)

        return info
Beispiel #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