Esempio n. 1
0
    def isAvailable(self):
        request = self.request
        principal = request.principal

        if not IUnauthenticatedPrincipal.providedBy(principal):
            return False

        auth = getUtility(IAuthentication)
        login = queryMultiAdapter((auth, request), ILoginService)

        if login is not None:
            if login.isChallenging():
                return False

            if IPluggableAuthentication.providedBy(auth):
                for name, creds in auth.getCredentialsPlugins():
                    if IDefaultCredentialsPlugin.providedBy(creds):
                        self.nextURL = login.nextURL()

                        if self.hasOpenId:
                            include("portlet-login")

                        return True

        return False
Esempio n. 2
0
    def update(self):
        if self.updated:
            return

        self.updated = True

        context = self.context
        if checkPermission('zojax.ModifyTaskStatus', context):
            self.severity = getUtility(
                IVocabularyFactory, 'project.task.severity')(context)

        if checkPermission('zojax.ModifyTaskAttributes', context):
            self.allowAttributes = True

        if checkPermission('zojax.AssignTo', context):
            self.allowAssign = True

        if checkPermission('zojax.AddContentAttachment', context):
            self.allowAttachments = True

        self.wfinfo = IWorkflowInfo(context)
        self.wfinfo.fireAutomatic()

        # subscribers
        auth = getUtility(IAuthentication)

        subs = getSubscribers(('tasks',), context)
        assignees = getSubscribers(('assigneetasks'), context)

        for pid in IAssignments(context).assignees:
            if pid in assignees:
                subs.add(pid)

        subscribers = []
        for subs in subs:
            try:
                principal = auth.getPrincipal(subs)
            except PrincipalLookupError:
                continue

            profile = IPersonalProfile(principal)

            subscribers.append(profile.title)

        subscribers.sort()
        self.subscribers = subscribers

        task = removeAllProxies(context)
        if checkPermission('zojax.ModifyContent', task.__parent__.__parent__):
            self.manageSubscribers = absoluteURL(
                task.__parent__.__parent__, self.request)

        super(TaskCommentForm, self).update()

        include('jquery-plugins')

        if 'file' in self.widgets:
            self.widgets['file'].klass = 'multi'
Esempio n. 3
0
    def update(self):
        queryObject = getUtility(IIntIds).queryObject
        self.categories = categories = []
        for uid in self.context.category:
            category = queryObject(uid)
            if category is not None:
                categories.append(category)
        categories.sort(key=attrgetter('title'))
        self.date = IZopeDublinCore(self.context).created
        self.autoplay = str(self.context.autoplay).lower()

        if self.context.mediaSource:
            self.mediaURL = None
        else:
            self.mediaURL = (self.context.mediaData is not None \
                             and self.context.mediaData.data) \
                            and '%s/view.html' % absoluteURL(self.context, self.request) \
                            or (self.context.mediaURL or '')
            if self.context.mediaURLList:
                self.mediaURL = self.context.mediaURLList[0]
                mediaURLList = self.context.mediaURLList
            else:
                mediaURLList = [self.mediaURL]
            urls = map(lambda x: r"""{\'url\':\'%s\', \'autoPlay\': %s}""" % (urllib.quote(x[1]), \
                                                                                 x[0]==0 and self.autoplay or 'true'), \
                                            enumerate(mediaURLList))
            self.mediaURLListEncoded = r"\'playlist\': [%s]" % ','.join(urls)
        discussion = IContentDiscussion(self.context, None)
        self.comments = discussion is not None and len(discussion)
        self.discussible = discussion is not None and discussion.status != 3
        self.addcomment = self.discussible and discussion.status != 2
        self.tags = IContentTags(self.context, None)
        self.tags = self.tags is not None and self.tags.tags or []
        self.url = absoluteURL(self.context, self.request)
        self.space = getSpace(self.context)
        self.container_url = absoluteURL(self.space, self.request)
        self.site_url = absoluteURL(getSite(), self.request)
        owner = IOwnership(self.context).owner
        space = IPersonalSpace(owner, None)
        profile = IPersonalProfile(owner, None)
        # author
        try:
            self.author = '%s %s'%(profile.firstname, profile.lastname)
            self.avatar_url = profile.avatarUrl(self.request)
        except AttributeError:
            self.author = getattr(owner,'title','')
            self.avatar_url = '#'

        if space is not None:
            self.profile_url = '%s/profile/'%absoluteURL(space, self.request)
        self.container_title = self.space.title
        include('jquery-plugins')
