Beispiel #1
0
class SchutzhandschuhFilter(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IBelowContentTitle)

    def available(self):
        if ISchutzhandschuhOrdner.providedBy(self.context):
            return True
        return False

    def getHersteller(self):
        fc = self.context.getFolderContents()
        produkthersteller = []
        for i in fc:
            if i.portal_type in [
                    'Schutzhandschuh', 'Hautreinigungsmittel',
                    'Hautpflegemittel', 'Hautschutzmittel',
                    'Desinfektionsmittel'
            ]:
                obj = i.getObject()
                if obj.hersteller:
                    if (obj.hersteller.to_object.UID(),
                            obj.hersteller.to_object.title
                        ) not in produkthersteller:
                        produkthersteller.append(
                            (obj.hersteller.to_object.UID(),
                             obj.hersteller.to_object.title))
        sorted_produkthersteller = sorted(produkthersteller,
                                          key=lambda tup: tup[1])
        return sorted_produkthersteller

    def update(self):
        self.hersteller = self.getHersteller()
Beispiel #2
0
class CareerFormViewlet(api.Viewlet):
    api.context(IATNewsItem)
    api.viewletmanager(IBelowContentBody)

    def available(self):
        if self.context.getReferences('rel_careerform'):
            return True
        return False

    def update(self):
        if self.available():
            ref = self.context.getReferences('rel_careerform')[0]
            kennziffer = getattr(self.context, 'kennziffer', '')
            pin = getattr(self.context, 'pin', '')
            mail = getattr(self.context, 'email', '')
            pin = hashlib.sha224(pin).hexdigest()
            self.linkurl = "%s?kennziffer=%s&pin=%s&stellentitel=%s/%s&mykennziffer=%s&empfaenger=%s" % (ref.absolute_url(), 
                                                                                        kennziffer, 
                                                                                        pin,
                                                                                        self.context.title,
                                                                                        kennziffer,
                                                                                        kennziffer,
                                                                                        mail)
            bewerbungsfrist = getattr(self.context, 'bewerbungsfrist')
            if bewerbungsfrist:
                self.bewerbungsfrist = bewerbungsfrist.strftime('%d.%m.%Y')
            else:
                self.bewerbungsfrist = ''
            self.ansprechperson = getattr(self.context, 'ansprechperson')
            self.telefon = getattr(self.context, 'telefon')
Beispiel #3
0
class SummaryViewlet(api.Viewlet):
    api.context(IDocument)
    api.viewletmanager(IBelowContent)

    def render(self):
        cleaned = cleanhtml(self.context.text.raw)
        return "<div> %s </div>" % summarize(cleaned)
Beispiel #4
0
class PageFooter(api.Viewlet):
    grok.layer(IAnonymousLayer)
    api.context(interface.Interface)
    api.viewletmanager(IFooter)

    def update(self):
        pathroot = self.context.absolute_url_path().split('/')[1]
        self.rechteurl = '/%s/index.html/bildrechte' % pathroot
Beispiel #5
0
class PortalMarkerViewlet(ContentBoxViewlet):
    api.context(Interface)
    api.viewletmanager(IPortalTop)


    def memberdata(self):
        self.memberfullname = self.member_name_or_id()
        self.memberfolder = self.memberfolder()
        self.memberprefs = self.memberprefs()
        self.userprofile = self.userprofile()

    def memberfolder(self):
        if not ploneapi.user.is_anonymous():
            userid = ploneapi.user.get_current().id
            portalobj = ploneapi.portal.get()
            members = getattr(portalobj, 'Members', None)
            if members:
                memberfolder = getattr(members, userid, None)
                if memberfolder:
                    return "%s/Members/%s" %(ploneapi.portal.get().absolute_url(), userid)
            return None

    def memberprefs(self):
        return ploneapi.portal.get().absolute_url() + '/@@personal-preferences'

    def userprofile(self):
        return ploneapi.portal.get().absolute_url() + '/@@userprofileform'


    def loginform(self):
        loginurl = ''
        if ploneapi.user.is_anonymous():
            loginurl = "%s/%s" %(ploneapi.portal.get().absolute_url(), 'login')
        return loginurl


    def logoutform(self):
        logouturl =  ''
        if not ploneapi.user.is_anonymous():
            logouturl = "%s/%s" %(ploneapi.portal.get().absolute_url(), 'logout')
        return logouturl


    def member_name_or_id(self, ):
        """
        """
        if ploneapi.user.is_anonymous():
            return ''

        member = ploneapi.user.get_current()
        fullname = member.getProperty('fullname', '')

        if fullname:
            return fullname
        else:
            return member.getId()
Beispiel #6
0
class TestEMailViewlet(api.Viewlet):
    api.context(IATNewsItem)
    api.viewletmanager(IBelowContentBody)

    def available(self):
        if not getattr(self.context, 'pin', ''):
            return False
        try:
            current = ploneapi.user.get_current()
            return ploneapi.user.has_permission('Modify portal content', username=current.id, obj=self.context)
        except:
            return False

    def update(self):
        self.testmailurl = self.context.absolute_url() + '/mailtester'
