# HG changeset patch # User ymh # Date 1354065171 -3600 # Node ID c63f2508c34d81143adcbac44d98c2835315d790 # Parent 88e08fd7a160fd9c71eda54eb4d1248487a1fe9c improve on kc rel form to avoid having all the contents in the drop down list, only those available. diff -r 88e08fd7a160 -r c63f2508c34d src/hp/__init__.py --- a/src/hp/__init__.py Tue Nov 27 01:52:43 2012 +0100 +++ b/src/hp/__init__.py Wed Nov 28 02:12:51 2012 +0100 @@ -1,4 +1,4 @@ -VERSION = (0, 9, 0, "alpha", 0) +VERSION = (0, 10, 0, "alpha", 0) VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2]))) diff -r 88e08fd7a160 -r c63f2508c34d src/hp/forms.py --- a/src/hp/forms.py Tue Nov 27 01:52:43 2012 +0100 +++ b/src/hp/forms.py Wed Nov 28 02:12:51 2012 +0100 @@ -21,14 +21,17 @@ def __init__(self, *args, **kwargs): super(VideoKCRelForm, self).__init__(*args, **kwargs) - + url = settings.LDT_API_URL + "contents/" contents = get_all_objects(url, {'limit':settings.LDT_MAX_FETCH}, 'front_project') - self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents] + + #remove contents that already are associated + associated_rel = dict([(rel.iri_id, rel) for rel in VideoKCRel.objects.all()]) + + self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents if (content['iri_id'] not in associated_rel) or (content['iri_id'] == self['iri_id'].value())] url = settings.LDT_API_URL + "projects/" projects = get_all_objects(url, {'state': 2, 'limit': settings.LDT_MAX_FETCH}, None) - logger.debug("projects " + repr(projects)) values = [(None, "-----")] values.extend([(project['ldt_id'], project['title']) for project in projects])