def populate_choices(self, component_list): self.choices = [('*', 'All Components')] self.component_list = component_list for comp in unique(self.component_list, lambda x: x[1]): name = comp[1] self.choices.append((slugify(name), name)) self.initial = self.choices[0][0]
def components(request, os_release, associate, component_field): dajax = Dajax() db = pyfaf.storage.getDatabase() os_releases = [] os_release_id = distro_release_id(db, *split_distro_release(os_release)) if os_release_id != -1: os_releases.append(os_release_id) out = "<option value='*'>All Components</option>" for component in unique(components_list(db, os_releases, None if '*' == associate else [int(associate)]), lambda x: x[1]): out += "<option value='%s'>%s</option>\n" % (slugify(component[1]), component[1]) dajax.assign('#id_%s' % (component_field), 'innerHTML', out) return dajax.json()