From 4f107ad4643a9b14b6394ee9cd82e31a3a65b646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Wed, 27 Oct 2021 16:27:03 +0200 Subject: [PATCH] Cleaning up things --- server/src/uds/core/util/stats/events.py | 9 ++++----- server/src/uds/reports/lists/users.py | 12 +++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/server/src/uds/core/util/stats/events.py b/server/src/uds/core/util/stats/events.py index e15edf82..23c68d72 100644 --- a/server/src/uds/core/util/stats/events.py +++ b/server/src/uds/core/util/stats/events.py @@ -151,10 +151,10 @@ def getEvents( Returns: A generator, that contains pairs of (stamp, value) tuples """ - from uds.models import NEVER + from uds.models import NEVER_UNIX, getSqlDatetimeAsUnix - since = kwargs.get('since', NEVER) - to = kwargs.get('to', datetime.datetime.now()) + since = kwargs.get('since', NEVER_UNIX) + to = kwargs.get('to', getSqlDatetimeAsUnix()) type_ = type(obj) if kwargs.get('all', False): @@ -165,7 +165,7 @@ def getEvents( for i in StatsManager.manager().getEvents( __transDict[type_], eventType, owner_id=owner_id, since=since, to=to ): - val = ( + yield ( datetime.datetime.fromtimestamp(i.stamp), i.fld1, i.fld2, @@ -173,4 +173,3 @@ def getEvents( i.fld4, i.event_type, ) - yield val diff --git a/server/src/uds/reports/lists/users.py b/server/src/uds/reports/lists/users.py index 5db1a7c5..53081c14 100644 --- a/server/src/uds/reports/lists/users.py +++ b/server/src/uds/reports/lists/users.py @@ -52,11 +52,6 @@ logger = logging.getLogger(__name__) class ListReportUsers(ListReport): filename = 'users.pdf' - def initialize(self, values): - if values: - auth = Authenticator.objects.get(uuid=self.authenticator.value) - self.filename = auth.name + '.pdf' - authenticator = gui.ChoiceField( label=_("Authenticator"), order=1, @@ -68,6 +63,11 @@ class ListReportUsers(ListReport): description = _('List users of platform') # Report description uuid = '8cd1cfa6-ed48-11e4-83e5-10feed05884b' + def initialize(self, values): + if values: + auth = Authenticator.objects.get(uuid=self.authenticator.value) + self.filename = auth.name + '.pdf' + def initGui(self) -> None: logger.debug('Initializing gui') vals = [gui.choiceItem(v.uuid, v.name) for v in Authenticator.objects.all()] @@ -116,8 +116,6 @@ class ListReportsUsersCSV(ListReportUsers): for v in users: writer.writerow([v.name, v.real_name, v.last_access]) - # writer.writerow(['ñoño', 'ádios', 'hola']) - return output.getvalue().encode()