diff -r 509e30b9f5c9 -r a5719dcb742a web/ldt/ldt_utils/models.py --- a/web/ldt/ldt_utils/models.py Wed Sep 01 09:50:05 2010 +0200 +++ b/web/ldt/ldt_utils/models.py Mon Sep 06 17:00:34 2010 +0200 @@ -2,7 +2,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from ldt.core.models import Document, Owner -from utils import create_ldt, copy_ldt, create_empty_iri, update_iri +from utils import create_ldt, copy_ldt, create_empty_iri, update_iri, generate_uuid import lxml.etree import os.path import uuid @@ -19,9 +19,9 @@ class Content(models.Model): - iri_id = models.CharField(max_length=1024, unique=True) + iri_id = models.CharField(max_length=1024, unique=True, default=generate_uuid) iriurl = models.CharField(max_length=1024) - src = models.CharField(max_length=1024) + src = models.CharField(max_length=1024, null=True, blank=True) 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) @@ -30,6 +30,7 @@ external_id = models.CharField(max_length=1024, null=True, blank=True) authors = models.ManyToManyField(Author, blank=True) duration = models.IntegerField(null=True, blank=True) + content_creation_date = models.DateTimeField(null=True, blank=True) def get_duration(self): if self.duration is None: @@ -47,6 +48,7 @@ #TODO: better manage the change in .iri name and error scenario (save in temp file + rename def save(self, *args, **kwargs): + # create iri file if needed created = False try: @@ -67,6 +69,7 @@ if os.path.exists(iri_file_path): os.remove(iri_file_path) raise e + # update it super(Content, self).save(*args, **kwargs)