コード例 #1
0
    def setUp(self):
        portal = self.layer['portal']

        req = self.getRequest(
            {
                'workflow-name': 'workflow-1',
                'form.actions.add': 'create',
                'clone-from-workflow': 'simple_publication_workflow'
            }, True)
        alsoProvides(req, IAttributeAnnotatable)
        AddWorkflow(portal, req)()

        # add some rules/actions
        req = self.getRequest(
            {
                'form.actions.add': 'Add',
                'selected-transition': 'publish',
                'selected-state': 'published',
                'selected-workflow': 'workflow-1'
            }, True)
        view = AddActionView(portal, req)
        view()
        self.selected_workflow = view.selected_workflow
        self.selected_transition = view.selected_transition
        self.selected_state = view.selected_state

        am = ActionManager()
        rule = am.get_rule(self.selected_transition)
        action = NotifyAction()
        action.message = 'foobar'
        action.message_type = 'info'
        rule.actions.append(action)
コード例 #2
0
    def downvote(self, path):
        """ """
        user_rating = None
        s = getSite()
        rpath = '/'.join(s.getPhysicalPath()) + path.replace(s.absolute_url(), '')
        reply = self.context.restrictedTraverse(rpath)
        if not IAttributeAnnotatable.providedBy(reply):
            alsoProvides(reply, IAttributeAnnotatable)
        annotations = IAnnotations(reply)
        voters = annotations.get('opkode.rateablediscussion.voters', {})
        rating = annotations.get('opkode.rateablediscussion.rating', 0)
        pm = getToolByName(s, 'portal_membership')
        if pm.isAnonymousUser():
            return 
        pm = getToolByName(s, 'portal_membership')
        member = pm.getAuthenticatedMember()
        member_id = member.getId()
        if member_id not in voters:
            voters[member_id] = 'down'
            user_rating = 'down'
            annotations['opkode.rateablediscussion.voters'] = voters
            rating -= 1
            annotations['opkode.rateablediscussion.rating'] = rating
        elif voters.get(member_id) == 'up':
            # The voter is removing his vote, so let's delete him
            del voters[member_id]
            annotations['opkode.rateablediscussion.voters'] = voters
            rating -= 1
            annotations['opkode.rateablediscussion.rating'] = rating
        elif voters.get(member_id) == 'down':
            # The down arrow has already been clicked before
            user_rating = 'down'

        return json.dumps(
                    {'reply_rating': rating, 'user_rating':user_rating})
コード例 #3
0
 def get_member_vote(self, object):
     """ """
     if not IAttributeAnnotatable.providedBy(object):
         alsoProvides(object, IAttributeAnnotatable)
     annotations = IAnnotations(object)
     voters = annotations.get('opkode.rateablediscussion.voters', {})
     return voters.get(self.member.getId(), None)
コード例 #4
0
    def setUp(self):
        portal = self.layer['portal']

        req = self.getRequest({'workflow-name': 'workflow-1',
            'form.actions.add': 'create',
            'clone-from-workflow': 'simple_publication_workflow'}, True)
        alsoProvides(req, IAttributeAnnotatable)
        AddWorkflow(portal, req)()

        # add some rules/actions
        req = self.getRequest({
            'form.actions.add': 'Add',
            'selected-transition': 'publish',
            'selected-state': 'published',
            'selected-workflow': 'workflow-1'}, True)
        view = AddActionView(portal, req)
        view()
        self.selected_workflow = view.selected_workflow
        self.selected_transition = view.selected_transition
        self.selected_state = view.selected_state

        am = ActionManager()
        rule = am.get_rule(self.selected_transition)
        action = NotifyAction()
        action.message = 'foobar'
        action.message_type = 'info'
        rule.actions.append(action)
