def testExecuteCountMinMax(self):
     e = ChildCondition()
     e.check_types = set(['Document', 'Image'])
     e.wf_states = None
     e.recursive = False
     e.min_count = 2
     e.max_count = 3
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
     
     self.folder.invokeFactory('Document', 'd1')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
     
     self.folder.invokeFactory('Document', 'd2')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(True, ex())
     
     self.folder.invokeFactory('Document', 'd3')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(True, ex())
     
     self.folder.invokeFactory('Document', 'd4')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
    def test_delete_tile_persistent_data(self):
        permissions = getMultiAdapter(
            (self.tile.context, self.request, self.tile), ITilesPermissions)
        permissions.set_allowed_edit('masters_of_the_universe')
        annotations = IAnnotations(self.tile.context)
        self.assertIn('plone.tiles.permission.test-basic-tile', annotations)

        configuration = getMultiAdapter(
            (self.tile.context, self.request, self.tile),
            ITilesConfigurationScreen)
        configuration.set_configuration({
            'title': {'order': u'0', 'visibility': u'on'},
            'description': {'order': u'1', 'visibility': u'off'},
        })
        self.assertIn('plone.tiles.configuration.test-basic-tile',
                      annotations)

        # Call the delete method
        self.tile.delete()

        # Now we should not see the stored data anymore
        self.assertNotIn('plone.tiles.permission.test-basic-tile',
                         annotations)
        self.assertNotIn('plone.tiles.configuration.test-basic-tile',
                         annotations)
    def init(self):

        self.resizer = getMultiAdapter((self.context, self.request), IMobileImageProcessor)
        self.resizer.init()

        sniffer = getMultiAdapter((self.context, self.request), IUserAgentSniffer)
        self.ua = sniffer.getUserAgentRecord()
Example #4
0
 def _add_rule_action(self, rule, action_id, data):
     action = component.getUtility(IRuleAction, name=action_id)
     adding = component.getMultiAdapter((rule, self.request),
                                        name='+action')
     addview = component.getMultiAdapter((adding, self.request),
                               name=action.addview)
     addview.createAndAdd(data=data)
Example #5
0
 def __init__(self, context, request, view, manager):
     ViewletBase.__init__(self, context, request, view, manager)
     
     self.membership = getToolByName(self.context, 'portal_membership')        
     self.context_state = getMultiAdapter((context, request), name=u'plone_context_state')
     self.portal_state = getMultiAdapter((context, request), name=u'plone_portal_state')
     self.pas_info = getMultiAdapter((context, request), name=u'pas_info')
Example #6
0
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.errors = {}

        self.portal_state = getMultiAdapter((self.context, self.request), name=u'plone_portal_state')
        self.tools = getMultiAdapter((self.context, self.request), name=u'plone_tools')
        self.props = getToolByName(self.context, 'portal_properties')
        self.utils = getToolByName(self.context, 'plone_utils')
        self.site_properties = self.props['site_properties']

        self.url_solicitacao_pesquisa = self.context.absolute_url()
        self.url_sucess = self.context.absolute_url()

        self.url_servico_ra = self.site_properties.URL_SERVICO_RA

        self.lista = []
        self.SiglaOsID = 'SUST'

        if 'ordemServico' in request.form:
            ordemServico = request.form['ordemServico']
            request.set('ordemServico', ordemServico)
            self.ordemServico = ordemServico
        else:
            self.ordemServico = None

        if 'anoOS' in request.form:
            anoOS = request.form['anoOS']
            request.set('anoOS', anoOS)
            self.anoOS = anoOS
        else:
            self.anoOS = None
Example #7
0
    def getResults(self):
        context = Acquisition.aq_inner(self.context)

        # try to get query parameters from Topic (if present)
        query = hasattr(context, 'buildQuery') and context.buildQuery()
        if query:
            catalog = getToolByName(context, 'portal_catalog')
            results = catalog(query)
            # filter out results that are both outdated and expired
            to_show = [
                x for x in results if not (
                    getattr(x, 'outdated', False) and isExpired(x))
            ]
            return to_show

        # otherwise construct a query
        portal_state = getMultiAdapter(
            (self.context, self.request), name=u'plone_portal_state')
        navigation_root_path = portal_state.navigation_root_path()

        oshaview = getMultiAdapter(
            (self.context, self.request), name=u'oshaview')
        mySEP = oshaview.getCurrentSingleEntryPoint()
        kw = ''

        if mySEP:
            kw = mySEP.getProperty('keyword', '')

        query = '(portal_type:("News Item") OR isNews:true) AND '
        'review_state:published AND path_parents:%s' % navigation_root_path
        if kw != '':
            query = ' AND '.join([query, 'Subject:(%s)' % ' OR '.join(kw)])
        return search_solr(query, sort='Date desc')
