From c748374e02cb18e47970b32dd08ca26de98904a1 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Sun, 13 Oct 2024 19:02:33 +0200 Subject: [PATCH] Update date and phase labels --- daiquiri/contact/serializers.py | 3 ++- .../js/query/components/job/JobOverview.js | 4 ++-- daiquiri/query/serializers.py | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/daiquiri/contact/serializers.py b/daiquiri/contact/serializers.py index 00048548..ca2429a7 100644 --- a/daiquiri/contact/serializers.py +++ b/daiquiri/contact/serializers.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.template.loader import render_to_string from django.template.defaultfilters import date @@ -32,7 +33,7 @@ def get_status_label(self, obj): return dict(ContactMessage.STATUS_CHOICES)[obj.status] def get_created_label(self, obj): - return date(obj.created) + return date(obj.created, settings.DATETIME_FORMAT) def get_mailto(self, obj): return render_to_string('contact/messages_mailto.html', { diff --git a/daiquiri/query/assets/js/query/components/job/JobOverview.js b/daiquiri/query/assets/js/query/components/job/JobOverview.js index 78b7e041..860a878e 100644 --- a/daiquiri/query/assets/js/query/components/job/JobOverview.js +++ b/daiquiri/query/assets/js/query/components/job/JobOverview.js @@ -67,7 +67,7 @@ const JobOverview = ({ job, loadForm }) => {
{gettext('Job status')}
- {job.phase} + {job.phase_label}
{ @@ -86,7 +86,7 @@ const JobOverview = ({ job, loadForm }) => {
{job.id}
{gettext('Time submitted')}
-
{job.creation_time}
+
{job.creation_time_label}
{ job.queue && ( diff --git a/daiquiri/query/serializers.py b/daiquiri/query/serializers.py index a54fb66b..0c52220f 100644 --- a/daiquiri/query/serializers.py +++ b/daiquiri/query/serializers.py @@ -1,3 +1,5 @@ +from django.conf import settings +from django.template.defaultfilters import date from django.template.loader import get_template, TemplateDoesNotExist from rest_framework import serializers @@ -77,6 +79,11 @@ class Meta: class QueryJobRetrieveSerializer(serializers.ModelSerializer): + phase_label = serializers.SerializerMethodField() + creation_time_label = serializers.SerializerMethodField() + start_time_label = serializers.SerializerMethodField() + end_time_label = serializers.SerializerMethodField() + sources = serializers.SerializerMethodField() columns = serializers.SerializerMethodField() @@ -86,9 +93,13 @@ class Meta: 'id', 'run_id', 'phase', + 'phase_label', 'creation_time', + 'creation_time_label', 'start_time', + 'start_time_label', 'end_time', + 'end_time_label', 'execution_duration', 'time_queue', 'time_query', @@ -108,6 +119,18 @@ class Meta: 'columns' ) + def get_phase_label(self, obj): + return dict(QueryJob.PHASE_CHOICES)[obj.phase] + + def get_creation_time_label(self, obj): + return date(obj.creation_time, settings.DATETIME_FORMAT) + + def get_start_time_label(self, obj): + return date(obj.start_time, settings.DATETIME_FORMAT) + + def get_end_time_label(self, obj): + return date(obj.end_time, settings.DATETIME_FORMAT) + def get_sources(self, obj): if obj.metadata: return obj.metadata.get('sources', [])