コード例 #1
0
    def finish(self):
        self.applySteps(self.context)
        sqlalsession = Session()
        sqlalsession.flush()
        organization = self.session["organization"]
        canonical_id = self.session["canonical_id"]
        if organization.organization_id:
            sqlalsession.merge(organization)
        else:
            sqlalsession.add(organization)
            if canonical_id:
                # flush required for organization.organization_id creation
                sqlalsession.flush()
                assoc = Association(association_type="lang")
                assoc.translated_id = organization.organization_id
                assoc.canonical_id = canonical_id
                sqlalsession.add(assoc)

        from cirb.organizations.traversal import OrganizationWrapper

        # transaction.commit()
        self.request.SESSION.clear()
        orga_page = "{0}/organizations_manage".format(self.context.absolute_url())
        if isinstance(self.context, OrganizationWrapper):
            orga_page = "{0}/organizations_manage".format(self.context.__parent__.__parent__.absolute_url())
        self.request.response.redirect(orga_page)
コード例 #2
0
def add_test_organisations_in_db(logger):
    # TODO check if table exists
    engine = component.getUtility(IEngineFactory, name="gscetterbeek")()
    ORMBase.metadata.create_all(engine)

    session = Session()
    if len(session.query(Organization).all()) < 1:

        addr = Address(street='avenue des arts', num='21', post_code='1000', municipality='Bruxelles')
        cat = Category(music=True, welcome=True, other="god")
        incharge = InCharge(title="Sir", first_name="Benoit", second_name="Suttor")
        contact_addr = Address(street='contact street', num='7', post_code='1001', municipality='Brux')
        contact = Contact(title="Monsieur", first_name="James", second_name="Bond", phone="007/11.11.11", fax="00", email="*****@*****.**", address=contact_addr)
        addinfo = AdditionalInformation(objectif="objectifs de l'association", comments="mon comm")
        # TODO add logo
        orga = Organization(name='CIRB', 
                address=addr, 
                person_incharge=incharge,
                person_contact=contact, 
                category=cat,
                additionalinfo=addinfo,
                status=u"asbl", 
                language=u"fr", 
                website="http://www.cirb.irisnet.be",
                x="150041",
                y="170633")
        addr2 = Address(street='kunststraat', num='21', post_code='1000', municipality='Brussel')
        cat2 = Category(music=True, welcome=True, other="god")
        incharge2 = InCharge(title="Sir", first_name="Benoit", second_name="Suttor")
        contact_addr2 = Address(street='contact street', num='7', post_code='1000', municipality='Brux')
        contact2 = Contact(title="double zero", first_name="Bond", second_name="James", phone="007/11.11.11", fax="00", email="*****@*****.**", address=contact_addr2)
        addinfo2 = AdditionalInformation(objectif="objectifs de l'association", comments="mon comm")

        orga2 = Organization(name='CIBG', 
                address=addr2, 
                person_incharge=incharge2,
                person_contact=contact2, 
                category=cat2, 
                additionalinfo=addinfo2,
                status=u"asbl", 
                language=u"nl", 
                website="http://www.cibg.irisnet.be",
                x="150041",
                y="170633")

        session.add(orga)
        session.add(orga2)
        session.flush()

        assoc = Association(association_type = "lang")
        assoc.translated_id = orga2.organization_id
        assoc.canonical_id = orga.organization_id 
        session.add(assoc)
        transaction.commit()
    else:
        logger.info('There are already some organizations in DB.')
コード例 #3
0
    def test_translation(self):
        session = Session()
        session.add(Organization(name=u"Vin", language="fr"))
        session.add(Organization(name=u"Wijn", language="nl"))
        self.assertEqual(len(session.query(Organization).all()), 2)

        assoc = Association(association_type="lang")
        [orgafr, organl] = [orga for orga in session.query(Organization).all()]
        assoc.translated_id = organl.organization_id
        assoc.canonical_id = orgafr.organization_id
        session.add(assoc)
        self.assertEqual(orgafr, organl.get_translation())
        self.assertEqual(orgafr.get_translation().name, u"Wijn")
        self.assertEqual(organl.get_translation().name, u"Vin")
コード例 #4
0
ファイル: traversal.py プロジェクト: CIRB/cirb.organizations
 def addTranslation(self, language):
     organization = Organization(address=Address(), category=Category(),
                                 person_incharge=InCharge(), person_contact=Contact(),
                                 additionalinfo=AdditionalInformation())
     organization.person_contact.address = Address()
     organization.name = self._organization.name
     organization.language = language
     session = Session()
     session.add(organization)
     session.flush()
     canonical_id = self.getId()
     assoc = Association(association_type="lang")
     assoc.translated_id = organization.organization_id
     assoc.canonical_id = canonical_id
     session.add(assoc)
     session.flush()