src/hp/forms.py
changeset 65 6289931858a7
parent 45 316a0101512e
child 83 07c9aa7de765
equal deleted inserted replaced
64:78f174d908a0 65:6289931858a7
    13 
    13 
    14 logger = logging.getLogger(__name__)
    14 logger = logging.getLogger(__name__)
    15 
    15 
    16 class VideoKCRelForm(forms.ModelForm):
    16 class VideoKCRelForm(forms.ModelForm):
    17     
    17     
    18     iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) 
    18     iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select())
       
    19     project_id =  forms.CharField(max_length=255, widget=forms.widgets.Select())
    19 
    20 
    20     def __init__(self, *args, **kwargs):
    21     def __init__(self, *args, **kwargs):
    21         super(VideoKCRelForm, self).__init__(*args, **kwargs)
    22         super(VideoKCRelForm, self).__init__(*args, **kwargs)
    22         
    23         
    23         url = settings.LDT_API_URL + "contents/?limit=" + str(settings.LDT_MAX_FETCH)
    24         url = settings.LDT_API_URL + "contents/?limit=" + str(settings.LDT_MAX_FETCH)
    24         contents = get_all_objects(url, 'front_project')
    25         contents = get_all_objects(url, 'front_project')
    25         self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents]
    26         self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents]
    26         
    27         
       
    28         url = settings.LDT_API_URL + "projects/?state=2&limit=" + str(settings.LDT_MAX_FETCH)
       
    29         projects = get_all_objects(url, None)
       
    30         logger.debug("projects " + repr(projects))
       
    31         values = [(None, "-----")]
       
    32         values.extend([(project['ldt_id'], project['title']) for project in projects])
       
    33         
       
    34         self.fields['project_id'].widget.choices = values
       
    35 
       
    36 
    27     class Meta:
    37     class Meta:
    28         model = VideoKCRel
    38         model = VideoKCRel
    29     
    39