# HG changeset patch # User verrierj # Date 1326880429 -3600 # Node ID d126a67897c0ed153b689a6c33cf514aff0852ff # Parent 35453efed7ed95ae4c42576e4669ab2bd2b97c47 Small bugfixes diff -r 35453efed7ed -r d126a67897c0 src/ldt/ldt/ldt_utils/models.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) diff -r 35453efed7ed -r d126a67897c0 src/ldt/ldt/ldt_utils/stat.py --- 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