From d4ce8bbf237ae8e8755a91266e5ebc98f0b9e481 Mon Sep 17 00:00:00 2001 From: Macartur Sousa Date: Tue, 24 Nov 2015 11:36:53 -0200 Subject: [PATCH] Adding kwargs in colab.plugins.models and changed timestamp method --- colab/plugins/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/colab/plugins/models.py b/colab/plugins/models.py index 618c193..a7d70b0 100644 --- a/colab/plugins/models.py +++ b/colab/plugins/models.py @@ -1,5 +1,5 @@ from django.db import models -from datetime import datetime +from django.utils.timezone import datetime class TimeStampPlugin(models.Model): @@ -11,9 +11,15 @@ class TimeStampPlugin(models.Model): timestamp = models.DateTimeField(default=datetime.min, blank=True) @classmethod - def update_timestamp(cls, class_name): + def update_timestamp(cls, class_name, **kwargs): instance = TimeStampPlugin.objects.filter(name=class_name)[0] - instance.timestamp = datetime.now() + last_updated = kwargs.get('last_updated', '') + + if last_updated: + instance.timestamp = datetime.strptime(last_updated, + "%Y/%m/%d %H:%M:%S") + else: + instance.timestamp = datetime.now() instance.save() @classmethod -- libgit2 0.21.2