Commit d4ce8bbf237ae8e8755a91266e5ebc98f0b9e481
1 parent
36c52218
Exists in
master
and in
4 other branches
Adding kwargs in colab.plugins.models and changed timestamp method
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
colab/plugins/models.py
1 | from django.db import models | 1 | from django.db import models |
2 | -from datetime import datetime | 2 | +from django.utils.timezone import datetime |
3 | 3 | ||
4 | 4 | ||
5 | class TimeStampPlugin(models.Model): | 5 | class TimeStampPlugin(models.Model): |
@@ -11,9 +11,15 @@ class TimeStampPlugin(models.Model): | @@ -11,9 +11,15 @@ class TimeStampPlugin(models.Model): | ||
11 | timestamp = models.DateTimeField(default=datetime.min, blank=True) | 11 | timestamp = models.DateTimeField(default=datetime.min, blank=True) |
12 | 12 | ||
13 | @classmethod | 13 | @classmethod |
14 | - def update_timestamp(cls, class_name): | 14 | + def update_timestamp(cls, class_name, **kwargs): |
15 | instance = TimeStampPlugin.objects.filter(name=class_name)[0] | 15 | instance = TimeStampPlugin.objects.filter(name=class_name)[0] |
16 | - instance.timestamp = datetime.now() | 16 | + last_updated = kwargs.get('last_updated', '') |
17 | + | ||
18 | + if last_updated: | ||
19 | + instance.timestamp = datetime.strptime(last_updated, | ||
20 | + "%Y/%m/%d %H:%M:%S") | ||
21 | + else: | ||
22 | + instance.timestamp = datetime.now() | ||
17 | instance.save() | 23 | instance.save() |
18 | 24 | ||
19 | @classmethod | 25 | @classmethod |