# HG changeset patch # User ymh # Date 1353087231 -3600 # Node ID 6289931858a772f6b4ac66269a35342f3d43f790 # Parent 78f174d908a04cf09e093c0d6ebd7d5f41c6d8de add a project property to override the front project. diff -r 78f174d908a0 -r 6289931858a7 src/hp/forms.py --- a/src/hp/forms.py Fri Nov 16 17:38:24 2012 +0100 +++ b/src/hp/forms.py Fri Nov 16 18:33:51 2012 +0100 @@ -15,7 +15,8 @@ class VideoKCRelForm(forms.ModelForm): - iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) + iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) + project_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) def __init__(self, *args, **kwargs): super(VideoKCRelForm, self).__init__(*args, **kwargs) @@ -24,6 +25,15 @@ contents = get_all_objects(url, 'front_project') self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in contents] + url = settings.LDT_API_URL + "projects/?state=2&limit=" + str(settings.LDT_MAX_FETCH) + projects = get_all_objects(url, None) + logger.debug("projects " + repr(projects)) + values = [(None, "-----")] + values.extend([(project['ldt_id'], project['title']) for project in projects]) + + self.fields['project_id'].widget.choices = values + + class Meta: model = VideoKCRel \ No newline at end of file diff -r 78f174d908a0 -r 6289931858a7 src/hp/models.py --- a/src/hp/models.py Fri Nov 16 17:38:24 2012 +0100 +++ b/src/hp/models.py Fri Nov 16 18:33:51 2012 +0100 @@ -11,6 +11,7 @@ class VideoKCRel(models.Model): iri_id = models.CharField(max_length=255, unique=True, verbose_name=_('content.iri_id')) + project_id = models.CharField(max_length=255, unique=False, verbose_name=_('project_id'), null=True, blank=True) graph_id = models.CharField(max_length=1024, verbose_name=_('graph_id')) topic_id = models.CharField(max_length=1024, verbose_name=_('topic_id')) diff -r 78f174d908a0 -r 6289931858a7 src/hp/utils.py --- a/src/hp/utils.py Fri Nov 16 17:38:24 2012 +0100 +++ b/src/hp/utils.py Fri Nov 16 18:33:51 2012 +0100 @@ -24,13 +24,15 @@ def get_all_objects(res_url, field_filter): - contents = [] + objects = [] url = res_url while url: r = requests.get(url) if r.status_code != requests.codes.ok: #@UndefinedVariable - logger.error("Error when requesting contents " + repr(r.status_code) + " : " + repr(r.text)) + logger.error("Error when requesting objects " + repr(r.status_code) + " : " + repr(r.text)) break - contents.extend([ c for c in r.json['objects'] if c.get(field_filter, None) ]) + objects.extend([ c for c in r.json['objects'] if field_filter is None or c.get(field_filter, None) ]) url = get_abs_url(r.json.get('meta',{}).get('next',None), settings.LDT_NETLOC) - return contents + return objects + + diff -r 78f174d908a0 -r 6289931858a7 src/hp/views.py --- a/src/hp/views.py Fri Nov 16 17:38:24 2012 +0100 +++ b/src/hp/views.py Fri Nov 16 18:33:51 2012 +0100 @@ -55,12 +55,6 @@ logger.debug(r_content.text) content = r_content.json - project_url = content['front_project'] - project_path = urlparse.urlparse(project_url).path - project_id = "" - if project_path: - project_path_parts = project_path.split("/") - project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2] kc_id = None topic_id = None @@ -70,6 +64,15 @@ if len(kc_relation_list) > 0: kc_id = kc_relation_list[0].graph_id topic_id = kc_relation_list[0].topic_id + project_id = kc_relation_list[0].project_id + + if not project_id: + project_url = content['front_project'] + project_path = urlparse.urlparse(project_url).path + project_id = "" + if project_path: + project_path_parts = project_path.split("/") + project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2] return render_to_response( 'hp/video_player.html', diff -r 78f174d908a0 -r 6289931858a7 virtualenv/res/lib/lib_create_env.py --- a/virtualenv/res/lib/lib_create_env.py Fri Nov 16 17:38:24 2012 +0100 +++ b/virtualenv/res/lib/lib_create_env.py Fri Nov 16 18:33:51 2012 +0100 @@ -49,7 +49,7 @@ 'PYYAML' : {'setup':'pyyaml', 'url':'http://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.10.tar.gz', 'local': 'PyYAML-3.10.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'django-tastypie-0.9.11-modified.tar.gz', 'local': 'django-tastypie-0.9.11-modified.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, - 'LDT': {'setup': 'ldt','url': 'ldt-1.30.tar.gz', 'local':"ldt-1.30.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'LDT': {'setup': 'ldt','url': 'ldt-1.31.tar.gz', 'local':"ldt-1.31.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, } if system_str == 'Windows': diff -r 78f174d908a0 -r 6289931858a7 virtualenv/res/src/ldt-1.30.tar.gz Binary file virtualenv/res/src/ldt-1.30.tar.gz has changed diff -r 78f174d908a0 -r 6289931858a7 virtualenv/res/src/ldt-1.31.tar.gz Binary file virtualenv/res/src/ldt-1.31.tar.gz has changed