From 5b71cb34d1ec7a92210a019c53b1f1aed0173ff8 Mon Sep 17 00:00:00 2001 From: Tom Searle Date: Fri, 26 Apr 2024 17:19:40 +0100 Subject: [PATCH] CU-8693xmvd9: last_modified in the project model Is updated when: - AnnotatedEntity is updated - MetaAnnotation is created /updated - RelationAnnotation is created / updated --- webapp/api/api/models.py | 17 +++++++++++++++++ webapp/frontend/src/views/Home.vue | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/webapp/api/api/models.py b/webapp/api/api/models.py index 80307df8..85d6fe13 100644 --- a/webapp/api/api/models.py +++ b/webapp/api/api/models.py @@ -105,6 +105,7 @@ class Project(PolymorphicModel): "outlininng a guide for annotators to follow for this project," "an example is available here: https://docs.google.com/document/d/1xxelBOYbyVzJ7vLlztP2q1Kw9F5Vr1pRwblgrXPS7QM/edit?usp=sharing") create_time = models.DateTimeField(auto_now_add=True) + last_modified = models.DateTimeField(auto_now=True) members = models.ManyToManyField(settings.AUTH_USER_MODEL) dataset = models.ForeignKey('Dataset', on_delete=models.CASCADE) validated_documents = models.ManyToManyField(Document, default=None, blank=True) @@ -155,6 +156,11 @@ class EntityRelation(models.Model): class Meta: ordering = ['id'] + def save(self, *args, **kwargs): + super().save(*args, **kwargs) + self.project.last_modified = self.last_modified + self.project.save() + def __str__(self): return f'{self.start_entity} - {self.relation} - {self.end_entity}' @@ -182,6 +188,11 @@ class AnnotatedEntity(models.Model): class Meta: ordering = ['id'] + def save(self, *args, **kwargs): + super().save(*args, **kwargs) + self.project.last_modified = self.last_modified + self.project.save() + def __str__(self): return str(self.entity) @@ -243,6 +254,12 @@ class MetaAnnotation(models.Model): meta_task_value = models.ForeignKey('MetaTaskValue', on_delete=models.CASCADE) acc = models.FloatField(default=1) validated = models.BooleanField(default=False) + last_modified = models.DateTimeField(auto_now=True) + + def save(self, *args, **kwargs): + super().save(*args, **kwargs) + self.annotated_entity.last_modified = self.last_modified + self.annotated_entity.save() def __str__(self): return str(self.annotated_entity) diff --git a/webapp/frontend/src/views/Home.vue b/webapp/frontend/src/views/Home.vue index 37ff8277..e39bffac 100644 --- a/webapp/frontend/src/views/Home.vue +++ b/webapp/frontend/src/views/Home.vue @@ -72,6 +72,9 @@ + @@ -190,11 +193,12 @@ export default { { key: 'name', label: 'Title', sortable: true }, { key: 'description', label: 'Description' }, { key: 'create_time', label: 'Create Time', sortable: true }, + { key: 'last_modified', label: 'Last Modified', sortable: true }, { key: 'cuis', label: 'Concepts' }, { key: 'require_entity_validation', label: 'Annotate / Validate' }, { key: 'status', label: 'Status', sortable: true }, { key: 'progress', label: 'Progress', formatter: this.progressFormatter }, - { key: 'anno_class', label: 'Annotation Classification'}, + { key: 'anno_class', label: 'Annotation Classification', sortable: true }, { key: 'cdb_search_filter', label: 'Concepts Imported' }, { key: 'model_loaded', label: 'Model Loaded' }, { key: 'metrics', label: 'Metrics' },