Skip to content

Commit

Permalink
Update date and phase labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Oct 13, 2024
1 parent 7219a97 commit c748374
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion daiquiri/contact/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.template.loader import render_to_string
from django.template.defaultfilters import date

Expand Down Expand Up @@ -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', {
Expand Down
4 changes: 2 additions & 2 deletions daiquiri/query/assets/js/query/components/job/JobOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const JobOverview = ({ job, loadForm }) => {
<dl className="row mb-0">
<dt className="col-sm-4 text-end">{gettext('Job status')}</dt>
<dd className="col-sm-8 mb-0">
<span className={jobPhaseBadge[job.phase]}>{job.phase}</span>
<span className={jobPhaseBadge[job.phase]}>{job.phase_label}</span>
</dd>

{
Expand All @@ -86,7 +86,7 @@ const JobOverview = ({ job, loadForm }) => {
<dd className="col-sm-8 mb-0"><code>{job.id}</code></dd>

<dt className="col-sm-4 text-end">{gettext('Time submitted')}</dt>
<dd className="col-sm-8 mb-0">{job.creation_time}</dd>
<dd className="col-sm-8 mb-0">{job.creation_time_label}</dd>

{
job.queue && (
Expand Down
23 changes: 23 additions & 0 deletions daiquiri/query/serializers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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',
Expand All @@ -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', [])
Expand Down

0 comments on commit c748374

Please sign in to comment.