Example #8
0
    def getRepliesStructure(self):
        replyStructures = []

        isTask = self.getType() == 'Task'
        isDeadlinePassed = False
        outOfTime = False
        taskDeadline = getattr(self.context, 'deadline', None)
        if taskDeadline is not None:
            isDeadlinePassed = taskDeadline < datetime.datetime.now()

        for reply_brain in self.replies:
            reply = reply_brain.getObject()

            if not outOfTime and isTask and isDeadlinePassed:
                currentCreationDate = DT2dt(reply.created()).replace(tzinfo=None)
                if currentCreationDate > taskDeadline:
                    outOfTime = True
                    expiredView = getMultiAdapter(
                        (self.context, self.request), name=u"expired")
                    replyStructures.append(expiredView)

            view = getMultiAdapter((reply, self.request), name=u"thread")
            replyStructures.append(view)

        if replyStructures:
            replyStructures[-1].isLast = True

        if not outOfTime and isTask and isDeadlinePassed:
            expiredView = getMultiAdapter((self.context, self.request), name=u"expired")
            replyStructures.append(expiredView)

        return replyStructures
    def test_delete_tile_persistent_data(self):
        permissions = getMultiAdapter(
            (self.tile.context, self.request, self.tile), ITilesPermissions)
        permissions.set_allowed_edit('masters_of_the_universe')
        annotations = IAnnotations(self.tile.context)
        self.assertIn('plone.tiles.permission.test-pfg-tile', annotations)

        uuid = IUUID(self.pfg, None)
        configuration = getMultiAdapter(
            (self.tile.context, self.request, self.tile),
            ITilesConfigurationScreen)
        configuration.set_configuration({
            'uuid': uuid,
            'title': self.pfg.Title(),
            'description': self.pfg.Description(),
        })
        self.assertIn('plone.tiles.configuration.test-pfg-tile',
                      annotations)

        # Call the delete method
        self.tile.delete()

        # Now we should not see the stored data anymore
        self.assertNotIn('plone.tiles.permission.test-pfg-tile',
                         annotations)
        self.assertNotIn('plone.tiles.configuration.test-pfg-tile',
                         annotations)
    def update(self):
        context= aq_inner(self.context)

        context_helper = getMultiAdapter((context, self.request), name="plone_context_state")

        portal_helper = getMultiAdapter((context, self.request), name="plone_portal_state")

        canonical = context_helper.canonical_object()

        parent = aq_parent(canonical)

        breadcrumbs_view = getView(self.context, self.request, 'breadcrumbs_view')
        breadcrumbs = breadcrumbs_view.breadcrumbs()

        if (len(breadcrumbs)==1):
            self.backTitle = _(u"Home")
        else:
            if hasattr(parent, "Title"):
                self.backTitle = parent.Title()
            else:
                self.backTitle = _(u"Back")

        if hasattr(parent, "absolute_url"):
            self.backUrl = parent.absolute_url()
        else:
            self.backUrl = portal_helper.portal_url()

        self.isHome = len(breadcrumbs)==0

        self.homeUrl = portal_helper.portal_url()
    def test_spaces_are_not_escaped(self):
        # Escaping spaces in URLs with %20 in LaTeX is bad because % is a comment.
        chapter = create(Builder('chapter')
                         .within(self.book)
                         .titled('the chapter'))

        document = create(Builder('file')
                          .within(chapter)
                          .titled('The File')
                          .with_id('the file'))

        html = '<a class="internal-link" href="resolveuid/{0}">Link</a>'.format(
            IUUID(document))
        block = create(Builder('book textblock')
                       .within(chapter)
                       .having(text=html))

        request = block.REQUEST
        assembler = getMultiAdapter((self.book, request), IPDFAssembler)
        latex_view = getMultiAdapter((block, request, assembler.get_layout()),
                                     ILaTeXView)

        self.assertEqual(
            r'\hyperref[path:/plone/the-book/the-chapter/the file]{Link'
            r'\footnote{See page'
            r' \pageref{path:/plone/the-book/the-chapter/the file}}}',
            latex_view.render().strip())
 def __init__(self, context, request, view, manager, data):
     BaseRenderer.__init__(self, context, request, view, manager, data)
     portal_state = getMultiAdapter((context, request), name=u'plone_portal_state')
     portal_tools = getMultiAdapter((context, request), name=u'plone_tools')
     self.navigation_root_url = portal_state.navigation_root_url()
     self.portal_types = portal_tools.types()
     self.friendly_types = portal_state.friendly_types()
 def renderViewlet(self, manager, name):
     if isinstance(manager, basestring):
         manager = getMultiAdapter((self.context, self.request, self), IViewletManager, name=manager)
     renderer = getMultiAdapter((self.context, self.request, self, manager), IViewlet, name=name)
     renderer = renderer.__of__(self.context)
     renderer.update()
     return renderer.render()
 def testExecuteComplex(self):
     e = ChildCondition()
     e.check_types = set(['Folder', 'Document'])
     e.wf_states = set(['published'])
     e.recursive = True
     e.min_count = 2
     e.max_count = 3
     
     self.folder.invokeFactory('Folder', 'f1')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
     
     self.folder.f1.invokeFactory('Document', 'd1')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
     
     self.portal.portal_workflow.doActionFor(self.folder.f1, 'publish')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(False, ex())
     
     self.portal.portal_workflow.doActionFor(self.folder.f1.d1, 'publish')
     
     ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
     self.assertEquals(True, ex())
    def update(self):
        if not self.portal_state:
            self.portal_state = component.getMultiAdapter((self.context,
                                                           self.request),
                                           name="plone_portal_state")
        if not self.portal_url:
            self.portal_url = self.portal_state.portal_url()

        if self.portal_path is None:
            portal = self.portal_state.portal()
            self.portal_path = '/'.join(portal.getPhysicalPath())

        if self.portlet_url is None:
            #http://stackoverflow.com/questions/11211134/how-do-i-get-the-kind-of-portlet-group-context-type-from-its-renderer-in-pl/11211893#11211893
            retriever = component.getMultiAdapter((self.context, self.manager),
                                                  IPortletRetriever)
            category = None
            for info in retriever.getPortlets():
                if info['assignment'] is self.data.aq_base:
                    category = info['category']
                    key = info['key']
                    break
            if category is not None:
                path = key[len(self.portal_path)+1:]
                info = {'category': category,
                        'id': '%s' % self.data.id,
                        'manager': self.manager.__name__,
                        'context_path': path}
                self.portlet_url = '%s/%s' % (self.portal_url, 
                                              PORTLET_PATH % info)
    def test_exported_XML_valid_for_GS(self):
        """Test that exported XMLs can be parsed by GenericSetup's parser."""
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        # create a Dexterity item that we can export
        self.item = add_item_type(self.portal)

        # request is expected to have the 'selected' parameter set
        self.request['selected'] = 'item'

        # get the export view
        dexterity_control_panel = getMultiAdapter(
            (self.portal, self.request), name='dexterity-types')
        types_export_view = getMultiAdapter(
            (dexterity_control_panel, self.request), name='types-export')

        # export the 'item' type and try to parse all XMLs
        fd = StringIO.StringIO(types_export_view.__call__())
        archive = zipfile.ZipFile(fd, mode='r')
        filenames = archive.namelist()
        for filename in filenames:
            file_xml = archive.read(filename)

            # if this passes then GenericSetup will be able to use this XML
            try:
                parseString(file_xml)
            except ExpatError as e:
                self.fail("Parsing XML failed with ExpatError: " + e.message)
    def test_delete_confirmation_if_locked(self):
        folder = self.portal['f1']
        lockable = ILockable.providedBy(folder)

        form = getMultiAdapter(
            (folder, self.request), name='delete_confirmation')
        form.update()

        self.assertFalse(form.is_locked)

        if lockable:
            lockable.lock()

        form = getMultiAdapter(
            (folder, self.request), name='delete_confirmation')
        form.update()

        self.assertFalse(form.is_locked)

        # After switching the user it should not be possible to delete the
        # object. Of course this is only possible if our context provides
        # ILockable interface.
        if lockable:
            logout()
            login(self.portal, 'editor')

            form = getMultiAdapter(
                (folder, self.request), name='delete_confirmation')
            form.update()
            self.assertTrue(form.is_locked)

            logout()
            login(self.portal, TEST_USER_NAME)

            ILockable(folder).unlock()
