def testParticipating(self): """Tests if a list of all the organizations participating in a given gci program is returned. """ expected = [] actual = organization_logic.participating(self.program) self.assertEqual(expected, actual) org1 = self.gci_program_helper.createOrg() org2 = self.gci_program_helper.createNewOrg() #We need to clear the cache with the key given below as the first call to #the function being tested sets an empty cache with the same key. key = 'participating_orgs_for' + self.program.key().name() memcache.delete(key) expected = set([org1.key(), org2.key()]) actual = organization_logic.participating(self.gci_program_helper.program) actual = set([org.key() for org in actual]) self.assertEqual(expected, set(actual))
def context(self): participating_orgs = [] current_orgs = org_logic.participating( self.data.program, org_count=self._ORG_COUNT) for org in current_orgs: link = links.LINKER.organization(org.key(), url_names.GCI_ORG_HOME) participating_orgs.append({ 'link': link, 'logo': org.logo_url, 'name': org.short_name, }) participating_orgs_table_rows = [] orgs = list(participating_orgs) while True: if not orgs: break elif len(orgs) <= self._TABLE_WIDTH: participating_orgs_table_rows.append(orgs) break else: row, orgs = orgs[:self._TABLE_WIDTH], orgs[self._TABLE_WIDTH:] participating_orgs_table_rows.append(row) # TODO(nathaniel): make this .program() call unnecessary. self.data.redirect.program() accepted_orgs_url = self.data.redirect.urlOf('gci_accepted_orgs') context = { 'participating_orgs': participating_orgs, 'participating_orgs_table_rows': participating_orgs_table_rows, 'org_list_url': accepted_orgs_url, 'all_participating_orgs': ( self.data.program.nr_accepted_orgs <= len(participating_orgs)), } if not self.data.profile: redirector = self.data.redirect redirector.program() redirector.createProfile('mentor') context['register_url'] = redirector.urlOf( url_names.GCI_PROFILE_CREATE, secure=True) return context
def context(self): r = self.data.redirect participating_orgs = [] current_orgs = org_logic.participating(self.data.program) for org in current_orgs: participating_orgs.append({ 'link': r.orgHomepage(org.link_id).url(), 'logo': org.logo_url, 'name': org.short_name, }) accepted_orgs_url = r.program().urlOf('gci_accepted_orgs') return { 'participating_orgs': participating_orgs, 'org_list_url': accepted_orgs_url, }