--- a/src/hp/__init__.py Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/__init__.py Tue Nov 27 01:48:15 2012 +0100
@@ -1,4 +1,4 @@
-VERSION = (0, 8, 0, "alpha", 0)
+VERSION = (0, 9, 0, "alpha", 0)
VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
--- a/src/hp/forms.py Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/forms.py Tue Nov 27 01:48:15 2012 +0100
@@ -10,13 +10,14 @@
from .utils import get_all_objects
from django import forms
import logging
+import requests
logger = logging.getLogger(__name__)
class VideoKCRelForm(forms.ModelForm):
iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select())
- project_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)
@@ -32,7 +33,19 @@
values.extend([(project['ldt_id'], project['title']) for project in projects])
self.fields['project_id'].widget.choices = values
+
+ self.fields['content_title'].widget.attrs['readonly'] = True
+ def clean_content_title(self):
+ iri_id = self.cleaned_data['iri_id']
+ url = settings.LDT_API_URL + "contents/%s/" % iri_id
+
+ 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))
+ raise forms.ValidationError("Unable to request content %s" % url)
+ return r.json.get('title', None)
+
class Meta:
model = VideoKCRel
--- a/src/hp/locale/en/LC_MESSAGES/django.po Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/locale/en/LC_MESSAGES/django.po Tue Nov 27 01:48:15 2012 +0100
@@ -7,7 +7,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-26 17:04+0100\n"
+"POT-Creation-Date: 2012-11-27 01:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,14 +21,18 @@
msgstr "Content id"
#: models.py:14
+msgid "content.title"
+msgstr "Content title"
+
+#: models.py:15
msgid "project_id"
msgstr "project id"
-#: models.py:15
+#: models.py:16
msgid "graph_id"
msgstr "Graph id"
-#: models.py:16
+#: models.py:17
msgid "topic_id"
msgstr "Topic id"
--- a/src/hp/locale/fr/LC_MESSAGES/django.po Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/locale/fr/LC_MESSAGES/django.po Tue Nov 27 01:48:15 2012 +0100
@@ -7,7 +7,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-26 17:04+0100\n"
+"POT-Creation-Date: 2012-11-27 01:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -22,14 +22,18 @@
msgstr "Id contenu"
#: models.py:14
+msgid "content.title"
+msgstr "Titre contenu"
+
+#: models.py:15
msgid "project_id"
msgstr "Id projet"
-#: models.py:15
+#: models.py:16
msgid "graph_id"
msgstr "Id graphe"
-#: models.py:16
+#: models.py:17
msgid "topic_id"
msgstr "Id topic"
--- a/src/hp/locale/ja/LC_MESSAGES/django.po Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/locale/ja/LC_MESSAGES/django.po Tue Nov 27 01:48:15 2012 +0100
@@ -7,7 +7,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-26 17:04+0100\n"
+"POT-Creation-Date: 2012-11-27 01:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -22,14 +22,18 @@
msgstr "Content"
#: models.py:14
+msgid "content.title"
+msgstr "Content title"
+
+#: models.py:15
msgid "project_id"
msgstr "LDT Project"
-#: models.py:15
+#: models.py:16
msgid "graph_id"
msgstr "KC Project id"
-#: models.py:16
+#: models.py:17
msgid "topic_id"
msgstr "Topic id"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hp/migrations/0003_auto__add_field_videokcrel_content_title.py Tue Nov 27 01:48:15 2012 +0100
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from south.db import db
+from south.v2 import SchemaMigration
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'VideoKCRel.content_title'
+ db.add_column('hp_videokcrel', 'content_title', #@UndefinedVariable
+ self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'VideoKCRel.content_title'
+ db.delete_column('hp_videokcrel', 'content_title') #@UndefinedVariable
+
+
+ models = {
+ 'hp.videokcrel': {
+ 'Meta': {'object_name': 'VideoKCRel'},
+ 'content_title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'graph_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'iri_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'project_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'topic_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
+ }
+ }
+
+ complete_apps = ['hp']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hp/migrations/0004_kc_rel_query_content_title.py Tue Nov 27 01:48:15 2012 +0100
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+from south.v2 import DataMigration
+from hp.utils import get_all_objects
+from hp import settings
+
+class Migration(DataMigration):
+
+ def forwards(self, orm):
+ url = settings.LDT_API_URL + "contents/"
+ contents = get_all_objects(url, {'limit':settings.LDT_MAX_FETCH}, None)
+
+ title_dict = dict([(c.get('iri_id',''), c.get('title','')) for c in contents])
+
+ for rel in orm.VideoKCRel.objects.all():
+ rel.content_title = title_dict.get(rel.iri_id,None)
+ rel.save()
+
+ def backwards(self, orm):
+ for rel in orm.VideoKCRel.objects.all():
+ rel.content_title = None
+ rel.save()
+
+ models = {
+ 'hp.videokcrel': {
+ 'Meta': {'object_name': 'VideoKCRel'},
+ 'content_title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'graph_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'iri_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'project_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'topic_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
+ }
+ }
+
+ complete_apps = ['hp']
+ symmetrical = True
--- a/src/hp/models.py Mon Nov 26 23:58:04 2012 +0100
+++ b/src/hp/models.py Tue Nov 27 01:48:15 2012 +0100
@@ -11,11 +11,12 @@
class VideoKCRel(models.Model):
iri_id = models.CharField(max_length=255, unique=True, verbose_name=_('content.iri_id'))
+ content_title = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('content.title'))
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'))
def __unicode__(self):
- return u"%s->%s|%s" %(self.iri_id,self.graph_id, self.topic_id)
+ return u"%s->%s|%s" %(self.content_title if self.content_title else self.iri_id,self.graph_id, self.topic_id)