From d962763987562c28fed31a42ec9bdf4fe267bde1 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 14 Aug 2020 19:04:44 +0200 Subject: [PATCH] datetime.today() => date.today() --- apps/member/views.py | 6 +++--- apps/treasury/models.py | 9 +++++---- apps/wei/views.py | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index 332f0047..3375927a 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import io -from datetime import datetime, timedelta +from datetime import timedelta, date from PIL import Image from django.conf import settings @@ -151,7 +151,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): history_table.paginate(per_page=20, page=self.request.GET.get("transaction-page", 1)) context['history_list'] = history_table - club_list = Membership.objects.filter(user=user, date_end__gte=datetime.today())\ + club_list = Membership.objects.filter(user=user, date_end__gte=date.today())\ .filter(PermissionBackend.filter_queryset(self.request.user, Membership, "view")) membership_table = MembershipTable(data=club_list, prefix='membership-') membership_table.paginate(per_page=10, page=self.request.GET.get("membership-page", 1)) @@ -374,7 +374,7 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): context['history_list'] = history_table club_member = Membership.objects.filter( club=club, - date_end__gte=datetime.today(), + date_end__gte=date.today(), ).filter(PermissionBackend.filter_queryset(self.request.user, Membership, "view")) membership_table = MembershipTable(data=club_member, prefix="membership-") diff --git a/apps/treasury/models.py b/apps/treasury/models.py index 467a84bf..9e5c3584 100644 --- a/apps/treasury/models.py +++ b/apps/treasury/models.py @@ -1,6 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from datetime import datetime + +from datetime import date from django.contrib.auth.models import User from django.core.exceptions import ValidationError @@ -55,7 +56,7 @@ class Invoice(models.Model): ) date = models.DateField( - default=datetime.today, + default=date.today, verbose_name=_("Date"), ) @@ -326,7 +327,7 @@ class SogeCredit(models.Model): for transaction in self.transactions.all(): transaction.valid = True transaction._force_save = True - transaction.created_at = datetime.now() + transaction.created_at = timezone.now() transaction.save() def delete(self, **kwargs): @@ -345,7 +346,7 @@ class SogeCredit(models.Model): for transaction in self.transactions.all(): transaction._force_save = True transaction.valid = True - transaction.created_at = datetime.now() + transaction.created_at = timezone.now() transaction.save() super().delete(**kwargs) diff --git a/apps/wei/views.py b/apps/wei/views.py index ada4c5d8..74830066 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -4,7 +4,7 @@ import os import shutil import subprocess -from datetime import datetime, date, timedelta +from datetime import date, timedelta from tempfile import mkdtemp from django.contrib.auth.mixins import LoginRequiredMixin @@ -119,7 +119,7 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): club_member = WEIMembership.objects.filter( club=club, - date_end__gte=datetime.today(), + date_end__gte=date.today(), ).filter(PermissionBackend.filter_queryset(self.request.user, WEIMembership, "view")) membership_table = WEIMembershipTable(data=club_member, prefix="membership-") membership_table.paginate(per_page=20, page=self.request.GET.get('membership-page', 1))