Beispiel #7
0
class ReadSpeakerViewlet(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IAboveContentTitle)

    def available(self):
        #if hasattr(self.context, 'layout'):
        #    if self.context.layout == 'folder_full_view':
        #        return False
        return True
        allowedTypes = ['Document', 'News Item', 'Event', 'Folder',]
        if self.context.portal_type in allowedTypes:
            return True
        return False

    def update(self):
        pageurl = self.context.absolute_url()
        self.buttonid = 'readspeaker_button_%s' % datetime.now().strftime('%f')
        self.readurl = '//app-eu.readspeaker.com/cgi-bin/rsent?customerid=%s&amp;lang=de_de&amp;readid=%s&amp;url=%s' % (cid, readid, pageurl) 
Beispiel #8
0
class PageHeader(api.Viewlet):
    grok.layer(IAnonymousLayer)
    api.context(interface.Interface)
    api.viewletmanager(IPageTop)

    def update(self):
        api.Viewlet.update(self)
        self.catalog = getToolByName(self.context, 'portal_catalog')
        fc = self.context.aq_parent.getFolderContents()
        seq = []
        for i in fc:
            entry = {}
            obj = i.getObject()
            if obj.portal_type == "Document":
                if not obj.excludenextprev and not obj.id == "index.html":
                    entry['linktitle'] = "%s : %s" % (obj.category, obj.title)
                    entry['url'] = obj.absolute_url()
                    seq.append(entry)
        self.doclist = [seq[i:i + 8] for i in range(0, len(seq), 8)]
        self.ausgabe = self.context.aq_parent.Description()
Beispiel #9
0
class CardViewlet(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IAboveContentTitle)

    #def available(self):
    #    korb = len(getCartCookie(self.request).keys())
    #    if korb == 0:
    #        return False
    #    return False

    def _available(self):
        if 'medienportal' in self.context.absolute_url():
            return True
        return False

    def update(self):
        shop = ploneapi.portal.get().absolute_url() + '/medienportal'
        self.available = self._available()
        self.shopbutton = True
        if self.request.get('URL').endswith('vuecart'):
            self.shopbutton = False
        if self.context.absolute_url().endswith('vuecart'):
            self.shopbutton = False
        artikel = getCartCookie(self.request)
        print artikel
        menge = 0
        for i in artikel:
            menge += int(artikel[i].get('menge'))
        #self.artikel = len(getCartCookie(self.request).keys())
        self.artikel = menge
        self.shop_url = shop + '/vuecart'
        self.del_link = shop + '/@@delcard?redirect=%s' % shop
        self.login_link = shop + '/@@loginform'
        self.userdel_link = shop + '/@@deleteuserform'
        self.changepw_link = shop + '/@@changepassword'
        self.changeadr_link = shop + '/@@changeanschrift'
        self.logout_link = shop + '/@@userlogout'
        self.email = getSessionData(self.request).get('email', '')
        self.card = getCartCookie(self.request)
Beispiel #10
0
class UserStatus(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IAboveContentTitle)

    def hsReady(self, sessiondata):
        taetigkeit = False
        hautschutz = False
        if sessiondata.get('taetigkeit'):
            taetigkeit = sessiondata.get('taetigkeit')
            if taetigkeit.get('title') and taetigkeit.get('gefaehrdung'):
                taetigkeit = True
        if sessiondata.get('hautschutz') or sessiondata.get(
                'schutzhandschuhe'):
            hautschutz = True
        if taetigkeit == True and hautschutz == True:
            return True
        return False

    def getTaetigkeit(self, sessiondata):
        btnclass = "btn btn-warning"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/taetigkeitform'
        if sessiondata.get('taetigkeit'):
            taetigkeit = sessiondata.get('taetigkeit')
            if taetigkeit.get('title') and taetigkeit.get('gefaehrdung'):
                btnclass = "btn btn-success"
        return {'btn': btnclass, 'url': url}

    def getSchutzhandschuhe(self, sessiondata):
        btnclass = "btn btn-warning"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/gefaehrdung'
        if sessiondata.get('hautschutz'):
            btnclass = "btn btn-default"
        if sessiondata.get('schutzhandschuhe'):
            form = '/hand-und-hautschutz/schutzhandschuhe'
            btnclass = "btn btn-success"
            url = self.context.aq_inner.absolute_url() + form
        return {'btn': btnclass, 'url': url}

    def getHautschutz(self, sessiondata):
        btnclass = "btn btn-warning"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/hsfinden'
        if sessiondata.get('schutzhandschuhe'):
            btnclass = "btn btn-default"
        if sessiondata.get('hautschutz'):
            btnclass = "btn btn-success"
            url = ploneapi.portal.get().absolute_url(
            ) + '/hand-und-hautschutz/resulthautschutz'
        return {'btn': btnclass, 'url': url}

    def getHautreinigung(self, sessiondata):
        btnclass = "btn btn-default"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/listhautreinigungsmittel'
        if sessiondata.get('hautreinigung'):
            form = '/hand-und-hautschutz/resulthautreinigung'
            btnclass = "btn btn-success"
            url = self.context.aq_inner.absolute_url() + form
        return {'btn': btnclass, 'url': url}

    def getHautpflege(self, sessiondata):
        btnclass = "btn btn-default"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/listhautpflegemittel'
        if sessiondata.get('hautpflege'):
            form = '/hand-und-hautschutz/resulthautpflege'
            btnclass = "btn btn-success"
            url = self.context.aq_inner.absolute_url() + form
        return {'btn': btnclass, 'url': url}

    def getDesinfektion(self, sessiondata):
        btnclass = "btn btn-default"
        url = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz/listdesinfektionsmittel'
        if sessiondata.get('desinfektion'):
            form = '/hand-und-hautschutz/resultdesinfektion'
            btnclass = "btn btn-success"
            url = self.context.aq_inner.absolute_url() + form
        return {'btn': btnclass, 'url': url}

    def update(self):
        sessiondata = getSessionData(self.request)
        self.available = sessiondata.get('hhplan', False)
        self.taetigkeit = self.getTaetigkeit(sessiondata)
        self.schutzhandschuhe = self.getSchutzhandschuhe(sessiondata)
        self.hautschutz = self.getHautschutz(sessiondata)
        self.desinfektion = self.getDesinfektion(sessiondata)
        self.hautreinigung = self.getHautreinigung(sessiondata)
        self.hautpflege = self.getHautpflege(sessiondata)
        self.ready = self.hsReady(sessiondata)
        self.homeurl = ploneapi.portal.get().absolute_url(
        ) + '/hand-und-hautschutz'