Example #18
0
    def test_crud(self):
        # we start with an empty tile
        self.assertTrue(self.tile.is_empty())

        # now we add a couple of objects to the list
        obj1 = self.portal['my-document']
        obj2 = self.portal['my-image']
        self.tile.populate_with_object(obj1)
        self.tile.populate_with_object(obj2)

        # tile's data attributed is cached so we should re-instantiate the tile
        tile = getMultiAdapter((self.cover, self.request), name=self.name)
        tile = tile['test']
        self.assertEqual(len(tile.results()), 2)
        self.assertTrue(obj1 in tile.results())
        self.assertTrue(obj2 in tile.results())

        # next, we replace the list of objects with a different one
        obj3 = self.portal['my-news-item']
        tile.replace_with_objects([IUUID(obj3, None)])
        # tile's data attributed is cached so we should re-instantiate the tile
        tile = getMultiAdapter((self.cover, self.request), name=self.name)
        tile = tile['test']
        self.assertTrue(obj1 not in tile.results())
        self.assertTrue(obj2 not in tile.results())
        self.assertTrue(obj3 in tile.results())

        # finally, we remove it from the list; the tile must be empty again
        tile.remove_item(obj3.UID())
        # tile's data attributed is cached so we should re-instantiate the tile
        tile = getMultiAdapter((self.cover, self.request), name=self.name)
        tile = tile['test']
        self.assertTrue(tile.is_empty())
    def get_values_to_index(self):
        request = getRequest()
        items = super(FactsheetCataloguer, self).get_values_to_index()
        view = getMultiAdapter((self.context, request), name='view')
        contents = u''
        for item in view.facts():
            for fact in item.get('facts'):
                contents += getMultiAdapter(
                    (fact.getObject(), request),
                    name='factrenderview')()

        items['article[content]'] = contents
        targets = []
        for target in (self.context.targets or []):
            targets.append(target)
        items['article[target_list]'] = u','.join(targets)
        actions = []
        for action in (self.context.actions or []):
            actions.append(action)
        items['article[action_list]'] = u','.join(actions)
        tags = []
        for tag in (self.context.cataloguetags or []):
            tagid, tagname = tag.split('-')
            tags.append(tagname)
        items['article[tag_list]'] = u','.join(tags)

        items['article[countries]'] = \
            (self.context.fact_countryCode or '').strip()

        return items
    def getResult(self):
        assert self._updated
        result = []
        qc = getMultiAdapter((self.context, self.request),
                             name='refbrowser_querycatalog')
        if self.widget.show_results_without_query or self.search_text:
            result = (self.widget.show_results_without_query or \
                      self.search_text) and \
                      qc(search_catalog=self.widget.search_catalog)

            self.has_queryresults = bool(result)

        elif self.widget.allow_browse:
            ploneview = getMultiAdapter((self.context, self.request),
                                        name="plone")
            folder = ploneview.getCurrentFolder()
            self.request.form['path'] = {
                              'query': '/'.join(folder.getPhysicalPath()),
                              'depth':1}
            self.request.form['portal_type'] = []
            self.request.form['sort_on'] = 'getObjPositionInParent'
            result = qc(search_catalog=self.widget.search_catalog)
        else:
            result = []
        b_size = int(self.request.get('b_size', 20))
        b_start = int(self.request.get('b_start', 0))

        return Batch(result, b_size, b_start, orphan=1)
