def update(self):
        request = self.request
        context = self.context

        profile = IPersonalProfile(context)

        self.author = profile.title
        self.avatar = profile.avatarUrl(request)

        space = profile.space
        if space is not None:
            self.profile = '%s/'%absoluteURL(space, request)
        else:
            self.profile = None

        self.content = profile.getProfileData()

        super(PrincipalView, self).update()
class QuickInfo(PageletDisplayForm):

    @property
    def fields(self):
        content = self.content
        configlet = getUtility(IProfilesCategory)
        ids = getUtility(IIntIds)
        configletFields = configlet['default'].getFields()

        fields = []
        for id in configlet.quickInfoFields:
            field = ids.getObject(id)
            name = field.__name__
            if field in configletFields and field.visible:
                if content.get(name, field.missing_value) is not \
                        field.missing_value:
                    fields.append(field)

        return Fields(*fields)

    def update(self):
        context = self.context
        while not IProfileWorkspace.providedBy(context):
            context = context.__parent__

        self.workspace = context
        self.profile = IPersonalProfile(context.__principal__)
        self.content = self.profile.getProfileData()

        self.timezone = self.profile.timezone
        self.registered = self.profile.registered
        self.lastLoginTime = self.profile.lastLoginTime

        super(QuickInfo, self).update()

    def getContent(self):
        return self.content
Exemple #3
0
    def update(self):
        super(BasePostView, self).update()

        post = removeAllProxies(self.context)
        request = self.request
        owner = IOwnership(post).owner
        profile = IPersonalProfile(owner, None)
        space = getattr(profile, 'space', None)
        profileData = profile.getProfileData()

        self.post = post
        self.postUrl = absoluteURL(post, request)
        self.text = getattr(self.context.text, 'cooked', '')
        self.biography = profileData.get('about', False)
        self.jobtitle = profileData.get('jobtitle', False)
        if self.biography:
            self.biography = re.sub('<[^>]*>', '', self.biography.text)
            if len(self.biography) >= 240:
                self.biography = self.biography[:240].rsplit(' ', 1)[0].strip() + '...'

        # blog
        if IDraftedContent.providedBy(post):
            blog = post.__parent__
            location = blog.getLocation()
            if location is not None:
                blog = location.get('blog')
            else:
                blog = None
        else:
            blog = post.__parent__

        if IBlog.providedBy(blog):
            self.blog = blog
            self.blog_title = blog.title
            self.blog_url = absoluteURL(blog, request)
            self.tags_list = blog['tags'].listTags(post)

        # author
        try:
            self.author = profile.title
            self.avatar_url = profile.avatarUrl(request)
        except AttributeError:
            self.author = getattr(owner, 'title', '')
            self.avatar_url = '#'

        if space is not None:
            self.profile_url = '%s/profile/' % absoluteURL(space, request)

        # discussion
        discussion = IContentDiscussion(post, None)
        self.comments = discussion is not None and len(discussion)
        self.discussible = discussion is not None and discussion.status != 3
        self.footer_discussion = self.discussible and self.comments_num

        # categories
        categories = []
        ids = getUtility(IIntIds)

        for cId in post.category:
            category = ids.queryObject(cId)
            if category is not None:
                categories.append(
                    (category.title, {'name': category.__name__,
                                      'title': category.title}))

        categories.sort()
        self.categories = [info for t, info in categories]

        self.footer = self.categories or \
            self.tags_list or self.footer_discussion