--- a/web/ldt/ldt_utils/models.py Thu Jun 10 04:16:26 2010 +0200
+++ b/web/ldt/ldt_utils/models.py Thu Jun 10 11:17:09 2010 +0200
@@ -6,6 +6,7 @@
import os
import os.path
import uuid
+import xml
class Author(models.Model):
@@ -20,14 +21,15 @@
class Content(models.Model):
iri_id = models.CharField(max_length=1024, unique=True)
- iriurl = models.URLField()
- videopath = models.URLField(null=True, blank=True)
+ iriurl = models.CharField(max_length=1024)
+ src = models.CharField(max_length=1024)
+ videopath = models.CharField(max_length=1024, null=True, blank=True)
creation_date = models.DateTimeField(auto_now_add=True)
update_date = models.DateTimeField(auto_now=True)
title = models.CharField(max_length=1024, null=True, blank=True)
description = models.TextField(null=True, blank=True)
external_id = models.CharField(max_length=1024, null=True, blank=True)
- authors = models.ManyToManyField(Author)
+ authors = models.ManyToManyField(Author, blank=True)
duration = models.IntegerField(null=True, blank=True)
def get_duration(self):
@@ -36,7 +38,7 @@
doc = Ft.Xml.Domlette.ConvertDocument(doc)
con = xml.xpath.Context.Context(doc, 1, 1, None)
res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
- self.duration = int(res[0].getAttributeNS(None, 'dur'))
+ self.duration = int(res[0].getAttributeNS(None, u'dur'))
self.save()
return self.duration
@@ -68,10 +70,10 @@
return unicode(web_url) + unicode(settings.MEDIA_URL)+u"media/ldt/"+unicode(self.iriurl)
def iri_file_path(self):
- return os.path.join(os.path.join(os.path.join(os.path.join(settings.MEDIA_ROOT, "media"), "ldt"), self.iri_id), os.path.basename(self.iri.path))
+ return os.path.join(os.path.join(os.path.join(os.path.join(settings.MEDIA_ROOT, "media"), "ldt"), self.iri_id), os.path.basename(self.iriurl))
def iri_url_template(self):
- return "${web_url}${media_url}media/ldt/" + unicode(self.iri_id) + "/" + os.path.basename(self.iri.path)
+ return "${web_url}${media_url}media/ldt/" + unicode(self.iri_id) + "/" + os.path.basename(self.iriurl)
class Project(Document):
@@ -104,7 +106,7 @@
con = xml.xpath.Context.Context(doc, 1, 1, None)
res = xml.xpath.Evaluate("/iri/project", context=con)
if len(res) > 0:
- return res[0].getAttributeNS(None, 'abstract')
+ return res[0].getAttributeNS(None, u'abstract')
else:
return None