Example #21
0
    def test_multi_checkin_from_tabbedview_with_comment(self, browser):
        document2 = create(Builder("document").checked_out().within(self.dossier))

        browser.login().open(
            self.dossier,
            data={
                "paths": [obj2brain(self.document).getPath(), obj2brain(document2).getPath()],
                "checkin_documents:method": 1,
                "_authenticator": createToken(),
            },
        )

        # fill and submit checkin form
        browser.fill({"Journal Comment Describe, why you checkin the selected documents": "Checkini"})
        browser.css("#form-buttons-button_checkin").first.click()

        manager1 = getMultiAdapter((self.document, self.portal.REQUEST), ICheckinCheckoutManager)
        self.assertEquals(None, manager1.get_checked_out_by())
        manager2 = getMultiAdapter((document2, self.portal.REQUEST), ICheckinCheckoutManager)
        self.assertEquals(None, manager2.get_checked_out_by())

        # check last history entry to verify the checkin
        repository_tool = getToolByName(document2, "portal_repository")
        history = repository_tool.getHistory(document2)
        last_entry = repository_tool.retrieve(document2, len(history) - 1)
        self.assertEquals("Checkini", last_entry.comment)
Example #22
0
 def get_form(self):
     """
     fill out common stuff when creating a new experiment
     """
     # setup request layer
     self.request = TestRequest()
     # get add view
     form = getMultiAdapter((self.experiments, self.request),
                            name="newProjection")
     # update the form once to initialise all widgets
     form.update()
     # go through all widgets on the form  and update the request with
     # default values
     data = {}
     for widget in form.widgets.values():
         data[widget.name] = widget.value
     data.update({
         'form.widgets.IDublinCore.title': u"My CC Experiment",
         'form.widgets.IDublinCore.description': u'This is my experiment description',
         'form.widgets.species_distribution_models.count': 1,
         'form.widgets.species_distribution_models.item.0': unicode(self.sdmexp.UID()),
         'form.widgets.species_distribution_models.item.0.item': [unicode(self.sdmmodel.UID())],
         'form.widgets.future_climate_datasets': [unicode(self.future.UID())]
     })
     self.request.form.update(data)
     form = getMultiAdapter((self.experiments, self.request),
                            name="newProjection")
     return form