Esempio n. 4
0
    def update(self):
        self.catalog = queryUtility(ICatalog)

        if self.catalog is not None:
            self.fti = self.catalog.getFTIndex()
        else:
            self.fti = None

        self.value = self.request.get(self.fti)
        self.portal = getSite()

        if self.fti is not None:
            include('zojax.portlets.livesearch')
Esempio n. 5
0
    def update(self):
        include('zojax.photoalbum')

        product = getUtility(IPhotoAlbumProduct)

        self.lightbox = product.lightbox
        if self.lightbox:
            try:
                self.context.listPhotos().next()
                includeInplaceSource(lightboxinit, required=('jquery-lightbox',))
            except:
                pass

        title, self.width, self.height = sizes['thumbnail']
        self.url = absoluteURL(self.context, self.request)
Esempio n. 6
0
    def update(self):
        include('jquery-plugins')

        request = self.request

        if 'form.upload' in request:
            dataField = IPhoto['data']
            context = self.context

            files = []

            data = request.form.get('uploadFile', None)
            if data is not None:
                if type(data) is list:
                    files.extend(data)
                else:
                    files.append(data)

            updated = False
            for file in files:
                if not file:
                    continue

                for file in unpack(file):
                    name = file.filename

                    if name in context and \
                            not IPhoto.providedBy(context[name]):
                        photo = context[name]
                        field = dataField.bind(photo)
                        field.set(photo, file)
                        transaction.commit()
                        continue
                    elif name in context:
                        del context[name]

                    photo = Photo(name)
                    event.notify(ObjectCreatedEvent(photo))
                    context[name] = photo
                    field = dataField.bind(photo)
                    field.set(photo, file)
                    transaction.commit()
                    updated = True

            if updated:
                IStatusMessage(request).add(_(u'Files have been uploaded.'))
 def update(self):
     include('zojax.portlets.imagerotator')
     include('jquery.slick')
     self.url = publicAbsoluteURL(self, self.request)
Esempio n. 8
0
 def __call__(self, econtext):
     include(self._expr)
     return ''
Esempio n. 9
0
 def __init__(self, *args, **kw):
     include('blogger-advanced-post-form-js')
     super(AdvancedBlogPostAddForm, self).__init__(*args, **kw)
Esempio n. 10
0
    def update(self):
        include('zojax.photoalbum')

        title, self.width, self.height = sizes['medium']
        self.context.preview.generatePreview(self.width, self.height)
Esempio n. 11
0
    def update(self):
        include('jquery-plugins')
        super(UploadAttachments, self).update()

        self.widgets['file'].klass = 'multi'
 def __init__(self, *args, **kw):
     include('advanced-page')
     super(AdvancedPageEditForm, self).__init__(*args, **kw)
Esempio n. 13
0
 def render(self):
     include('zojax.ui.portaltabs')
     return super(MenuPortlet, self).render()
Esempio n. 14
0
 def update(self):
     super(MediaTypeWidget, self).update()
     library.include('jquery-plugins')
Esempio n. 15
0
 def __call__(self, expr):
     include(expr)
Esempio n. 16
0
 def update(self):
     include('zojax.usermanual')
     self.items = IOrder(self.context).values()
Esempio n. 17
0
 def update(self):
     super(AdvancedPostView, self).update()
     self.pages = [getattr(p.text, 'cooked', '') for p in self.context.pages]
     self.draft = IDraftedContent.providedBy(self.context)
     include('blogger-advanced-post-js')
Esempio n. 18
0
 def update(self):
     super(PortletPreview, self).update()
     include('zojax.portlet.preview')
Esempio n. 19
0
 def update(self):
     library.include('jquery-plugins')
Esempio n. 20
0
 def render(self):
     include('zojax.portlet.navigation')
     return super(NavigationPortlet, self).render()