Debug messages

This commit is contained in:
har0ke 2019-08-21 00:56:26 +02:00
parent 8e42920ced
commit 0d58e0d5a5
2 changed files with 14 additions and 3 deletions

View File

@ -77,7 +77,10 @@ class InvoiceDependencies(object):
def set_may_have_changed(self, kwargs):
inventory_ids = set([i.pk for i in self.get_related_invoices() if i])
Inventory.objects.filter(pk__in=inventory_ids, may_have_changed=False).update(may_have_changed=True)
if inventory_ids:
if settings.DEBUG:
print("May have changed: " + str(inventory_ids))
Inventory.objects.filter(pk__in=inventory_ids, may_have_changed=False).update(may_have_changed=True)
def delete(self, *args, **kwargs):
assert isinstance(self, models.Model) and isinstance(self, InvoiceDependencies)

View File

@ -1,14 +1,22 @@
import trace
import traceback
from datetime import datetime
from django.conf.urls import url
from tallybill import settings
from . import views
def time_measure(view):
def _wrapper(*args, **kwargs):
b = datetime.now()
ret = view(*args, **kwargs)
print("View '%s' took %.2fms" % (view.__name__, (datetime.now() - b).total_seconds() * 1000.))
try:
ret = view(*args, **kwargs)
except Exception as e:
print(traceback.format_exc(100, e))
raise e
if settings.DEBUG:
print("View '%s' took %.2fms" % (view.__name__, (datetime.now() - b).total_seconds() * 1000.))
return ret
return _wrapper