Example #23
0
 def update(self):
     super(View, self).update()
     context = aq_inner(self.context)
     parent = aq_parent(context)
     if parent.portal_type=='apyb.papers.track':
         track = parent
         program = aq_parent(track)
     else:
         program = parent
     self.context = context
     self._path = '/'.join(context.getPhysicalPath())
     self.state = getMultiAdapter((context, self.request),
                                  name=u'plone_context_state')
     self.tools = getMultiAdapter((context, self.request),
                                  name=u'plone_tools')
     self.portal = getMultiAdapter((context, self.request),
                                  name=u'plone_portal_state')
     self.helper = getMultiAdapter((program, self.request),
                                   name=u'helper')
     self._ct = self.tools.catalog()
     self._mt = self.tools.membership()
     self._wt = self.tools.workflow()
     self.member = self.portal.member()
     voc_factory = queryUtility(IVocabularyFactory,
                                'apyb.papers.talk.rooms')
     self.rooms = voc_factory(self.context)
     self.roles_context = self.member.getRolesInContext(context)
     if not self.show_border:
         self.request['disable_border'] = True
Example #24
0
 def get_form(self):
     """
     fill out common stuff when creating a new experiment
     """
     # setup request layer
     self.request = TestRequest()
     # get add view
     form = getMultiAdapter((self.experiments, self.request),
                            name="newBiodiverse")
     # update the form once to initialise all widgets
     form.update()
     # go through all widgets on the form  and update the request with
     # default values
     data = {}
     for widget in form.widgets.values():
         data[widget.name] = widget.value
     data.update({
         'form.widgets.IDublinCore.title': u"My BD Experiment",
         'form.widgets.IDublinCore.description': u'This is my experiment description',
         'form.widgets.projection.count': '1',
         'form.widgets.projection.item.0': unicode(self.sdmexp.UID()),
         'form.widgets.projection.item.0.count': 1,
         'form.widgets.projection.item.0.item.0.uuid': unicode(self.sdmproj.UID()),
         'form.widgets.projection.item.0.item.0.threshold': u'0.5',
         'form.widgets.cluster_size': '5000',
     })
     self.request.form.update(data)
     form = getMultiAdapter((self.experiments, self.request),
                            name="newBiodiverse")
     return form
    def testEquivalence(self):
        mapping = getMultiAdapter((self.folder, self.manager), IPortletAssignmentMapping)
        c = classic.Assignment()
        mapping['foo'] = c

        mapping2 = getMultiAdapter((self.folder, self.manager), IPortletAssignmentMapping)
        self.assertEqual(mapping2['foo'], c)
Example #26
0
 def get_form(self):
     """
     fill out common stuff when creating a new experiment
     """
     # setup request layer
     self.request = TestRequest()
     # get add view
     form = getMultiAdapter((self.experiments, self.request),
                            name="newEnsemble")
     # update the form once to initialise all widgets
     form.update()
     # go through all widgets on the form  and update the request with
     # default values
     data = {}
     for widget in form.widgets.values():
         data[widget.name] = widget.value
     data.update({
         'form.widgets.IDublinCore.title': u"My EN Experiment",
         'form.widgets.IDublinCore.description': u'This is my experiment description',
         'form.widgets.experiment_type': ISDMExperiment.__identifier__,
         'form.widgets.datasets.count': '1',
         'form.widgets.datasets.item.0': unicode(self.sdmexp.UID()),
         'form.widgets.datasets.item.0.item': [unicode(self.sdmproj.UID())],
     })
     self.request.form.update(data)
     form = getMultiAdapter((self.experiments, self.request),
                            name="newEnsemble")
     return form
