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])