Skip to content

Commit

Permalink
Formateo la fecha adecuadamente de AnalyticsImportTask
Browse files Browse the repository at this point in the history
mejora la legibilidad en el admin de django
  • Loading branch information
lucaslavandeira committed Dec 3, 2018
1 parent 0431ccf commit 179964e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion series_tiempo_ar_api/apps/analytics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.conf import settings
from django.db import models
from django.core.exceptions import ValidationError
from django.utils import timezone
from solo.models import SingletonModel

from series_tiempo_ar_api.apps.management.models import TaskCron
Expand Down Expand Up @@ -73,6 +74,7 @@ def save(self, *args, **kwargs):


class AnalyticsImportTask(models.Model):
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'

RUNNING = 'running'
FINISHED = 'finished'
Expand All @@ -87,11 +89,14 @@ class AnalyticsImportTask(models.Model):
timestamp = models.DateTimeField()

def __str__(self):
return "Analytics import task at {}".format(self.timestamp)
return "Analytics import task at {}".format(self._format_date(self.timestamp))

def write_logs(self, text):
if not self.logs:
self.logs = ''

self.logs += text + '\n'
self.save()

def _format_date(self, date):
return timezone.localtime(date).strftime(self.DATE_FORMAT)

0 comments on commit 179964e

Please sign in to comment.