misc: use tz-aware datetimes in logged errors (#52989)

This commit is contained in:
Frédéric Péters 2021-04-13 18:18:39 +02:00
parent 38e19faacb
commit dd0ce06123
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import datetime
from django.utils.timezone import now
from wcs.carddef import CardDef
from wcs.formdef import FormDef
@ -85,13 +85,13 @@ class LoggedError:
if status:
error.status_id = status.id
error.first_occurence_timestamp = datetime.datetime.now()
error.first_occurence_timestamp = now()
error.tech_id = error.build_tech_id()
existing_errors = list(cls.get_with_indexed_value('tech_id', error.tech_id))
if existing_errors:
error = existing_errors[0]
error.occurences_count += 1
error.latest_occurence_timestamp = datetime.datetime.now()
error.latest_occurence_timestamp = now()
error.store()
return error