Example #27
0
    def getColumnsClass(self, view=None):
        """Determine whether a column should be shown. The left column is called
        plone.leftcolumn; the right column is called plone.rightcolumn.
        """
        context = aq_inner(self.context)
        plone_view = getMultiAdapter((context, self.request), name=u'plone')
        sl = plone_view.have_portlets('plone.leftcolumn', view=view);
        sr = plone_view.have_portlets('plone.rightcolumn', view=view);
        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')

        if not sl and not sr:
            # we don't have columns, thus conten takes the whole width
            return "cell width-full position-0"
        elif sl and sr:
            # In case we have both columns, content takes 50% of the whole
            # width and the rest 50% is spread between the columns
            return "cell width-1:2 position-1:4"
        elif (sr and not sl) and (portal_state.is_rtl()):
            # We have right column and we are in RTL language
            return "cell width-3:4 position-1:4"
        elif (sr and not sl) and (not portal_state.is_rtl()):
            # We have right column and we are NOT in RTL language
            return "cell width-3:4 position-0"
        elif (sl and not sr) and (portal_state.is_rtl()):
            # We have left column and we are in RTL language
            return "cell width-3:4 position-0"
        elif (sl and not sr) and (not portal_state.is_rtl()):
            # We have left column and we are in NOT RTL language
            return "cell width-3:4 position-1:4"
Example #28
0
    def __call__(self):
        portal_state = getMultiAdapter(
            (self.context, self.request),
            name=u'plone_portal_state'
        )
        context_state = getMultiAdapter(
            (self.context, self.request),
            name='plone_context_state'
        )
        # do not use getSite because it's possible it could be different
        # than the actual portal url
        portal_url = portal_state.portal_url()
        result = {
            'data-base-url': self.context.absolute_url(),
            'data-view-url': context_state.view_url(),
            'data-portal-url': portal_url,
            'data-i18ncatalogurl': portal_url + '/plonejsi18n'
        }

        # first, check for any adapters that need pattern data defined
        adapters = getAdapters(
            (self.context, self.request, None),
            IPatternsSettings
        )
        [result.update(x[1]()) for x in adapters]

        # Resources Registered UI patterns can override adapters
        registry = getUtility(IRegistry)
        pattern_options = registry.get('plone.patternoptions', {})
        for key, value in pattern_options.items():
            result['data-pat-' + key] = value

        return result
Example #29
0
    def test_multi_checkin_does_not_checkin_locked_documents(self, browser):
        self.login(self.regular_user, browser)

        browser.open(self.document, view='tabbedview_view-overview')
        browser.find('Checkout and edit').click()

        browser.open(self.subdocument, view='tabbedview_view-overview')
        browser.find('Checkout and edit').click()

        lockable = IRefreshableLockable(self.document)
        lockable.lock()

        browser.open(
            self.dossier,
            method='POST',
            data={
                'paths': [
                    obj2brain(self.document).getPath(),
                    obj2brain(self.subdocument).getPath(),
                    ],
                'checkin_without_comment:method': 1,
                '_authenticator': createToken(),
                },
            )

        manager = getMultiAdapter((self.document, self.portal.REQUEST), ICheckinCheckoutManager)
        self.assertEquals('kathi.barfuss', manager.get_checked_out_by())

        manager = getMultiAdapter((self.subdocument, self.portal.REQUEST), ICheckinCheckoutManager)
        self.assertEquals(None, manager.get_checked_out_by())

        self.assertEquals([u'Could not check in document Vertr\xe4gsentwurf'],
                          error_messages())
Example #30
0
def fakePutOrDelete(context, request):
    """Check whether to do fake PUT or DELETE.

    If fake needs to be performed, return message of fake request.
    If no faking is requested, return None.
    """
    qs = request.environment['QUERY_STRING']
    # this is an optimization so we don't have to do parse_qs all the time
    if not '_method=' in qs:
        return None
    d = cgi.parse_qs(qs)
    method = d.get('_method', None)
    # there actually was no _method parameter after all
    if method is None:
        return None
    method = method[0]
    method = method.lower()
    if method == 'put':
        view = component.getMultiAdapter((context, request),
                                         name='PUT')
        return view()
    elif method == 'delete':
        view = component.getMultiAdapter((context, request),
                                         name='DELETE')
        return view()
    # unknown fake HTTP method, ignore
    return None