コード例 #5
0
    def test_document_fusion(self):
        # data source and model are in the same content
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        content = api.content.create(self.portal, type='letter',
                           title=u"En réponse...",
                           file=NamedFile(data=open(TEST_LETTER_ODT).read(),
                                          filename=u'letter.odt',
                                          contentType='application/vnd.oasis.opendocument.text'),
                           sender_name="Thomas Desvenain",
                           sender_address="57 Quai du Pré Long",
                           recipient_name="Vincent Fretin",
                           date=datetime.date(2012, 12, 23))

        notify(ObjectModifiedEvent(content))
        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='letter.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='letter.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read()
        self.assertIn('Vincent Fretin', txt)
        self.assertIn('57 Quai du Pré Long', txt)
        self.assertIn('2012', txt)
        self.assertIn(u'EN RÉPONSE...', txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #6
0
def mark_video_as_google_drive_link(context):
    """
    Mark a link as a google drive resource
    """
    alsoProvides(mark_video_link(context),
                     IVideoLinkGoogleDrive
                     )
    return context 
コード例 #7
0
    def test_uuid(self):
        alsoProvides(self.doc, IAttributeUUID)
        notify(ObjectCreatedEvent(self.doc))

        uuid = IUUID(self.doc, None)
        wrapped = IndexableObjectWrapper(self.doc, self.portal.portal_catalog)
        self.assertTrue(wrapped.UID)
        self.assertTrue(uuid == wrapped.UID)
コード例 #8
0
    def test_uuid(self):
        alsoProvides(self.doc, IAttributeUUID)
        notify(ObjectCreatedEvent(self.doc))

        uuid = IUUID(self.doc, None)
        wrapped = IndexableObjectWrapper(self.doc, self.portal.portal_catalog)
        self.assertTrue(wrapped.UID)
        self.assertTrue(uuid == wrapped.UID)
コード例 #9
0
    def test_document_fusion_with_merge_multiple(self):
        # data source is in a related content
        # we merge two files from two sources
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        source_1 = api.content.create(self.portal, type='contact_infos',
                                      id='desvenain_thomas',
                                      identity='M. Desvenain Thomas',
                                      address_1='24 rue des Trois Mollettes',
                                      address_2='C24',
                                      zipcode='59000',
                                      city='Lille')

        source_2 = api.content.create(self.portal, type='contact_infos',
                                      id='fretin_vincent',
                                      identity='M. Fretin Vincent',
                                      address_1='51 r Lac',
                                      address_2='',
                                      zipcode='59810',
                                      city='LESQUIN')

        content = api.content.create(self.portal, type='label_model',
                           title=u"Modèle d'étiquette",
                           file=NamedFile(data=open(TEST_LABEL_ODT).read(),
                                          filename=u'label.odt',
                                          contentType='application/vnd.oasis.opendocument.text'),
                           relatedItems=[RelationValue(intids.getId(source_1)),
                                         RelationValue(intids.getId(source_2))],
                           )

        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='label.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='label.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read().replace(r'\xc2\xa0', ' ')

        # label 1
        self.assertIn('M. DESVENAIN THOMAS', txt)
        self.assertIn('24 RUE DES TROIS MOLLETTES', txt)
        self.assertIn('C24', txt)
        self.assertIn(u'59000', txt)

        # label 2
        self.assertIn('M. FRETIN VINCENT', txt)
        self.assertIn(u'59810', txt)
        self.assertIn(u'LESQUIN', txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #10
0
    def test_document_fusion_with_merge_multiple(self):
        # data source is in a related content
        # we merge two files from two sources
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        source_1 = api.content.create(self.portal, type='contact_infos',
                                      id='desvenain_thomas',
                                      identity='M. Desvenain Thomas',
                                      address_1='24 rue des Trois Mollettes',
                                      address_2='C24',
                                      zipcode='59000',
                                      city='Lille')

        source_2 = api.content.create(self.portal, type='contact_infos',
                                      id='fretin_vincent',
                                      identity='M. Fretin Vincent',
                                      address_1='51 r Lac',
                                      address_2='',
                                      zipcode='59810',
                                      city='LESQUIN')

        content = api.content.create(self.portal, type='label_model',
                           title=u"Modèle d'étiquette",
                           file=NamedFile(data=open(TEST_LABEL_ODT).read(),
                                          filename=u'label.odt',
                                          contentType='application/vnd.oasis.opendocument.text'),
                           relatedItems=[RelationValue(intids.getId(source_1)),
                                         RelationValue(intids.getId(source_2))],
                           )

        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='label.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='label.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read()

        # label 1
        self.assertIn('M. DESVENAIN THOMAS', txt)
        self.assertIn('24 RUE DES TROIS MOLLETTES', txt)
        self.assertIn('C24', txt)
        self.assertIn(u'59000', txt)

        # label 2
        self.assertIn('M. FRETIN VINCENT', txt)
        self.assertIn(u'59810', txt)
        self.assertIn(u'LESQUIN', txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #11
0
 def setUp(self):
     super(IntegrationTestCase, self).setUp()
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     self.portal.invokeFactory('Folder', 'test-folder')
     setRoles(self.portal, TEST_USER_ID, ['Member'])
     self.folder = self.portal['test-folder']
     alsoProvides(self.request, IPloneFormLayer)
コード例 #12
0
def mark_video_link(context):
    """
    Mark a link as an oembedable resource
    (usually a video, may need to refactor because
    this works for resources like soundcloud and flickr also)
    """
    alsoProvides(context, IVideoLinkThumb, IVideoLinkOembedable)
    #reindex(context)
    return context
コード例 #13
0
 def setUp(self):
     super(IntegrationTestCase, self).setUp()
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     self.portal.invokeFactory('Folder', 'test-folder')
     setRoles(self.portal, TEST_USER_ID, ['Member'])
     self.folder = self.portal['test-folder']
     alsoProvides(self.request, IPloneFormLayer)
コード例 #14
0
    def getRequest(self, form={}, authentic=False):
        if authentic:
            form['_authenticator'] = self.genAuthString()

        req = TestRequest(form=form, environ={
            'SERVER_URL': 'http://nohost',
            'HTTP_HOST': 'nohost'
        })
        alsoProvides(req, IAttributeAnnotatable)
        return req
コード例 #15
0
def initial_rating(obj, event):
    """ Give the comment creator an inital vote of +1 for the comment.
    """
    s = getSite()
    if not IAttributeAnnotatable.providedBy(obj):
        alsoProvides(obj, IAttributeAnnotatable)
    annotations = IAnnotations(obj)
    pm = getToolByName(s, 'portal_membership')
    member = pm.getAuthenticatedMember()
    annotations['opkode.rateablediscussion.voters'] = {member.getId(): 'up'}
    annotations['opkode.rateablediscussion.rating'] = 1
コード例 #16
0
def mark_video_link(context):
    """
    Mark a link as an oembedable resource
    (usually a video, may need to refactor because
    this works for resources like soundcloud and flickr also)
    """
    alsoProvides(context,
                     IVideoLinkThumb,
                     IVideoLinkOembedable
                     )
    #reindex(context)
    return context
コード例 #17
0
def worker():
    print '################################################################'
    print 'Start...'
    print '################################################################'
    uvcsite = root['app']
    component.hooks.setSite(uvcsite)
    hfm = component.getUtility(IHomeFolderManager).homeFolderBase
    for homefolder in hfm.values():
        #for item in homefolder:
        #    print item
        if 'Sunfallanzeigen' in homefolder:
            for item in homefolder['Sunfallanzeigen'].values():
                #pid = str(item.principal.id)
                #print pid
                #print IWorkflowState(item).getState()
                if IWorkflowState(item).getState() == 2:
                    print '################################################################'
                    print 'Fehlerhafte Unfallanzeige gefunden:'
                    print "%s/%s" % (homefolder.__name__, item.title)
                    print '################################################################'
                    print 'Bitte Dokument anschauen und Fehler beheben !'
                    print 'Dann Code der Nachverarbeitung aendern:'
                    print '1. Dokument neu erstellen und versenden, NICHT fixen !!!'
                    print '2. Dokument fixen, OHNE Erstellung !!!'
                    print '################################################################'
                    ##### Status: 0 = Nur schauen, was laeuft falsch
                    #####         1 = Dokument neu erstellen
                    #####         2 = Dokument fixen (Status gesendet)
                    ##### Nachfolgenden Status setzen:
                    status = 0  # <----- Dort: 0, 1 oder 2
                    if status == 0:
                        print "-----> Es wurde noch keine Aktion ausgeführt"
                        print "Status: ", status
                    elif status == 1:
                        modprincipal = item.principal
                        alsoProvides(modprincipal, MoE)
                        event_obj = geteventobject(modprincipal)
                        try:
                            grok.notify(AfterSaveEvent(item, event_obj))
                        except InvalidTransitionError:
                            print "-----> Dokumente wurden erstellt, Status umstellen zum fixen !!!"
                            print "Status: ", status
                        except Exception, e:
                            print e
                            pass
                    elif status == 2:
                        IWorkflowInfo(item).fireTransition('fix')
                        print "-----> Dokumente gefixt !!!"
                        print "       Status umstellen auf --> 0 <--"
                        print "Status: ", status
                        print 'FIX of object %s' % item
コード例 #18
0
    def test_json_contacts(self):
        login(self.portal, TEST_USER_NAME)
        alsoProvides(self.portal.REQUEST, ICollectiveContactFacetednavLayer)
        directory = self.portal.mydirectory

        self.portal.REQUEST.form['type'] = 'organization'
        json_contacts = json.loads(directory.unrestrictedTraverse('@@json-contacts')())
        self.assertEqual(len(json_contacts), 7)
        self.assertTrue(json_contacts[0].has_key('id'))
        self.assertEqual(json_contacts[0]['path'], '/plone/mydirectory/armeedeterre')

        self.portal.REQUEST.form['type'] = 'held_position'
        json_contacts = json.loads(directory.unrestrictedTraverse('@@json-contacts')())
        self.assertEqual(len(json_contacts), 4)
        self.assertEqual(json_contacts[0]['path'], '/plone/mydirectory/degaulle/adt')
コード例 #19
0
    def test_subtyper(self):
        login(self.portal, TEST_USER_NAME)
        directory = self.portal.mydirectory
        alsoProvides(self.portal.REQUEST, ICollectiveContactFacetednavLayer)
        subtyper = directory.unrestrictedTraverse('@@contact_faceted_subtyper')
        subtyper.enable_actions()
        self.assertTrue(subtyper.actions_enabled)
        self.assertFalse(subtyper.can_enable_actions())
        self.assertTrue(subtyper.can_disable_actions())
        self.assertTrue(directory.unrestrictedTraverse('@@faceted_query').actions_enabled())

        subtyper.disable_actions()
        self.assertFalse(subtyper.actions_enabled)
        self.assertTrue(subtyper.can_enable_actions())
        self.assertFalse(subtyper.can_disable_actions())
        self.assertFalse(directory.unrestrictedTraverse('@@faceted_query').actions_enabled())
コード例 #20
0
    def test_document_fusion_with_merge_simple(self):
        # data source is in a related content
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        source_1 = api.content.create(
            self.portal,
            type="contact_infos",
            id="desvenain_thomas",
            identity="M. Desvenain Thomas",
            address_1="24 rue des Trois Mollettes",
            address_2="C24",
            zipcode="59000",
            city="Lille",
        )

        content = api.content.create(
            self.portal,
            type="label_model",
            title=u"Modèle d'étiquette",
            file=NamedFile(
                data=open(TEST_LABEL_ODT).read(),
                filename=u"label.odt",
                contentType="application/vnd.oasis.opendocument.text",
            ),
            relatedItems=[RelationValue(intids.getId(source_1))],
        )

        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse("@@getdocumentfusion")()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response["content-type"], "application/pdf")
        generated_path = tempfile.mktemp(suffix="label.pdf")
        generated_file = open(generated_path, "w")
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix="label.pdf")
        subprocess.call(["pdftotext", generated_path, txt_path])
        txt = open(txt_path).read().replace(r"\xc2\xa0", " ")
        self.assertIn("M. DESVENAIN THOMAS", txt)
        self.assertIn("24 RUE DES TROIS MOLLETTES", txt)
        self.assertIn("C24", txt)
        self.assertIn(u"59000", txt)
        os.remove(txt_path)
        os.remove(generated_path)
コード例 #21
0
def createDirectories(parent):
    existing = parent.objectIds()
    if "users_directory" not in existing:
        _createObjectByType(
            "collective.rcse.directory",
            parent,
            id="users_directory",
            title=_(u"Users directory")
        )
    _updateFolder(
        parent.users_directory,
        ['collective.rcse.member'],
        "users_directory_view"
    )
    _publishContent(parent.users_directory)
    if "companies_directory" not in existing:
        _createObjectByType(
            "collective.rcse.directory",
            parent,
            id="companies_directory",
            title=_(u"Companies directory")
        )
    _updateFolder(
        parent.companies_directory,
        ['collective.rcse.company'],
        "companies_directory_view",
    )
    _publishContent(parent.companies_directory)
    if "home" not in existing:
        _createObjectByType(
            "Folder",
            parent,
            id="home",
            title=_(u"Home")
        )
    _updateFolder(
        parent.home,
        ['collective.rcse.group'],
        "timeline_view",
    )
    alsoProvides(parent.home, INavigationRoot)
    _publishContent(parent.home)
    parent.home.reindexObject()
コード例 #22
0
    def test_document_fusion(self):
        # data source and model are in the same content
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        content = api.content.create(
            self.portal,
            type="letter",
            title=u"En réponse...",
            file=NamedFile(
                data=open(TEST_LETTER_ODT).read(),
                filename=u"letter.odt",
                contentType="application/vnd.oasis.opendocument.text",
            ),
            sender_name="Thomas Desvenain",
            sender_address="57 Quai du Pré Long",
            recipient_name="Vincent Fretin",
            date=datetime.date(2012, 12, 23),
        )

        notify(ObjectModifiedEvent(content))

        annotations = IAnnotations(content)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        self.assertEqual(status, TASK_SUCCEEDED)

        generated_stream = content.unrestrictedTraverse("@@getdocumentfusion")()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response["content-type"], "application/pdf")
        generated_path = tempfile.mktemp(suffix="letter.pdf")
        generated_file = open(generated_path, "w")
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix="letter.pdf")
        subprocess.call(["pdftotext", generated_path, txt_path])
        txt = open(txt_path).read().replace(r"\xc2\xa0", " ")
        self.assertIn("Vincent Fretin", txt)
        self.assertIn("57 Quai du Pré Long", txt)
        self.assertIn("2012", txt)
        self.assertIn(u"EN RÉPONSE...", txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #23
0
def customSetupRoutine(portal):
    """to be able to call the method w/o creating a fake context in
    the unittest, we added this method.
    """

    if FOLDER_ID in portal.objectIds():
        return

    portal.invokeFactory('Folder', id=FOLDER_ID, title=u"Testimonials")
    folder = portal.unrestrictedTraverse(FOLDER_ID)
    folder._md['excludeFromNav'] = True
    alsoProvides(folder, ITestimonialFolder)

    folder.setConstrainTypesMode(1)
    folder.setLocallyAllowedTypes(['Image'])

    wft = getToolByName(portal, 'portal_workflow')
    wft.doActionFor(folder, 'publish')

    folder.reindexObject()
コード例 #24
0
    def test_document_fusion_with_external_model(self):
        # model is in a related content (archetypes)
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        model = api.content.create(self.portal, type='File',
                                   id='invoice_model',
                                   file=BlobbableFile(open(TEST_INVOICE_ODT)),
                                   )

        content = api.content.create(self.portal, type='invoice',
                           title=u"Invoice for the Great Company intranet",
                           bill_date=datetime.date(2012, 12, 23),
                           customer="The Great company",
                           order_num='12A',
                           vat_excluded=1000.0,
                           vat=0.19,
                           vat_included=1190.0,
                           relatedItems=[RelationValue(intids.getId(model))],
                           )

        content.unrestrictedTraverse('@@documentfusion-refresh')()
        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='invoice.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='invoice.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read()
        self.assertIn('2012', txt)
        self.assertIn('12A', txt)
        self.assertIn('1 000,00 €', txt)
        self.assertIn('19,00%', txt)
        os.remove(txt_path)
        os.remove(generated_path)
コード例 #25
0
    def test_document_fusion_with_external_model(self):
        # model is in a related content (archetypes)
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        model = api.content.create(self.portal, type='File',
                                   id='invoice_model',
                                   file=BlobbableFile(open(TEST_INVOICE_ODT)),
                                   )

        content = api.content.create(self.portal, type='invoice',
                           title=u"Invoice for the Great Company intranet",
                           bill_date=datetime.date(2012, 12, 23),
                           customer="The Great company",
                           order_num='12A',
                           vat_excluded=1000.0,
                           vat=0.19,
                           vat_included=1190.0,
                           relatedItems=[RelationValue(intids.getId(model))],
                           )

        content.unrestrictedTraverse('@@documentfusion-refresh')()
        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='invoice.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='invoice.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read()
        self.assertIn('2012', txt)
        self.assertIn('12A', txt)
        self.assertIn('1 000,00 €', txt)
        self.assertIn('19,00%', txt)
        os.remove(txt_path)
        os.remove(generated_path)
コード例 #26
0
    def afterSetUp(self):
        self.loginAsPortalOwner()
        portal = self.portal
        createMembers(portal)

        portal.portal_membership.getMemberById('reader2'
                            ).setMemberProperties({'listed': False})

        portal.portal_membership.getMemberById('editor'
                            ).setMemberProperties({'listed': False})

        portal.invokeFactory('Folder', 'folder1')
        portal.invokeFactory('Folder', 'folder2')
        alsoProvides(portal.folder1, IUserListingAvailable)

        portal.folder1.manage_addLocalRoles('reader', ('Reader',))
        portal.folder1.manage_addLocalRoles('reader2', ('Reader',))
        portal.folder1.manage_addLocalRoles('contributor', ('Contributor',))
        portal.folder1.manage_addLocalRoles('reviewer', ('Reviewer',))
        portal.folder1.manage_addLocalRoles('editor', ('Editor',))
        portal.folder1.manage_addLocalRoles('member', ('Member',))
コード例 #27
0
ファイル: rate.py プロジェクト: andreasma/cioppino.twothumbs
def setupAnnotations(context):
    """
    set up the annotations if they haven't been set up
    already. The rest of the functions in here assume that
    this has already been set up
    """
    annotations = IAnnotations(context)
    changed = False
    if yays not in annotations:
        annotations[yays] = OIBTree()
        changed = True

    if nays not in annotations:
        annotations[nays] = OIBTree()
        changed = True

    if changed:
        request = getRequest()
        alsoProvides(request, IDisableCSRFProtection)

    return annotations
コード例 #28
0
    def test_document_fusion(self):
        # data source and model are in the same content
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        content = api.content.create(self.portal, type='letter',
                           title=u"En réponse...",
                           file=NamedFile(data=open(TEST_LETTER_ODT).read(),
                                          filename=u'letter.odt',
                                          contentType='application/vnd.oasis.opendocument.text'),
                           sender_name="Thomas Desvenain",
                           sender_address="57 Quai du Pré Long",
                           recipient_name="Vincent Fretin",
                           date=datetime.date(2012, 12, 23))

        notify(ObjectModifiedEvent(content))

        annotations = IAnnotations(content)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        self.assertEqual(status, TASK_SUCCEEDED)

        generated_stream = content.unrestrictedTraverse('@@getdocumentfusion')()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response['content-type'],
                         'application/pdf')
        generated_path = tempfile.mktemp(suffix='letter.pdf')
        generated_file = open(generated_path, 'w')
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix='letter.pdf')
        subprocess.call(['pdftotext', generated_path, txt_path])
        txt = open(txt_path).read().replace(r'\xc2\xa0', ' ')
        self.assertIn('Vincent Fretin', txt)
        self.assertIn('57 Quai du Pré Long', txt)
        self.assertIn('2012', txt)
        self.assertIn(u'EN RÉPONSE...', txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #29
0
ファイル: event.py プロジェクト: eestec-patras/eestec.portal
from plone.directives import form, dexterity
from zope import schema
from zope.interface.declarations import alsoProvides


class IEvent(form.Schema):
    """
    """
    deadline = schema.Datetime(
        title=u'Deadline',
        description=u'Deadline to apply to this event',
        required=True,
    )


alsoProvides(IEvent, form.IFormFieldProvider)


class Event(dexterity.Container):
    """
    """
    grok.implements(IEvent)


@grok.subscribe(Event, IActionSucceededEvent)
def event_published(context, event):
    """
    Send email to CP list, notifying them that new event was published
    """
    if event.action == 'publish':
        emails.event.published_notify_cp_list(context)
コード例 #30
0
    def test_document_fusion_with_merge_multiple_collection(self):
        # data source is in a related content
        # we merge two files from two sources
        alsoProvides(self.portal.REQUEST, ICollectiveDocumentfusionLayer)
        intids = getUtility(IIntIds)
        api.content.create(
            self.portal,
            type="contact_infos",
            id="desvenain_thomas",
            identity="M. Desvenain Thomas",
            address_1="24 rue des Trois Mollettes",
            address_2="C24",
            zipcode="59000",
            city="Lille",
        )

        api.content.create(
            self.portal,
            type="contact_infos",
            id="fretin_vincent",
            identity="M. Fretin Vincent",
            address_1="51 r Lac",
            address_2="",
            zipcode="59810",
            city="LESQUIN",
        )

        collection = api.content.create(
            self.portal,
            type="Collection",
            id="all_labels",
            query=[{"i": "portal_type", "o": "plone.app.querystring.operation.selection.is", "v": ["contact_infos"]}],
        )

        content = api.content.create(
            self.portal,
            type="label_model",
            title=u"Modèle d'étiquette",
            file=NamedFile(
                data=open(TEST_LABEL_ODT).read(),
                filename=u"label.odt",
                contentType="application/vnd.oasis.opendocument.text",
            ),
            relatedItems=[RelationValue(intids.getId(collection))],
        )

        notify(ObjectModifiedEvent(content))

        generated_stream = content.unrestrictedTraverse("@@getdocumentfusion")()
        self.assertTrue(generated_stream)
        self.assertEqual(self.portal.REQUEST.response["content-type"], "application/pdf")
        generated_path = tempfile.mktemp(suffix="label.pdf")
        generated_file = open(generated_path, "w")
        generated_file.write(generated_stream.read())
        generated_file.close()

        txt_path = tempfile.mktemp(suffix="label.pdf")
        subprocess.call(["pdftotext", generated_path, txt_path])
        txt = open(txt_path).read()

        # label 1
        self.assertIn("M. DESVENAIN THOMAS", txt)
        self.assertIn("24 RUE DES TROIS MOLLETTES", txt)
        self.assertIn("C24", txt)
        self.assertIn(u"59000", txt)

        # label 2
        self.assertIn("M. FRETIN VINCENT", txt)
        self.assertIn(u"59810", txt)
        self.assertIn(u"LESQUIN", txt)

        os.remove(txt_path)
        os.remove(generated_path)
コード例 #31
0
ファイル: app.py プロジェクト: BenoitTalbot/bungeni-portal
    def setUp(self):
        
        # register translations
        from bungeni.utils.capi import capi
        #import zope.i18n.zcml
        #zope.i18n.zcml.registerTranslations(getConfigContext(),
        #    capi.get_path_for("translations", "bungeni"))
        # 
        # !+ZCML_PYTHON(mr, apr-2011) above registerTranslations() in python 
        # does not work, as subsequent utility lookup fails. We workaround it 
        # by executing the following parametrized bit of ZCML:
        #
        from zope.configuration import xmlconfig
        xmlconfig.string("""
            <configure xmlns="http://namespaces.zope.org/zope"
                xmlns:i18n="http://namespaces.zope.org/i18n">
                <include package="zope.i18n" file="meta.zcml" />
                <i18n:registerTranslations directory="%s" />
            </configure>
            """ % (capi.get_path_for("translations", "bungeni")))
        
        import index
        # ensure indexing facilities are setup(lazy)
        index.setupFieldDefinitions(index.indexer)

        
        sm = site.LocalSiteManager(self.context)
        self.context.setSiteManager(sm)
        
        from bungeni.ui import z3evoque
        z3evoque.set_get_gettext()
        z3evoque.setup_evoque()
        z3evoque.domain.set_on_globals("devmode", common.has_feature("devmode"))
        z3evoque.domain.set_on_globals("absoluteURL", url.absoluteURL)
        z3evoque.domain.set_on_globals("get_section_name", url.get_section_name)
        z3evoque.domain.set_on_globals("get_base_direction", 
            language.get_base_direction)
        z3evoque.domain.set_on_globals("is_rtl", language.is_rtl)            
            
        # !+ where is the view name for the app root (slash) set?
        
        # CONVENTION: the action of each site top-section is made to point 
        # directly the primary sub-section (the INDEX) that it contains.
        # EXCEPTION: the "/", when logged in, is redirected to "/workspace/pi"
        
        self.context["bungeni"] = AkomaNtosoSection(
            title=_(u"Bungeni"),
            description=_(u"Current parliamentary activity"),
            default_name="bung", # !+NAMING(mr, jul-2011) bung?!?
        )
        
        # top-level sections
        workspace = self.context["workspace"] = WorkspaceSection(
            title=_(u"Workspace"),
            description=_(u"Current parliamentary activity"),
            default_name="documents",
        )
        
        alsoProvides(workspace, interfaces.ISearchableSection)
        workspace["documents"] = Section(
            title=_(u"documents"),
            description=_(u"documents"),
            default_name="inbox",
            marker = interfaces.IWorkspaceDocuments,
        )
        workspace["documents"]["draft"] = WorkspaceContainer(
            tab_type="draft",
            title=_("draft"),
            description=_("draft documents"),
            marker=interfaces.IWorkspaceDraft
        )
        workspace["documents"]["inbox"] = WorkspaceContainer(
            tab_type="inbox",
            title=_("inbox"),
            description=_("incoming documents"),
            marker=interfaces.IWorkspaceInbox
        )
        workspace["documents"]["sent"] = WorkspaceContainer(
            tab_type="sent",
            title=_("sent"),
            description=_("sent documents"),
            marker=interfaces.IWorkspaceSent
        )
        workspace["documents"]["archive"] = WorkspaceContainer(
            tab_type="archive",
            title=_("archive"),
            description=_("archived documents"),
            marker=interfaces.IWorkspaceArchive
        )
        
        workspace["scheduling"] = Section(
            title=_(u"Scheduling"),
            description=_(u"Scheduling"),
            default_name="index",
            marker=interfaces.IWorkspaceScheduling,
        )
        workspace["scheduling"]["committees"] = QueryContent(
            container_getter(get_current_parliament, 'committees'),
            title=_(u"Committees"),
            marker=interfaces.ICommitteeAddContext,
            description=_(u"Committee schedules")
        )
        workspace["scheduling"]["sittings"] = QueryContent(
            container_getter(get_current_parliament, 'sittings'),
            title=_(u"Sittings"),
            description=_(u"Plenary Sittings")
        )
        # Proof-of-concept: support for selective inclusion in breadcrumb trail:
        # a view marked with an attribute __crumb__=False is NOT included in 
        # the breadcrumb trail (see ui/viewlets/navigation.py)
        #self.context["workspace"].__crumb__ = False
        business = self.context["business"] = Section(
            title=_(u"Business"),
            description=_(u"Daily operations of the parliament"),
            default_name="business-index")
        members = self.context["members"] = Section(
            title=_(u"Members"),
            description=_(u"Records of members of parliament"),
            default_name="members-index")
        archive = self.context["archive"] = Section(
            title=_(u"Archive"),
            description=_(u"Parliament records and documents"),
            default_name="archive-index")
        
        alsoProvides(archive, interfaces.ISearchableSection)
            
        #!+SECURITY(miano. nov-2010) Admin section now uses AdminSection
        # container that is identical to Section, only difference is that
        # traversing though it requires zope.ManageSite permission as defined
        # in core/configure.zcml
            
        admin = self.context["admin"] = AdminSection(
            title=_(u"Administration"),
            description=_(u"Manage bungeni settings"),
            default_name="admin-index",
            marker=model_interfaces.IBungeniAdmin)
        
        alsoProvides(admin, interfaces.ISearchableSection)
        
        # business section
        business["whats-on"] = Section(
            title=_(u"What's on"),
            description=_(u"Current parliamentary activity"),
            default_name="whats-on")
        
        alsoProvides(business, interfaces.ISearchableSection)

        business[u"committees"] = QueryContent(
            container_getter(get_current_parliament, 'committees'),
            title=_(u"Committees"),
            marker=interfaces.ICommitteeAddContext,
            description=_(u"View committees created by the current parliament"))
        
        business[u"bills"] = QueryContent(
            container_getter(get_current_parliament, 'bills'),
            title=_(u"Bills"),
            marker=interfaces.IBillAddContext,
            description=_(u"View bills introduced in the current parliament"))

        business[u"questions"] = QueryContent(
            container_getter(get_current_parliament, 'questions'),
            title=_(u"Questions"),
            marker=interfaces.IQuestionAddContext,
            description=_(u"View questions tabled in the current parliament"))

        business[u"motions"] = QueryContent(
            container_getter(get_current_parliament, 'motions'),
            title=_(u"Motions"),
            marker=interfaces.IMotionAddContext,
            description=_(u"View motions moved in the current parliament"))


        business[u"tableddocuments"] = QueryContent(
            container_getter(get_current_parliament, 'tableddocuments'),
            title=_(u"Tabled documents"),
            marker=interfaces.ITabledDocumentAddContext,
            description=\
                _(u"View the documents tabled in the current parliament")
        )

        business[u"agendaitems"] = QueryContent(
            container_getter(get_current_parliament, 'agendaitems'),
            title=_(u"Agenda items"),
            marker=interfaces.IAgendaItemAddContext,
            description=_(u"View the agenda items of the current parliament"))

       # sessions = business[u"sessions"] = QueryContent(
       #     container_getter(get_current_parliament, 'sessions'),
       #     title=_(u"Sessions"),
       #     marker=interfaces.ISessionAddContext,
       #     description=_(u"View the sessions of the current parliament."))

        business[u"sittings"] = QueryContent(
            container_getter(get_current_parliament, 'sittings'),
            title=_(u"Sittings"),
            description=_(u"View the sittings of the current parliament"))
            
        #Parliamentary reports
        business[u"preports"] = QueryContent(
            container_getter(get_current_parliament, 'preports'),
            title=_(u"Publications"),
            marker=interfaces.IReportAddContext,
            description=\
                _(u"browse and download parliamentary publications")
        )
        
        
        # members section
        members[u"current"] = QueryContent(
            container_getter(get_current_parliament, 'parliamentmembers'),
            title=_(u"Current"),
            description=_(u"View current parliament members (MPs)"))
        
        alsoProvides(members, interfaces.ISearchableSection)

        members[u"political-groups"] = QueryContent(
            container_getter(get_current_parliament, 'politicalgroups'),
            title=_(u"Political groups"),
            description=_(u"View current political groups"))

        # archive
        records = archive[u"browse"] = Section(
            title=_(u"Browse archives"),
            description=_(u"Browse records from the archive"),
            default_name="browse-archive")

        documents = archive["documents"] = Section(
            title=_(u"Documents"),
            description=_(u"Browse documents in the archive"),
            default_name="browse-archive")
            
        
        def to_locatable_container(domain_class, *domain_containers):
            provideAdapter(location.ContainerLocation(*domain_containers),
                       (implementedBy(domain_class), ILocation))
        
        # archive/records
        documents[u"bills"] = domain.BillContainer()
        to_locatable_container(domain.Bill, documents[u"bills"])

        documents[u"motions"] = domain.MotionContainer()
        to_locatable_container(domain.Motion, documents[u"motions"])
        
        documents[u"questions"] = domain.QuestionContainer()
        to_locatable_container(domain.Question, documents[u"questions"])
        
        documents[u"agendaitems"] = domain.AgendaItemContainer()
        to_locatable_container(domain.AgendaItem, documents[u"agendaitems"])

        documents[u"tableddocuments"] = domain.TabledDocumentContainer()
        to_locatable_container(domain.TabledDocument, 
            documents[u"tableddocuments"]
        )
        
        documents[u"reports"] = domain.ReportContainer()
        to_locatable_container(domain.Report, documents[u"reports"])
        #provideAdapter(location.ContainerLocation(tableddocuments, documents[u"reports"]),
        #               (implementedBy(domain.Report), ILocation))
        
        records[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, records[u"parliaments"])
        
        records[u"politicalgroups"] = domain.PoliticalGroupContainer()
        to_locatable_container(domain.PoliticalGroup, 
            records[u"politicalgroups"]
        )
        
        records[u"constituencies"] = domain.ConstituencyContainer()
        to_locatable_container(domain.Constituency, records[u"constituencies"])
        
        records[u"committees"] = domain.CommitteeContainer()
        to_locatable_container(domain.Committee, records[u"committees"])

        #records[u"mps"] = domain.MemberOfParliamentContainer()
        #provideAdapter(location.ContainerLocation(records[u"mps"]),
        #               (implementedBy(domain.MemberOfParliament), ILocation))
        
        ##########
        # Admin User Interface
        # Administration section
        
        content = admin["content"] = Section(
            title=_(u"Content"),
            description=_(u"browse bungeni content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="browse-admin")

        admin["settings"] = Section(
            title=_(u"Settings"),
            description=_(u"settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="settings")

        admin["email-settings"] = Section(
            title=_(u"email settings"),
            description=_(u"manage email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="email-settings")

        admin["xapian-settings"] = Section(
            title=_(u"search index settings"),
            description=_(u"manage search index settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="xapian-settings")
        
        admin["registry-settings"] = Section(
            title=_(u"registry settings"),
            description=_(u"manage registry settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="registry-settings")
        
        content[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, content[u"parliaments"])
        
        content[u"offices"] = domain.OfficeContainer()
        to_locatable_container(domain.Office, content[u"offices"])
        
        content[u'users'] = domain.UserContainer()
        to_locatable_container(domain.User, content[u"users"])
        
        content[u'headings'] = domain.HeadingContainer()
        to_locatable_container(domain.Heading, content[u"headings"])
        
        content[u"constituencies"] = domain.ConstituencyContainer()
        to_locatable_container(domain.Constituency, content[u"constituencies"])
        
        content[u"provinces"] = domain.ProvinceContainer()
        to_locatable_container(domain.Province, content[u"provinces"])
        
        content[u"regions"] = domain.RegionContainer()
        to_locatable_container(domain.Region, content[u"regions"])
        
        content[u"parties"] = domain.PoliticalPartyContainer()
        to_locatable_container(domain.PoliticalParty, content[u"parties"])

        ''' !+TYPES_CUSTOM
コード例 #32
0
 def setUp(self):
     self.portal = self.layer["portal"]
     alsoProvides(self.portal.REQUEST, IOSHAContentSkinLayer)
コード例 #33
0
 def get_rating(self, object):
     """ """
     if not IAttributeAnnotatable.providedBy(object):
         alsoProvides(object, IAttributeAnnotatable)
     annotations = IAnnotations(object)
     return annotations.get('opkode.rateablediscussion.rating', 0)
コード例 #34
0
ファイル: behavior.py プロジェクト: RedTurtle/rt.semantic
# -*- coding: utf-8 -*-

from zope import schema
from zope.interface.declarations import alsoProvides

from plone.autoform.interfaces import IFormFieldProvider
from plone.directives import form
from z3c.form.interfaces import IEditForm, IDisplayForm

from rt.semantic import semanticMessageFactory as _


class ISemantic(form.Schema):
    """
    Semantic behavior interface
    """
    semantic = schema.Tuple(
        title=_("label_semantic", default=u"Semantic"),
        description=_("help_semantic", default=u""),
        required=False,
        value_type=schema.TextLine(),
        missing_value=(),
    )
    form.omitted('semantic')
    form.no_omit(IDisplayForm, 'semantic')
    form.no_omit(IEditForm, 'semantic')

alsoProvides(ISemantic, IFormFieldProvider)

コード例 #35
0
ファイル: app.py プロジェクト: mohalfaki/bungeni-portal
    def setUp(self):

        # register translations
        from bungeni.utils.capi import capi
        #import zope.i18n.zcml
        #zope.i18n.zcml.registerTranslations(getConfigContext(),
        #    capi.get_path_for("translations", "bungeni"))
        #
        # !+ZCML_PYTHON(mr, apr-2011) above registerTranslations() in python
        # does not work, as subsequent utility lookup fails. We workaround it
        # by executing the following parametrized bit of ZCML:
        #
        from zope.configuration import xmlconfig
        xmlconfig.string("""
            <configure xmlns="http://namespaces.zope.org/zope"
                xmlns:i18n="http://namespaces.zope.org/i18n">
                <include package="zope.i18n" file="meta.zcml" />
                <i18n:registerTranslations directory="%s" />
            </configure>
            """ % (capi.get_path_for("translations", "bungeni")))

        import index
        # ensure indexing facilities are setup(lazy)
        index.setupFieldDefinitions(index.indexer)

        sm = site.LocalSiteManager(self.context)
        self.context.setSiteManager(sm)

        from bungeni.ui import z3evoque
        z3evoque.set_get_gettext()
        z3evoque.setup_evoque()
        z3evoque.domain.set_on_globals("devmode",
                                       common.has_feature("devmode"))
        z3evoque.domain.set_on_globals("absoluteURL", url.absoluteURL)
        z3evoque.domain.set_on_globals("get_section_name",
                                       url.get_section_name)
        z3evoque.domain.set_on_globals("get_base_direction",
                                       language.get_base_direction)
        z3evoque.domain.set_on_globals("is_rtl", language.is_rtl)

        # !+ where is the view name for the app root (slash) set?

        # CONVENTION: the action of each site top-section is made to point
        # directly the primary sub-section (the INDEX) that it contains.
        # EXCEPTION: the "/", when logged in, is redirected to "/workspace/pi"

        self.context["bungeni"] = AkomaNtosoSection(
            title=_(u"Bungeni"),
            description=_(u"Current parliamentary activity"),
            default_name="bung",  # !+NAMING(mr, jul-2011) bung?!?
        )

        # top-level sections
        workspace = self.context["workspace"] = WorkspaceSection(
            title=_(u"Workspace"),
            description=_(u"Current parliamentary activity"),
            default_name="documents",
        )

        alsoProvides(workspace, interfaces.ISearchableSection)
        workspace["documents"] = Section(
            title=_(u"documents"),
            description=_(u"documents"),
            default_name="inbox",
            marker=interfaces.IWorkspaceDocuments,
        )
        workspace["documents"]["draft"] = WorkspaceContainer(
            tab_type="draft",
            title=_("draft"),
            description=_("draft documents"),
            marker=interfaces.IWorkspaceDraft)
        workspace["documents"]["inbox"] = WorkspaceContainer(
            tab_type="inbox",
            title=_("inbox"),
            description=_("incoming documents"),
            marker=interfaces.IWorkspaceInbox)
        workspace["documents"]["sent"] = WorkspaceContainer(
            tab_type="sent",
            title=_("sent"),
            description=_("sent documents"),
            marker=interfaces.IWorkspaceSent)
        workspace["documents"]["archive"] = WorkspaceContainer(
            tab_type="archive",
            title=_("archive"),
            description=_("archived documents"),
            marker=interfaces.IWorkspaceArchive)

        workspace["scheduling"] = Section(
            title=_(u"Scheduling"),
            description=_(u"Scheduling"),
            default_name="index",
            marker=interfaces.IWorkspaceScheduling,
        )
        workspace["scheduling"]["committees"] = QueryContent(
            container_getter(get_current_parliament, 'committees'),
            title=_(u"Committees"),
            marker=interfaces.ICommitteeAddContext,
            description=_(u"Committee schedules"))
        workspace["scheduling"]["sittings"] = QueryContent(
            container_getter(get_current_parliament, 'sittings'),
            title=_(u"Sittings"),
            description=_(u"Plenary Sittings"))
        # Proof-of-concept: support for selective inclusion in breadcrumb trail:
        # a view marked with an attribute __crumb__=False is NOT included in
        # the breadcrumb trail (see ui/viewlets/navigation.py)
        #self.context["workspace"].__crumb__ = False
        business = self.context["business"] = Section(
            title=_(u"Business"),
            description=_(u"Daily operations of the parliament"),
            default_name="business-index")
        members = self.context["members"] = Section(
            title=_(u"Members"),
            description=_(u"Records of members of parliament"),
            default_name="members-index")
        archive = self.context["archive"] = Section(
            title=_(u"Archive"),
            description=_(u"Parliament records and documents"),
            default_name="archive-index")

        alsoProvides(archive, interfaces.ISearchableSection)

        #!+SECURITY(miano. nov-2010) Admin section now uses AdminSection
        # container that is identical to Section, only difference is that
        # traversing though it requires zope.ManageSite permission as defined
        # in core/configure.zcml

        admin = self.context["admin"] = AdminSection(
            title=_(u"Administration"),
            description=_(u"Manage bungeni settings"),
            default_name="admin-index",
            marker=model_interfaces.IBungeniAdmin)

        alsoProvides(admin, interfaces.ISearchableSection)

        # business section
        business["whats-on"] = Section(
            title=_(u"What's on"),
            description=_(u"Current parliamentary activity"),
            default_name="whats-on")

        alsoProvides(business, interfaces.ISearchableSection)

        business[u"committees"] = QueryContent(
            container_getter(get_current_parliament, 'committees'),
            title=_(u"Committees"),
            marker=interfaces.ICommitteeAddContext,
            description=_(
                u"View committees created by the current parliament"))

        business[u"bills"] = QueryContent(
            container_getter(get_current_parliament, 'bills'),
            title=_(u"Bills"),
            marker=interfaces.IBillAddContext,
            description=_(u"View bills introduced in the current parliament"))

        business[u"questions"] = QueryContent(
            container_getter(get_current_parliament, 'questions'),
            title=_(u"Questions"),
            marker=interfaces.IQuestionAddContext,
            description=_(u"View questions tabled in the current parliament"))

        business[u"motions"] = QueryContent(
            container_getter(get_current_parliament, 'motions'),
            title=_(u"Motions"),
            marker=interfaces.IMotionAddContext,
            description=_(u"View motions moved in the current parliament"))


        business[u"tableddocuments"] = QueryContent(
            container_getter(get_current_parliament, 'tableddocuments'),
            title=_(u"Tabled documents"),
            marker=interfaces.ITabledDocumentAddContext,
            description=\
                _(u"View the documents tabled in the current parliament")
        )

        business[u"agendaitems"] = QueryContent(
            container_getter(get_current_parliament, 'agendaitems'),
            title=_(u"Agenda items"),
            marker=interfaces.IAgendaItemAddContext,
            description=_(u"View the agenda items of the current parliament"))

        # sessions = business[u"sessions"] = QueryContent(
        #     container_getter(get_current_parliament, 'sessions'),
        #     title=_(u"Sessions"),
        #     marker=interfaces.ISessionAddContext,
        #     description=_(u"View the sessions of the current parliament."))

        business[u"sittings"] = QueryContent(
            container_getter(get_current_parliament, 'sittings'),
            title=_(u"Sittings"),
            description=_(u"View the sittings of the current parliament"))

        #Parliamentary reports
        business[u"preports"] = QueryContent(
            container_getter(get_current_parliament, 'preports'),
            title=_(u"Publications"),
            marker=interfaces.IReportAddContext,
            description=\
                _(u"browse and download parliamentary publications")
        )

        # members section
        members[u"current"] = QueryContent(
            container_getter(get_current_parliament, 'parliamentmembers'),
            title=_(u"Current"),
            description=_(u"View current parliament members (MPs)"))

        alsoProvides(members, interfaces.ISearchableSection)

        members[u"political-groups"] = QueryContent(
            container_getter(get_current_parliament, 'politicalgroups'),
            title=_(u"Political groups"),
            description=_(u"View current political groups"))

        # archive
        records = archive[u"browse"] = Section(
            title=_(u"Browse archives"),
            description=_(u"Browse records from the archive"),
            default_name="browse-archive")

        documents = archive["documents"] = Section(
            title=_(u"Documents"),
            description=_(u"Browse documents in the archive"),
            default_name="browse-archive")

        def to_locatable_container(domain_class, *domain_containers):
            provideAdapter(location.ContainerLocation(*domain_containers),
                           (implementedBy(domain_class), ILocation))

        # archive/records
        documents[u"bills"] = domain.BillContainer()
        to_locatable_container(domain.Bill, documents[u"bills"])

        documents[u"motions"] = domain.MotionContainer()
        to_locatable_container(domain.Motion, documents[u"motions"])

        documents[u"questions"] = domain.QuestionContainer()
        to_locatable_container(domain.Question, documents[u"questions"])

        documents[u"agendaitems"] = domain.AgendaItemContainer()
        to_locatable_container(domain.AgendaItem, documents[u"agendaitems"])

        documents[u"tableddocuments"] = domain.TabledDocumentContainer()
        to_locatable_container(domain.TabledDocument,
                               documents[u"tableddocuments"])

        documents[u"reports"] = domain.ReportContainer()
        to_locatable_container(domain.Report, documents[u"reports"])
        #provideAdapter(location.ContainerLocation(tableddocuments, documents[u"reports"]),
        #               (implementedBy(domain.Report), ILocation))

        records[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, records[u"parliaments"])

        records[u"politicalgroups"] = domain.PoliticalGroupContainer()
        to_locatable_container(domain.PoliticalGroup,
                               records[u"politicalgroups"])

        records[u"constituencies"] = domain.ConstituencyContainer()
        to_locatable_container(domain.Constituency, records[u"constituencies"])

        records[u"committees"] = domain.CommitteeContainer()
        to_locatable_container(domain.Committee, records[u"committees"])

        #records[u"mps"] = domain.MemberOfParliamentContainer()
        #provideAdapter(location.ContainerLocation(records[u"mps"]),
        #               (implementedBy(domain.MemberOfParliament), ILocation))

        ##########
        # Admin User Interface
        # Administration section

        content = admin["content"] = Section(
            title=_(u"Content"),
            description=_(u"browse bungeni content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="browse-admin")

        admin["settings"] = Section(title=_(u"Settings"),
                                    description=_(u"settings"),
                                    marker=model_interfaces.IBungeniAdmin,
                                    default_name="settings")

        admin["email-settings"] = Section(
            title=_(u"email settings"),
            description=_(u"manage email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="email-settings")

        admin["xapian-settings"] = Section(
            title=_(u"search index settings"),
            description=_(u"manage search index settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="xapian-settings")

        admin["registry-settings"] = Section(
            title=_(u"registry settings"),
            description=_(u"manage registry settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="registry-settings")

        content[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, content[u"parliaments"])

        content[u"offices"] = domain.OfficeContainer()
        to_locatable_container(domain.Office, content[u"offices"])

        content[u'users'] = domain.UserContainer()
        to_locatable_container(domain.User, content[u"users"])

        content[u'headings'] = domain.HeadingContainer()
        to_locatable_container(domain.Heading, content[u"headings"])

        content[u"constituencies"] = domain.ConstituencyContainer()
        to_locatable_container(domain.Constituency, content[u"constituencies"])

        content[u"provinces"] = domain.ProvinceContainer()
        to_locatable_container(domain.Province, content[u"provinces"])

        content[u"regions"] = domain.RegionContainer()
        to_locatable_container(domain.Region, content[u"regions"])

        content[u"parties"] = domain.PoliticalPartyContainer()
        to_locatable_container(domain.PoliticalParty, content[u"parties"])
        ''' !+TYPES_CUSTOM
コード例 #36
0
ファイル: app.py プロジェクト: kohsah/bungeni-portal
    def setUp(self):
        
        # register translations
        #import zope.i18n.zcml
        #zope.i18n.zcml.registerTranslations(getConfigContext(),
        #    capi.get_path_for("translations", "bungeni"))
        # !+ZCML_PYTHON(mr, apr-2011) above registerTranslations() in python 
        # does not work, as subsequent utility lookup fails. We workaround it 
        # by executing the following parametrized bit of ZCML:
        from zope.configuration import xmlconfig
        xmlconfig.string("""
            <configure xmlns="http://namespaces.zope.org/zope"
                xmlns:i18n="http://namespaces.zope.org/i18n">
                <include package="zope.i18n" file="meta.zcml" />
                <i18n:registerTranslations directory="%s" />
            </configure>
            """ % (capi.get_path_for("translations", "bungeni")))
        
        sm = site.LocalSiteManager(self.context)
        self.context.setSiteManager(sm)
        
        from bungeni.core import language
        from bungeni.ui import z3evoque
        z3evoque.set_get_gettext()
        z3evoque.setup_evoque()
        z3evoque.domain.set_on_globals("devmode", common.has_feature("devmode"))
        z3evoque.domain.set_on_globals("absoluteURL", url.absoluteURL)
        z3evoque.domain.set_on_globals("get_section_name", url.get_section_name)
        z3evoque.domain.set_on_globals("get_base_direction", 
            language.get_base_direction)
        z3evoque.domain.set_on_globals("is_rtl", language.is_rtl)          
        
        # !+ where is the view name for the app root (slash) set?
        
        # CONVENTION: the action of each site top-section is made to point 
        # directly the primary sub-section (the INDEX) that it contains.
        # EXCEPTION: the "/", when logged in, is redirected to "/workspace/pi"
        
        self.context["bungeni"] = AkomaNtosoSection(
            title=_(u"Bungeni"),
            description=_(u"Current parliamentary activity"),
            default_name="bung", # !+NAMING(mr, jul-2011) bung?!?
        )
        
        # top-level sections
        workspace = self.context["workspace"] = WorkspaceSection(
            title=_("section_workspace", default=u"Workspace"),
            description=_(u"Current parliamentary activity"),
            default_name="my-documents",
        )
        alsoProvides(workspace, interfaces.ISearchableSection)
        
        workspace["my-documents"] = WorkspaceSection(
            title=_("section_workspace_documents", default=u"my documents"),
            description=_(u"my documents workspace section"),
            default_name="inbox",
            marker=interfaces.IWorkspaceDocuments,
        )
        
        for tab in capi.workspace_tabs:
            workspace["my-documents"][tab] = WorkspaceContainer(
                tab_type=tab,
                title=_("section_workspace_%s" % tab, default=tab),
                marker=interfaces.IWorkspaceTab
            )

        ws_uc = workspace["under-consideration"] = WorkspaceSection(
            title=_(u"under consideration"),
            description=_(u"documents under consideration"),
            default_name="documents",
            marker=interfaces.IWorkspaceUnderConsideration)
        ws_uc["documents"] = WorkspaceUnderConsiderationContainer(
            name="documents",
            title=_(u"under consideration"),
            description=_(u"documents under consideration"),
            marker=interfaces.IWorkspaceTrackedDocuments)
        ws_uc["tracked-documents"] = WorkspaceTrackedDocumentsContainer(
            name="tracked documents",
            title=_(u"tracked documents"),
            description=_(u"tracked documents"))
        
        ws_sched = workspace["scheduling"] = Section(
            title=_("section_scheduling", default=u"Scheduling"),
            description=_(u"Workspace Scheduling"),
            default_name="index",
            marker=interfaces.IWorkspaceScheduling)
        ws_sched["committees"] = QueryContent(
            container_getter(get_chamber_for_context, "committees"),
            title=_("section_scheduling_committees", default=u"Committees"),
            #!+marker=interfaces.ICommitteeAddContext,
            description=_(u"Committee schedules"))
        ws_sched["documents"] = WorkspaceSchedulableContainer(
            name=_(u"schedulable items"),
            title=_(u"schedulable items"),
            description=_(u"documents available for scheduling"))
        ws_sched["sittings"] = QueryContent(
            container_getter(get_chamber_for_context, "sittings"),
            title=_("section_scheduling_sittings", default=u"Sittings"),
            description=_(u"Plenary Sittings"))
        ws_sched["sessions"] = QueryContent(
            container_getter(get_chamber_for_context, "sessions"),
            title=_("section_scheduling_sessions", default=u"Sessions"),
            description=_(u"Plenary Sessions"))
        ws_sched["venues"] = QueryContent(
            container_getter(get_chamber_for_context, "venues"),
            title=_("section_scheduling_venues", default=u"Venues"),
            description=_(u"Venues"))
        ws_sched["agendaitems"] = QueryContent(
            container_getter(get_chamber_for_context, "agendaitems"),
            title=_("section_scheduling_agenda_items", 
                default=u"Agenda items"),
            #marker=interfaces.IAgendaItemAddContext,
            description=_(u"Manage agenda items"))
        ws_sched["publications"] = QueryContent(
            container_getter(get_chamber_for_context, "publications"),
            title=_("section_scheduling_publications", 
                default=u"Publications"),
            description=_(u"Publications"))
        
        workspace["groups"] = WorkspaceSection(
            title=_("section_groups", default=u"Groups"),
            description=_(u"Bungeni Groups"),
            default_name="my-groups",
            marker=interfaces.IWorkspaceGroups)
        workspace["groups"]["my-groups"] = WorkspaceGroupsContainer(
            name="my-groups",
            title=_(u"My Groups"),
            description=_(u"Groups that the user is a member of"))
        
        #!+TIMING
        #!+AUTO CONTAINERS SCHEDULING(mb, April-2012)
        # type_info missing container name
        for type_key, ti in capi.iter_type_info():
            if model_interfaces.IScheduleContent.implementedBy(ti.domain_model):
                container_property_name = naming.plural(type_key)
                container_class_name = naming.container_class_name(type_key)
                if not ws_sched.has_key(container_property_name):
                    ws_sched[container_property_name] = \
                        getattr(domain, container_class_name)()
                    to_locatable_container(
                        ti.domain_model, ws_sched[container_property_name])
        
        
        ##########
        # Admin User Interface
        # Administration section
        
        #!+SECURITY(miano. nov-2010) Admin section now uses AdminSection
        # container that is identical to Section, only difference is that
        # traversing though it requires zope.ManageSite permission as defined
        # in core/configure.zcml
        
        admin = self.context["admin"] = AdminSection(
            title=_(u"Administration"),
            description=_(u"Manage bungeni settings"),
            default_name="admin-index",
            marker=model_interfaces.IBungeniAdmin)
        
        content = admin["content"] = Section(
            title=_(u"Content"),
            description=_(u"browse bungeni content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="browse-admin")
        alsoProvides(content, interfaces.ISearchableSection)
        
        admin["email-settings"] = Section(
            title=_(u"email settings"),
            description=_(u"manage email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="email-settings")
        
        admin["search-settings"] = Section(
            title=_(u"search settings"),
            description=_(u"manage bungeni email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="search-settings")
        
        admin["registry-settings"] = Section(
            title=_(u"registry settings"),
            description=_(u"manage registry settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="registry-settings")
        
        admin["serialization-manager"] = Section(
            title=_(u"serialization manager"),
            description=_(u"batch serialization of content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="serialization-manager")
        
        content[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, content[u"parliaments"])
        content[u"governments"] = domain.GovernmentContainer()
        to_locatable_container(domain.Government, content[u"governments"])
        content[u"joint-committees"] = domain.JointCommitteeContainer()
        to_locatable_container(domain.JointCommittee,
            content["joint-committees"])
        content[u"users"] = domain.UserContainer()
        to_locatable_container(domain.User, content[u"users"])

        api = self.context[u"api"] = APISection(
            title=_(u"Bungeni API"),
            description=_(u"Bungeni REST API"),
            default_name="index",
        )

        api[u"workspace"] = copy.deepcopy(workspace)

        api[u"users"] = copy.deepcopy(content[u"users"])

        self.context["oauth"] = OAuthSection(
            title=_(u"Bungeni OAuth API"),
            description=_(u"Bungeni OAuth API"),
            default_name="index",
        )
        admin[u"applications"] = domain.OAuthApplicationContainer()
        to_locatable_container(domain.OAuthApplication, admin[u"applications"])
コード例 #37
0
ファイル: test_statistics.py プロジェクト: garbas/osha.oira
 def setUp(self):
     self.portal = self.layer["portal"]
     alsoProvides(self.portal.REQUEST, IOSHAContentSkinLayer)
コード例 #38
0
ファイル: app.py プロジェクト: mohalfaki/bungeni-portal
    def setUp(self):

        # register translations
        #import zope.i18n.zcml
        #zope.i18n.zcml.registerTranslations(getConfigContext(),
        #    capi.get_path_for("translations", "bungeni"))
        # !+ZCML_PYTHON(mr, apr-2011) above registerTranslations() in python
        # does not work, as subsequent utility lookup fails. We workaround it
        # by executing the following parametrized bit of ZCML:
        from zope.configuration import xmlconfig
        xmlconfig.string("""
            <configure xmlns="http://namespaces.zope.org/zope"
                xmlns:i18n="http://namespaces.zope.org/i18n">
                <include package="zope.i18n" file="meta.zcml" />
                <i18n:registerTranslations directory="%s" />
            </configure>
            """ % (capi.get_path_for("translations", "bungeni")))

        sm = site.LocalSiteManager(self.context)
        self.context.setSiteManager(sm)

        from bungeni.core import language
        from bungeni.ui import z3evoque
        z3evoque.set_get_gettext()
        z3evoque.setup_evoque()
        z3evoque.domain.set_on_globals("devmode",
                                       common.has_feature("devmode"))
        z3evoque.domain.set_on_globals("absoluteURL", url.absoluteURL)
        z3evoque.domain.set_on_globals("get_section_name",
                                       url.get_section_name)
        z3evoque.domain.set_on_globals("get_base_direction",
                                       language.get_base_direction)
        z3evoque.domain.set_on_globals("is_rtl", language.is_rtl)

        # !+ where is the view name for the app root (slash) set?

        # CONVENTION: the action of each site top-section is made to point
        # directly the primary sub-section (the INDEX) that it contains.
        # EXCEPTION: the "/", when logged in, is redirected to "/workspace/pi"

        self.context["bungeni"] = AkomaNtosoSection(
            title=_(u"Bungeni"),
            description=_(u"Current parliamentary activity"),
            default_name="bung",  # !+NAMING(mr, jul-2011) bung?!?
        )

        # top-level sections
        workspace = self.context["workspace"] = WorkspaceSection(
            title=_("section_workspace", default=u"Workspace"),
            description=_(u"Current parliamentary activity"),
            default_name="my-documents",
        )
        alsoProvides(workspace, interfaces.ISearchableSection)

        workspace["my-documents"] = WorkspaceSection(
            title=_("section_workspace_documents", default=u"my documents"),
            description=_(u"my documents workspace section"),
            default_name="inbox",
            marker=interfaces.IWorkspaceDocuments,
        )

        for tab in capi.workspace_tabs:
            workspace["my-documents"][tab] = WorkspaceContainer(
                tab_type=tab,
                title=_("section_workspace_%s" % tab, default=tab),
                marker=interfaces.IWorkspaceTab)

        ws_uc = workspace["under-consideration"] = WorkspaceSection(
            title=_(u"under consideration"),
            description=_(u"documents under consideration"),
            default_name="documents",
            marker=interfaces.IWorkspaceUnderConsideration)
        ws_uc["documents"] = WorkspaceUnderConsiderationContainer(
            name="documents",
            title=_(u"under consideration"),
            description=_(u"documents under consideration"),
            marker=interfaces.IWorkspaceTrackedDocuments)
        ws_uc["tracked-documents"] = WorkspaceTrackedDocumentsContainer(
            name="tracked documents",
            title=_(u"tracked documents"),
            description=_(u"tracked documents"))

        ws_sched = workspace["scheduling"] = Section(
            title=_("section_scheduling", default=u"Scheduling"),
            description=_(u"Workspace Scheduling"),
            default_name="index",
            marker=interfaces.IWorkspaceScheduling)
        ws_sched["committees"] = QueryContent(
            container_getter(get_chamber_for_context, "committees"),
            title=_("section_scheduling_committees", default=u"Committees"),
            #!+marker=interfaces.ICommitteeAddContext,
            description=_(u"Committee schedules"))
        ws_sched["documents"] = WorkspaceSchedulableContainer(
            name=_(u"schedulable items"),
            title=_(u"schedulable items"),
            description=_(u"documents available for scheduling"))
        ws_sched["sittings"] = QueryContent(
            container_getter(get_chamber_for_context, "sittings"),
            title=_("section_scheduling_sittings", default=u"Sittings"),
            description=_(u"Plenary Sittings"))
        ws_sched["sessions"] = QueryContent(
            container_getter(get_chamber_for_context, "sessions"),
            title=_("section_scheduling_sessions", default=u"Sessions"),
            description=_(u"Plenary Sessions"))
        ws_sched["venues"] = QueryContent(container_getter(
            get_chamber_for_context, "venues"),
                                          title=_("section_scheduling_venues",
                                                  default=u"Venues"),
                                          description=_(u"Venues"))
        ws_sched["agendaitems"] = QueryContent(
            container_getter(get_chamber_for_context, "agendaitems"),
            title=_("section_scheduling_agenda_items",
                    default=u"Agenda items"),
            #marker=interfaces.IAgendaItemAddContext,
            description=_(u"Manage agenda items"))
        ws_sched["publications"] = QueryContent(
            container_getter(get_chamber_for_context, "publications"),
            title=_("section_scheduling_publications",
                    default=u"Publications"),
            description=_(u"Publications"))

        workspace["groups"] = WorkspaceSection(
            title=_("section_groups", default=u"Groups"),
            description=_(u"Bungeni Groups"),
            default_name="my-groups",
            marker=interfaces.IWorkspaceGroups)
        workspace["groups"]["my-groups"] = WorkspaceGroupsContainer(
            name="my-groups",
            title=_(u"My Groups"),
            description=_(u"Groups that the user is a member of"))

        #!+TIMING
        #!+AUTO CONTAINERS SCHEDULING(mb, April-2012)
        # type_info missing container name
        for type_key, ti in capi.iter_type_info():
            if model_interfaces.IScheduleContent.implementedBy(
                    ti.domain_model):
                container_property_name = naming.plural(type_key)
                container_class_name = naming.container_class_name(type_key)
                if not ws_sched.has_key(container_property_name):
                    ws_sched[container_property_name] = \
                        getattr(domain, container_class_name)()
                    to_locatable_container(ti.domain_model,
                                           ws_sched[container_property_name])

        ##########
        # Admin User Interface
        # Administration section

        #!+SECURITY(miano. nov-2010) Admin section now uses AdminSection
        # container that is identical to Section, only difference is that
        # traversing though it requires zope.ManageSite permission as defined
        # in core/configure.zcml

        admin = self.context["admin"] = AdminSection(
            title=_(u"Administration"),
            description=_(u"Manage bungeni settings"),
            default_name="admin-index",
            marker=model_interfaces.IBungeniAdmin)

        content = admin["content"] = Section(
            title=_(u"Content"),
            description=_(u"browse bungeni content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="browse-admin")
        alsoProvides(content, interfaces.ISearchableSection)

        admin["email-settings"] = Section(
            title=_(u"email settings"),
            description=_(u"manage email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="email-settings")

        admin["search-settings"] = Section(
            title=_(u"search settings"),
            description=_(u"manage bungeni email settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="search-settings")

        admin["registry-settings"] = Section(
            title=_(u"registry settings"),
            description=_(u"manage registry settings"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="registry-settings")

        admin["serialization-manager"] = Section(
            title=_(u"serialization manager"),
            description=_(u"batch serialization of content"),
            marker=model_interfaces.IBungeniAdmin,
            default_name="serialization-manager")

        content[u"parliaments"] = domain.ParliamentContainer()
        to_locatable_container(domain.Parliament, content[u"parliaments"])
        content[u"governments"] = domain.GovernmentContainer()
        to_locatable_container(domain.Government, content[u"governments"])
        content[u"joint-committees"] = domain.JointCommitteeContainer()
        to_locatable_container(domain.JointCommittee,
                               content["joint-committees"])
        content[u"users"] = domain.UserContainer()
        to_locatable_container(domain.User, content[u"users"])

        api = self.context[u"api"] = APISection(
            title=_(u"Bungeni API"),
            description=_(u"Bungeni REST API"),
            default_name="index",
        )

        api[u"workspace"] = copy.deepcopy(workspace)

        api[u"users"] = copy.deepcopy(content[u"users"])

        self.context["oauth"] = OAuthSection(
            title=_(u"Bungeni OAuth API"),
            description=_(u"Bungeni OAuth API"),
            default_name="index",
        )
        admin[u"applications"] = domain.OAuthApplicationContainer()
        to_locatable_container(domain.OAuthApplication, admin[u"applications"])
コード例 #39
0
    departure = schema.Datetime(
        title=u'Departure Date/Time',
        description=u'Please input your departure date/time.',
    )

    arrival_notes = schema.Text(
        title=u'Arrival notes / Type of transport',
        description=u'Any additional information about your arrival. Type of transportation, flight information, etc',
    )

    departure_notes = schema.Text(
        title=u'Departure notes / Type of transport',
        description=u'any additional information about your departure. type of transportation, flight information, etc',
    )

alsoProvides(IEventApplication, form.IFormFieldProvider)


class EventApplication(dexterity.Container):
    """
    """
    grok.implements(IEventApplication)

    def get_applicant_fullname_and_lc(self):
        """Return member's fullname along with it's LC."""
        user = api.user.get(username=self.Creator())
        return u"%s, %s" % (user.fullname, self.get_lc_title())

    @property
    def Title(self):
        return self.get_fullname_with_lc()
コード例 #40
0
ファイル: event.py プロジェクト: eestec-patras/eestec.portal
from five import grok
from plone.directives import form, dexterity
from zope import schema
from zope.interface.declarations import alsoProvides


class IEvent(form.Schema):
    """
    """
    deadline = schema.Datetime(
        title=u'Deadline',
        description=u'Deadline to apply to this event',
        required=True,
    )

alsoProvides(IEvent, form.IFormFieldProvider)


class Event(dexterity.Container):
    """
    """
    grok.implements(IEvent)


@grok.subscribe(Event, IActionSucceededEvent)
def event_published(context, event):
    """
    Send email to CP list, notifying them that new event was published
    """
    if event.action == 'publish':
        emails.event.published_notify_cp_list(context)
コード例 #41
0
def mark_video_as_google_drive_link(context):
    """
    Mark a link as a google drive resource
    """
    alsoProvides(mark_video_link(context), IVideoLinkGoogleDrive)
    return context
コード例 #42
0
        description=u'Please input your departure date/time.',
    )

    arrival_notes = schema.Text(
        title=u'Arrival notes / Type of transport',
        description=u'Any additional information about your arrival. Type of '
                    'transportation, flight information, etc',
    )

    departure_notes = schema.Text(
        title=u'Departure notes / Type of transport',
        description=u'any additional information about your departure. type '
                    'of transportation, flight information, etc',
    )

alsoProvides(IEventApplication, form.IFormFieldProvider)


class EventApplication(dexterity.Container):
    """
    """
    grok.implements(IEventApplication)

    def get_applicant_fullname_and_lc(self):
        """Return member's fullname along with it's LC."""
        user = api.user.get(username=self.Creator())
        return u"%s, %s" % (user.fullname, self.get_lc_title())

    @property
    def Title(self):
        return self.get_fullname_with_lc()