src/hp/forms.py
author ymh <ymh.work@gmail.com>
Thu, 15 Nov 2012 04:11:59 +0100
changeset 45 316a0101512e
parent 41 b6010b3d6ea8
child 65 6289931858a7
permissions -rw-r--r--
add pagination new ldt version

# -*- coding: utf-8 -*-
'''
Created on Nov 14, 2012

@author: ymh
'''

from . import settings
from .models import VideoKCRel
from .utils import get_all_objects
from django import forms
import logging

logger = logging.getLogger(__name__)

class VideoKCRelForm(forms.ModelForm):
    
    iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) 

    def __init__(self, *args, **kwargs):
        super(VideoKCRelForm, self).__init__(*args, **kwargs)
        
        url = settings.LDT_API_URL + "contents/?limit=" + str(settings.LDT_MAX_FETCH)
        contents = get_all_objects(url, 'front_project')
        self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents]
        
    class Meta:
        model = VideoKCRel