improve on kc rel form to avoid having all the contents in the drop down list, only those available.
--- 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])))
--- 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])