Use dt.now everywhere. By @samuel-w

Fixes #185
This commit is contained in:
Samuel Woon 2020-09-04 07:09:11 -05:00 committed by GitHub
parent db9e5bdf3c
commit d98c3d46e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import json
import os import os
import sys import sys
from datetime import datetime, timedelta from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta as rd
import peewee as pw import peewee as pw
from playhouse.migrate import SqliteMigrator, migrate from playhouse.migrate import SqliteMigrator, migrate
@ -26,6 +27,7 @@ class JSONField(pw.TextField):
From: https://gist.github.com/rosscdh/f4f26758b0228f475b132c688f15af2b From: https://gist.github.com/rosscdh/f4f26758b0228f475b132c688f15af2b
""" """
def db_value(self, value): def db_value(self, value):
"""Convert the python value for storage in the database.""" """Convert the python value for storage in the database."""
return value if value is None else json.dumps(value) return value if value is None else json.dumps(value)
@ -38,7 +40,7 @@ class JSONField(pw.TextField):
class RepoModel(pw.Model): class RepoModel(pw.Model):
"""A single remote repo with unique URL.""" """A single remote repo with unique URL."""
url = pw.CharField(unique=True) url = pw.CharField(unique=True)
added_at = pw.DateTimeField(default=datetime.utcnow) added_at = pw.DateTimeField(default=datetime.now)
encryption = pw.CharField(null=True) encryption = pw.CharField(null=True)
unique_size = pw.IntegerField(null=True) unique_size = pw.IntegerField(null=True)
unique_csize = pw.IntegerField(null=True) unique_csize = pw.IntegerField(null=True)
@ -177,6 +179,7 @@ class SettingsModel(pw.Model):
class BackupProfileMixin: class BackupProfileMixin:
"""Extend to support multiple profiles later.""" """Extend to support multiple profiles later."""
def profile(self): def profile(self):
return BackupProfileModel.get(id=self.window().current_profile.id) return BackupProfileModel.get(id=self.window().current_profile.id)
@ -366,5 +369,5 @@ def init_db(con=None):
s.save() s.save()
# Delete old log entries after 3 months. # Delete old log entries after 3 months.
three_months_ago = datetime.now() - timedelta(days=180) three_months_ago = datetime.now() - rd(months=3)
EventLogModel.delete().where(EventLogModel.start_time < three_months_ago) EventLogModel.delete().where(EventLogModel.start_time < three_months_ago)

View File

@ -12,7 +12,6 @@ from vorta.views.tree_view import TreeModel
uifile = get_asset("UI/extractdialog.ui") uifile = get_asset("UI/extractdialog.ui")
ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile) ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile)
ISO_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
class ExtractDialog(ExtractDialogBase, ExtractDialogUI): class ExtractDialog(ExtractDialogBase, ExtractDialogUI):