Browse Source

Show author and created date on the project list page

pull/1985/head
Hironsan 2 years ago
parent
commit
0466b4725b
5 changed files with 23 additions and 4 deletions
  1. 12
      backend/projects/serializers.py
  2. 7
      frontend/components/project/ProjectList.vue
  3. 2
      frontend/domain/models/project/project.ts
  4. 2
      frontend/repositories/project/apiProjectRepository.ts
  5. 4
      frontend/services/application/project/projectData.ts

12
backend/projects/serializers.py

@ -49,6 +49,13 @@ class TagSerializer(serializers.ModelSerializer):
class ProjectSerializer(serializers.ModelSerializer):
tags = TagSerializer(many=True, required=False)
author = serializers.SerializerMethodField()
@classmethod
def get_author(cls, instance):
if instance.created_by:
return instance.created_by.username
return ""
class Meta:
model = Project
@ -58,9 +65,10 @@ class ProjectSerializer(serializers.ModelSerializer):
"description",
"guideline",
"project_type",
"created_at",
"updated_at",
"random_order",
"created_by",
"author",
"collaborative_annotation",
"single_class_classification",
"is_text_project",
@ -71,7 +79,9 @@ class ProjectSerializer(serializers.ModelSerializer):
"tags",
]
read_only_fields = (
"created_at",
"updated_at",
"author",
"is_text_project",
"can_define_label",
"can_define_relation",

7
frontend/components/project/ProjectList.vue

@ -34,9 +34,9 @@
<span>{{ item.name }}</span>
</nuxt-link>
</template>
<template #[`item.updatedAt`]="{ item }">
<template #[`item.createdAt`]="{ item }">
<span>{{
item.updatedAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm')
item.createdAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm')
}}</span>
</template>
<template #[`item.tags`]="{ item }">
@ -93,7 +93,8 @@ export default Vue.extend({
{ text: this.$t('generic.name'), value: 'name' },
{ text: this.$t('generic.description'), value: 'description' },
{ text: this.$t('generic.type'), value: 'projectType' },
{ text: 'Updated', value: 'updatedAt' },
{ text: 'Created', value: 'createdAt' },
{ text: 'Author', value: 'author' },
{ text: 'Tags', value: 'tags' }
]
}

2
frontend/domain/models/project/project.ts

@ -18,7 +18,9 @@ export class ProjectReadItem {
readonly users: number[],
readonly tags: Object[],
readonly projectType: ProjectType,
readonly createdAt: string,
readonly updatedAt: string,
readonly author: string,
readonly randomOrder: boolean,
readonly collaborativeAnnotation: boolean,
readonly exclusiveCategories: boolean,

2
frontend/repositories/project/apiProjectRepository.ts

@ -11,7 +11,9 @@ function toModel(item: { [key: string]: any }): ProjectReadItem {
item.users,
item.tags,
item.project_type,
item.created_at,
item.updated_at,
item.author,
item.random_order,
item.collaborative_annotation,
item.single_class_classification,

4
frontend/services/application/project/projectData.ts

@ -6,7 +6,9 @@ export class ProjectDTO {
description: string
guideline: string
projectType: ProjectType
createdAt: string
updatedAt: string
author: string
enableRandomOrder: boolean
enableShareAnnotation: boolean
singleClassClassification: boolean
@ -29,7 +31,9 @@ export class ProjectDTO {
this.description = item.description
this.guideline = item.guideline
this.projectType = item.projectType
this.createdAt = item.createdAt
this.updatedAt = item.updatedAt
this.author = item.author
this.enableRandomOrder = item.randomOrder
this.enableShareAnnotation = item.collaborativeAnnotation
this.singleClassClassification = item.exclusiveCategories

Loading…
Cancel
Save