Beispiel #11
0
class HeaderBannerImageViewlet(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IPortalHeader)

    @property
    def portal_catalog(self):
        return getToolByName(self.context, 'portal_catalog')

    def refs(self, obj):
        """ returns a list of references """
        refs = [i.UID() for i in obj.getReferences('rel_titleimages')]
        brains = self.portal_catalog.searchResults(UID=refs)
        myrefs = []
        for i in brains:
            myrefs.append(i.getObject())
        return myrefs

    def available(self):
        if getattr(self.context, 'viewlet', None):
            if getattr(self.context, 'viewlet') == 'header':
                return True
        return False

    def update(self):
        self.imagelist = []
        self.videopath = None
        self.imagepath = None
        if self.context.portal_type in [
                'Folder', 'Document', 'Topic', 'Collection'
        ]:
            if getattr(self.context, 'anzeige', False):
                titelbilder = self.refs(self.context)
                if titelbilder:
                    to = len(titelbilder)
                    if getattr(self.context, 'zufall', False):
                        imageindex = random.randint(0, to - 1)
                        randimage = titelbilder[imageindex]
                        refurl = ''
                        #Verlinkung des Titelbildes mit einem Inhalt
                        if randimage.getReferences():
                            refurl = randimage.getReferences()[0].absolute_url(
                            )
                        #Lesen des Titelbildes
                        if randimage.getField('image'):
                            image = {
                                'img':
                                randimage.getField('image').tag(randimage,
                                                                width="100%",
                                                                height="100%"),
                                'img-caption':
                                randimage.title,
                                'img-url':
                                refurl
                            }
                            self.imagelist.append(image)
                    else:
                        for i in range(to):
                            refurl = ''
                            #Verlinkung des Titelbildes mit einem Inhalt
                            if titelbilder[i].getReferences():
                                refurl = titelbilder[i].getReferences(
                                )[0].absolute_url()
                            if i == 0:
                                if titelbilder[i].getField('image'):
                                    image = {
                                        'data-slide':
                                        i,
                                        'class':
                                        'active',
                                        'item-class':
                                        'item active',
                                        'img':
                                        titelbilder[i].getField('image').tag(
                                            titelbilder[i],
                                            width="",
                                            height=""),
                                        'img-caption':
                                        titelbilder[i].title,
                                        'img-url':
                                        refurl
                                    }
                                    self.imagelist.append(image)
                            else:
                                if titelbilder[i].getField('image'):
                                    image = {
                                        'data-slide':
                                        i,
                                        'class':
                                        '',
                                        'item-class':
                                        'item',
                                        'img':
                                        titelbilder[i].getField('image').tag(
                                            titelbilder[i],
                                            width="",
                                            height=""),
                                        'img-caption':
                                        titelbilder[i].title,
                                        'img-url':
                                        refurl
                                    }
                                    self.imagelist.append(image)
                    if self.context.getReferences('rel_videopath'):
                        self.videopath = self.context.getReferences(
                            'rel_videopath')[0].absolute_url()
                    if self.context.getReferences('rel_imagepath'):
                        self.imagepath = self.context.getReferences(
                            'rel_imagepath')[0].absolute_url()
        return
Beispiel #12
0
class ReadSpeakerScript(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IPortalHeader)
Beispiel #13
0
class SearchViewlet(api.Viewlet):
    api.context(Interface)
    api.viewletmanager(IBelowContentTitle)

    def update(self):
        self.shop = ploneapi.portal.get().absolute_url() + '/medienportal'