Small bugfixes
authorverrierj
Wed, 18 Jan 2012 10:53:49 +0100
changeset 411 d126a67897c0
parent 410 35453efed7ed
child 412 8d777b1d1d92
Small bugfixes
src/ldt/ldt/ldt_utils/models.py
src/ldt/ldt/ldt_utils/stat.py
--- a/src/ldt/ldt/ldt_utils/models.py	Wed Jan 18 10:52:51 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/models.py	Wed Jan 18 10:53:49 2012 +0100
@@ -365,7 +365,7 @@
             admin = User.objects.filter(is_superuser=True)[0]
             
         set_current_user(admin)
-        self.front_project = Project.create_project(admin, 'front project : %s' % self.title, [self], cuttings=['chapitrage', 'contribution'] )
+        self.front_project = Project.create_project(admin, 'front project : %s' % self.title, [self], cuttings=['chapitrage', 'contributions'] )
         self.front_project.publish(allow_write=True)
         set_current_user(request_user)
             
--- a/src/ldt/ldt/ldt_utils/stat.py	Wed Jan 18 10:52:51 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/stat.py	Wed Jan 18 10:53:49 2012 +0100
@@ -1,5 +1,5 @@
 from django.conf import settings
-from ldt.ldt_utils.models import AnnotationStat, Project
+from ldt.ldt_utils.models import AnnotationStat, Project, Segment
 from django.db.models.signals import pre_delete
 import lxml.etree
 import datetime
@@ -14,11 +14,11 @@
         doc = lxml.etree.fromstring(project.ldt)
 
     number_division = settings.DIVISIONS_FOR_STAT_ANNOTATION
-    contributions = AnnotationStat.objects.filter(project=project)    
+    contributions = list(AnnotationStat.objects.filter(project=project))    
         
     for content_node in doc.xpath('/iri/annotations/content'):
         content_name = content_node.get('id')
-        content = contents.filter(iri_id=content_name)
+        content = filter_list(contents, 'iri_id', content_name)
         
         # if the content referenced in the xml belongs to the
         # fields contents of the project
@@ -121,7 +121,7 @@
     content.last_annotated = datetime.datetime.now()
     content.save()    
 
-
+import uuid
 def add_annotation_to_stat(content, project, begin, end):
     contribution_project = AnnotationStat.objects.get(project=project, content=content)
     
@@ -131,6 +131,20 @@
         contribution_project.nb_annotation += 1
     content.nb_annotation += 1
     
+    print "before segment creation"
+    s = Segment(project_obj=project,
+                content=content,
+                project_id=project.ldt_id,
+                iri_id=content.iri_id,
+                ensemble_id='%s' % unicode(uuid.uuid1()),
+                cutting_id='t',    
+                element_id='a',
+                duration=end-begin,
+                start_ts=begin)
+    s.save()
+    print s.id
+    print "segment created"
+    
     if contribution_project.stat:
         
         number_division = settings.DIVISIONS_FOR_STAT_ANNOTATION
@@ -147,7 +161,12 @@
     content.last_annotated = datetime.datetime.now()
     content.save()
     contribution_project.save()
-
     
 
-    
\ No newline at end of file
+def filter_list(list, criteria, value):
+    new_list = []
+    for l in list:
+        if getattr(l, criteria) == value:
+            new_list.append(l)
+    
+    return new_list
\ No newline at end of file