Add timestamps to task result model
This commit is contained in:
parent
6a6009e7f2
commit
b8893e92d7
2 changed files with 35 additions and 1 deletions
|
@ -0,0 +1,31 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.1 on 2016-01-09 14:24
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import django.utils.timezone
|
||||||
|
import model_utils.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('taskresults', '0002_auto_20151011_2248'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='taskresult',
|
||||||
|
options={'ordering': ['created'], 'verbose_name': 'Task result', 'verbose_name_plural': 'Task results'},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='taskresult',
|
||||||
|
name='created',
|
||||||
|
field=model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='taskresult',
|
||||||
|
name='modified',
|
||||||
|
field=model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -10,6 +10,8 @@ from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from gnuviechadmin.celery import app
|
from gnuviechadmin.celery import app
|
||||||
|
|
||||||
|
from model_utils.models import TimeStampedModel
|
||||||
|
|
||||||
|
|
||||||
class TaskResultManager(models.Manager):
|
class TaskResultManager(models.Manager):
|
||||||
def create_task_result(self, creator, signature, notes=''):
|
def create_task_result(self, creator, signature, notes=''):
|
||||||
|
@ -22,7 +24,7 @@ class TaskResultManager(models.Manager):
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class TaskResult(models.Model):
|
class TaskResult(TimeStampedModel):
|
||||||
task_id = models.CharField(_('Task id'), max_length=36)
|
task_id = models.CharField(_('Task id'), max_length=36)
|
||||||
signature = models.TextField(_('Task signature'))
|
signature = models.TextField(_('Task signature'))
|
||||||
creator = models.TextField(_('Task creator'))
|
creator = models.TextField(_('Task creator'))
|
||||||
|
@ -36,6 +38,7 @@ class TaskResult(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Task result')
|
verbose_name = _('Task result')
|
||||||
verbose_name_plural = _('Task results')
|
verbose_name_plural = _('Task results')
|
||||||
|
ordering = ['created']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{creator} ({task_id}): {finished}".format(
|
return "{creator} ({task_id}): {finished}".format(
|
||||||
|
|
Loading…
Reference in a new issue