mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 21:53:30 +00:00
resolve warnings
This commit is contained in:
parent
75bb3f992c
commit
cd58d5a357
@ -69,9 +69,7 @@ class ClubTest(TestCase):
|
||||
unix_name="fake-club",
|
||||
address="5 rue de la République, 90000 Belfort",
|
||||
)
|
||||
cls.members_url = reverse(
|
||||
"club:club_members", kwargs={"club_id": cls.club.id}
|
||||
)
|
||||
cls.members_url = reverse("club:club_members", kwargs={"club_id": cls.club.id})
|
||||
a_month_ago = now() - timedelta(days=30)
|
||||
yesterday = now() - timedelta(days=1)
|
||||
Membership.objects.create(
|
||||
@ -174,14 +172,11 @@ class MembershipQuerySetTest(ClubTest):
|
||||
# should delete the subscriptions of skia and comptable
|
||||
self.club.members.ongoing().board().delete()
|
||||
|
||||
assert (
|
||||
cache.get(f"membership_{mem_skia.club_id}_{mem_skia.user_id}")
|
||||
== "not_member"
|
||||
)
|
||||
assert (
|
||||
cache.get(f"membership_{mem_comptable.club_id}_{mem_comptable.user_id}")
|
||||
== "not_member",
|
||||
for membership in (mem_skia, mem_comptable):
|
||||
cached_mem = cache.get(
|
||||
f"membership_{membership.club_id}_{membership.user_id}"
|
||||
)
|
||||
assert cached_mem == "not_member"
|
||||
|
||||
|
||||
class ClubModelTest(ClubTest):
|
||||
|
@ -28,6 +28,7 @@ from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils import timezone
|
||||
from PIL import ExifTags
|
||||
from PIL.Image import Resampling
|
||||
|
||||
|
||||
def get_git_revision_short_hash() -> str:
|
||||
@ -109,7 +110,8 @@ def resize_image(im, edge, format):
|
||||
(w, h) = im.size
|
||||
(width, height) = scale_dimension(w, h, long_edge=edge)
|
||||
content = BytesIO()
|
||||
im = im.resize((width, height), PIL.Image.ANTIALIAS)
|
||||
# use the lanczos filter for antialiasing
|
||||
im = im.resize((width, height), Resampling.LANCZOS)
|
||||
try:
|
||||
im.save(
|
||||
fp=content,
|
||||
|
@ -2,9 +2,9 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from datetime import timezone
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -17,7 +17,9 @@ class Migration(migrations.Migration):
|
||||
field=models.DateTimeField(
|
||||
verbose_name="activity time",
|
||||
auto_now=True,
|
||||
default=datetime.datetime(2016, 8, 26, 17, 5, 31, 202824, tzinfo=utc),
|
||||
default=datetime.datetime(
|
||||
2016, 8, 26, 17, 5, 31, 202824, tzinfo=timezone.utc
|
||||
),
|
||||
),
|
||||
preserve_default=False,
|
||||
)
|
||||
|
@ -19,8 +19,8 @@ import base64
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import Optional, Tuple
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from typing import Tuple
|
||||
|
||||
from dict2xml import dict2xml
|
||||
from django.conf import settings
|
||||
@ -534,7 +534,7 @@ class Counter(models.Model):
|
||||
.order_by("-perm_sum")
|
||||
)
|
||||
|
||||
def get_top_customers(self, since: Optional[date] = None) -> QuerySet:
|
||||
def get_top_customers(self, since: datetime | date | None = None) -> QuerySet:
|
||||
"""
|
||||
Return a QuerySet querying the money spent by customers of this counter
|
||||
since the specified date, ordered by descending amount of money spent.
|
||||
@ -543,9 +543,13 @@ class Counter(models.Model):
|
||||
- the full name (first name + last name) of the customer
|
||||
- the nickname of the customer
|
||||
- the amount of money spent by the customer
|
||||
|
||||
:param since: timestamp from which to perform the calculation
|
||||
"""
|
||||
if since is None:
|
||||
since = get_start_of_semester()
|
||||
if isinstance(since, date):
|
||||
since = datetime(since.year, since.month, since.day, tzinfo=timezone.utc)
|
||||
return (
|
||||
self.sellings.filter(date__gte=since)
|
||||
.annotate(
|
||||
@ -568,19 +572,18 @@ class Counter(models.Model):
|
||||
.order_by("-selling_sum")
|
||||
)
|
||||
|
||||
def get_total_sales(self, since=None) -> CurrencyField:
|
||||
def get_total_sales(self, since: datetime | date | None = None) -> CurrencyField:
|
||||
"""
|
||||
Compute and return the total turnover of this counter
|
||||
since the date specified in parameter (by default, since the start of the current
|
||||
semester)
|
||||
:param since: timestamp from which to perform the calculation
|
||||
:type since: datetime | date | None
|
||||
:return: Total revenue earned at this counter
|
||||
"""
|
||||
if since is None:
|
||||
since = get_start_of_semester()
|
||||
if isinstance(since, date):
|
||||
since = datetime.combine(since, datetime.min.time())
|
||||
since = datetime(since.year, since.month, since.day, tzinfo=timezone.utc)
|
||||
total = self.sellings.filter(date__gte=since).aggregate(
|
||||
total=Sum(F("quantity") * F("unit_price"), output_field=CurrencyField())
|
||||
)["total"]
|
||||
|
@ -2,12 +2,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from datetime import timezone
|
||||
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -226,7 +226,9 @@ class Migration(migrations.Migration):
|
||||
"last_read_date",
|
||||
models.DateTimeField(
|
||||
verbose_name="last read date",
|
||||
default=datetime.datetime(1999, 1, 1, 0, 0, tzinfo=utc),
|
||||
default=datetime.datetime(
|
||||
1999, 1, 1, 0, 0, tzinfo=timezone.utc
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
|
@ -187,6 +187,7 @@ TEMPLATES = [
|
||||
},
|
||||
},
|
||||
]
|
||||
FORM_RENDERER = "django.forms.renderers.DjangoDivFormRenderer"
|
||||
|
||||
HAYSTACK_CONNECTIONS = {
|
||||
"default": {
|
||||
@ -248,8 +249,6 @@ TIME_ZONE = "Europe/Paris"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
LOCALE_PATHS = (os.path.join(BASE_DIR, "locale"),)
|
||||
@ -690,7 +689,6 @@ if DEBUG:
|
||||
"sith.toolbar_debug.TemplatesPanel",
|
||||
"debug_toolbar.panels.cache.CachePanel",
|
||||
"debug_toolbar.panels.signals.SignalsPanel",
|
||||
"debug_toolbar.panels.logging.LoggingPanel",
|
||||
"debug_toolbar.panels.redirects.RedirectsPanel",
|
||||
]
|
||||
SASS_INCLUDE_FOLDERS = ["core/static/"]
|
||||
|
Loading…
Reference in New Issue
Block a user