def setup_organisations_minimal(): for organisation in default_minimal_organisations: inserted_organisation = dqorganisations.addOrganisation( organisation) if inserted_organisation is False: inserted_organisation = dqorganisations.organisations( organisation['organisation_code']) thepackage = models.Package.query.filter_by( package_name=organisation['package_name'] ).first() organisationpackage_data = { "organisation_id": inserted_organisation.id, "package_id": thepackage.id, "condition": organisation["condition"] } dqorganisations.addOrganisationPackage(organisationpackage_data)
def setup_organisations_minimal(): for organisation in default_minimal_organisations: inserted_organisation = dqorganisations.addOrganisation(organisation) if inserted_organisation is False: inserted_organisation = dqorganisations.organisations(organisation["organisation_code"]) thepackage = models.Package.query.filter_by(package_name=organisation["package_name"]).first() if thepackage is None: print "Organisation lookup failure", organisation raise ValueError organisationpackage_data = { "organisation_id": inserted_organisation.id, "package_id": thepackage.id, "condition": organisation["condition"], } dqorganisations.addOrganisationPackage(organisationpackage_data)
def importManualPackages(organisation_code, filename, prefix_url): with file(filename) as fh: packages = unicodecsv.DictReader(fh) organisation = dqorganisations.organisations(organisation_code) for package in packages: data = { 'package_name': "manual_" + package['package_name'], 'package_title': package['package_title'], 'source_url': prefix_url + package['filename'], 'man_auto': 'man', 'active': True } print "Adding package", package["package_name"] newp = addPackage(data) if newp: dqorganisations.addOrganisationPackage({ 'organisation_id': organisation.id, 'package_id': newp.id, 'condition': None }) print "Success"