def test_getOrganizationByIDJSON(self): ''' Test getOrganizationByID method ''' ''' Validate first organization entries ''' jsonify = json.loads(controllers.getOrganizationByIDJSON(1)) org = controllers.extractOrganizationFromDict(jsonify) self.assertIsNotNone(org) self.assertEqual(org.entityFK, 1) self.assertEquals(org.name, 'Ai-Kon') self.assertEquals(org.description, 'Ai-Kon Anime Convention') self.assertEquals(org.entity.type, models.TYPE_ORGANIZATION) self.assertEquals(org.entity.addresses[0].address1, '123 Vroom Street') self.assertEquals(org.entity.addresses[0].address2, None) self.assertEquals(org.entity.addresses[0].address3, None) self.assertEquals(org.entity.addresses[0].city, 'Winnipeg') self.assertEquals(org.entity.addresses[0].province, 'Manitoba') self.assertEquals(org.entity.addresses[0].country, 'Canada') self.assertEquals(org.entity.addresses[0].postalcode, 'A1A1A1') self.assertEquals(org.entity.addresses[0].isprimary, True) self.assertEquals(org.entity.contacts[0].type, models.TYPE_EMAIL) self.assertEquals(org.entity.contacts[0].value, '*****@*****.**') self.assertEquals(org.entity.contacts[0].isprimary, True) ''' Validate second organization entries ''' jsonify = json.loads(controllers.getOrganizationByIDJSON(2)) org = controllers.extractOrganizationFromDict(jsonify) self.assertIsNotNone(org) self.assertEquals(org.entityFK, 2) self.assertEquals(org.name, 'University of Manitoba') self.assertEquals(org.description, 'The University of Manitoba, is a public university in the province of Manitoba, Canada. Located in Winnipeg, it is Manitoba\'s largest, most comprehensive, and only research-intensive post-secondary educational institution.') self.assertEquals(org.entity.type, models.TYPE_ORGANIZATION) self.assertEquals(org.entity.addresses[0].address1, '66 Chancellors Circle') self.assertEquals(org.entity.addresses[0].address2, None) self.assertEquals(org.entity.addresses[0].address3, None) self.assertEquals(org.entity.addresses[0].city, 'Winnipeg') self.assertEquals(org.entity.addresses[0].province, 'Manitoba') self.assertEquals(org.entity.addresses[0].country, 'Canada') self.assertEquals(org.entity.addresses[0].postalcode, 'R3T2N2') self.assertEquals(org.entity.addresses[0].isprimary, True) self.assertEquals(org.entity.contacts[0].type, models.TYPE_PHONE) self.assertEquals(org.entity.contacts[0].value, '18004321960') self.assertEquals(org.entity.contacts[0].isprimary, True) ''' Attempt an invalid organization ''' org = controllers.getOrganizationByIDJSON(3) self.assertIsNone(org)
def org_info(entityid): data = controllers.getOrganizationByIDJSON(entityid) if data == None: data = entityid return render_template('org_404.html', data=data) if request.method == 'GET' and is_request_json(): return Response(response=data, status=200, mimetype='application/json') else: return render_template('org_info.html', org=json.loads(data))
def getEventsByOrg(org_id): try: eventListJSON = controller_events.getEventsByOrgJSON(org_id) eventListDict = json.loads(eventListJSON) org = controllers.getOrganizationByIDJSON(org_id) org_dict = json.loads(org) if is_request_json(): return jsonify(eventListDict, Organization=org_dict) except Exception, e: return abort(404)
def privilege_org(org_id): try: user_id = current_user.entityFK if request.method == 'GET': persons = controllers.getPeopleInOrganizationJSON(org_id) persons_dict = json.loads(persons); org = controllers.getOrganizationByIDJSON(org_id) org_dict = json.loads(org); if is_request_json(): return jsonify(persons_dict, Organization=org_dict) except Exception, e: return abort(404)