388 (5, 'deleted') |
388 (5, 'deleted') |
389 ) |
389 ) |
390 ldt_id = models.CharField(max_length=1024, unique=True) |
390 ldt_id = models.CharField(max_length=1024, unique=True) |
391 ldt = models.TextField(null=True) |
391 ldt = models.TextField(null=True) |
392 title = models.CharField(max_length=1024) |
392 title = models.CharField(max_length=1024) |
393 contents = models.ManyToManyField(Content, through='AnnotationStat') |
393 contents = models.ManyToManyField(Content) |
394 creation_date = models.DateTimeField(auto_now_add=True) |
394 creation_date = models.DateTimeField(auto_now_add=True) |
395 modification_date = models.DateTimeField(auto_now=True) |
395 modification_date = models.DateTimeField(auto_now=True) |
396 created_by = models.CharField(_("created by"), max_length=70) |
396 created_by = models.CharField(_("created by"), max_length=70) |
397 changed_by = models.CharField(_("changed by"), max_length=70) |
397 changed_by = models.CharField(_("changed by"), max_length=70) |
398 state = models.IntegerField(choices=STATE_CHOICES, default=1) |
398 state = models.IntegerField(choices=STATE_CHOICES, default=1) |
520 if (user and user.is_staff) or self.state == 2: |
520 if (user and user.is_staff) or self.state == 2: |
521 return True |
521 return True |
522 else: |
522 else: |
523 return False |
523 return False |
524 |
524 |
525 def add_contents(self, contents): |
|
526 for content in contents: |
|
527 contribution = AnnotationStat.objects.create(project=self, content=content) |
|
528 contribution.save() |
|
529 |
|
530 def remove_contents(self, contents): |
|
531 AnnotationStat.objects.filter(project=self, content__in=contents).delete() |
|
532 |
|
533 |
|
534 class AnnotationStat(SafeModel): |
|
535 project = models.ForeignKey(Project) |
|
536 content = models.ForeignKey(Content) |
|
537 stat = models.CommaSeparatedIntegerField(max_length=1024, null=True, blank=True, verbose_name=_("content.stat_annotation")) |
|
538 nb_annotation = models.IntegerField(default=0, verbose_name=_("content.nb_annotation")) |
|
539 |
|
540 def __unicode__(self): |
|
541 return "%s::%s" % (self.project.ldt_id, self.content.iri_id) |
|
542 |
525 |
543 class Segment(SafeModel): |
526 class Segment(SafeModel): |
544 |
527 |
545 project_obj = models.ForeignKey(Project, null=True) |
528 project_obj = models.ForeignKey(Project, null=True) |
546 content = models.ForeignKey(Content) |
529 content = models.ForeignKey(Content) |
554 duration = models.IntegerField(null=True) |
537 duration = models.IntegerField(null=True) |
555 start_ts = models.IntegerField(null=True) |
538 start_ts = models.IntegerField(null=True) |
556 author = models.CharField(max_length=1024, unique=False, null=True, blank=True) |
539 author = models.CharField(max_length=1024, unique=False, null=True, blank=True) |
557 date = models.CharField(max_length=128, unique=False, null=True, blank=True) |
540 date = models.CharField(max_length=128, unique=False, null=True, blank=True) |
558 abstract = models.TextField(null=True, blank=True) |
541 abstract = models.TextField(null=True, blank=True) |
|
542 polemics = models.IntegerField(null=True, blank=True, default=0) |
559 |
543 |
560 def __unicode__(self): |
544 def __unicode__(self): |
561 return "/".join((unicode(self.project_id), unicode(self.iri_id), unicode(self.ensemble_id), unicode(self.cutting_id), unicode(self.element_id))) |
545 return "/".join((unicode(self.project_id), unicode(self.iri_id), unicode(self.ensemble_id), unicode(self.cutting_id), unicode(self.element_id))) |
562 |
546 |
563 class Meta: |
547 class Meta: |