Skip to content

Commit

Permalink
Merge pull request #721 from ae-utbm/remove-pytz
Browse files Browse the repository at this point in the history
Remove pytz from deps
  • Loading branch information
imperosol authored Jul 20, 2024
2 parents 588a824 + e5a2236 commit a1296dc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
14 changes: 6 additions & 8 deletions counter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import json
import re
from datetime import datetime, timedelta
from datetime import timezone as tz
from http import HTTPStatus
from urllib.parse import parse_qs

import pytz
from django import forms
from django.conf import settings
from django.contrib.auth.decorators import login_required
Expand Down Expand Up @@ -1439,10 +1439,10 @@ def get_context_data(self, **kwargs):
)
else:
refillings = refillings.filter(
date__gte=datetime(year=1994, month=5, day=17, tzinfo=pytz.UTC)
date__gte=datetime(year=1994, month=5, day=17, tzinfo=tz.utc)
) # My birth date should be old enough
cashredistersummaries = cashredistersummaries.filter(
date__gte=datetime(year=1994, month=5, day=17, tzinfo=pytz.UTC)
date__gte=datetime(year=1994, month=5, day=17, tzinfo=tz.utc)
)
if form.is_valid() and form.cleaned_data["end_date"]:
refillings = refillings.filter(date__lte=form.cleaned_data["end_date"])
Expand All @@ -1464,17 +1464,15 @@ def get_context_data(self, **kwargs):
"""Add sums to the context"""
kwargs = super().get_context_data(**kwargs)
kwargs["months"] = Selling.objects.datetimes("date", "month", order="DESC")
start_date = None
end_date = None
try:
if "month" in self.request.GET:
start_date = datetime.strptime(self.request.GET["month"], "%Y-%m")
except:
else:
start_date = datetime(
year=timezone.now().year,
month=(timezone.now().month + 10) % 12 + 1,
day=1,
)
start_date = start_date.replace(tzinfo=pytz.UTC)
start_date = start_date.replace(tzinfo=tz.utc)
end_date = (start_date + timedelta(days=32)).replace(
day=1, hour=0, minute=0, microsecond=0
)
Expand Down
4 changes: 2 additions & 2 deletions forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from __future__ import annotations

from datetime import datetime
from datetime import timezone as tz
from itertools import chain

import pytz
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
Expand Down Expand Up @@ -437,7 +437,7 @@ class ForumUserInfo(models.Model):
last_read_date = models.DateTimeField(
_("last read date"),
default=datetime(
year=settings.SITH_SCHOOL_START_YEAR, month=1, day=1, tzinfo=pytz.UTC
year=settings.SITH_SCHOOL_START_YEAR, month=1, day=1, tzinfo=tz.utc
),
)

Expand Down
10 changes: 5 additions & 5 deletions launderette/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from collections import OrderedDict
from datetime import datetime, timedelta
from datetime import timezone as tz

import pytz
from django import forms
from django.conf import settings
from django.db import DataError, transaction
Expand Down Expand Up @@ -79,7 +79,7 @@ def post(self, request, *args, **kwargs):
self.subscriber = request.user
if self.subscriber.is_subscribed:
self.date = dateparse.parse_datetime(request.POST["slot"]).replace(
tzinfo=pytz.UTC
tzinfo=tz.utc
)
if self.slot_type == "WASHING":
if self.check_slot(self.slot_type):
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_context_data(self, **kwargs):
kwargs["planning"] = OrderedDict()
kwargs["slot_type"] = self.slot_type
start_date = datetime.now().replace(
hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC
hour=0, minute=0, second=0, microsecond=0, tzinfo=tz.utc
)
for date in LaunderetteBookView.date_iterator(
start_date, start_date + timedelta(days=6), timedelta(days=1)
Expand All @@ -158,7 +158,7 @@ def get_context_data(self, **kwargs):
free = True
elif self.slot_type == "DRYING" and self.check_slot("DRYING", h):
free = True
if free and datetime.now().replace(tzinfo=pytz.UTC) < h:
if free and datetime.now().replace(tzinfo=tz.utc) < h:
kwargs["planning"][date].append(h)
else:
kwargs["planning"][date].append(None)
Expand Down Expand Up @@ -393,7 +393,7 @@ def clean(self):
slot.token = t
slot.save()
t.user = subscriber
t.borrow_date = datetime.now().replace(tzinfo=pytz.UTC)
t.borrow_date = datetime.now().replace(tzinfo=tz.utc)
t.save()
price = settings.SITH_LAUNDERETTE_PRICES[t.type]
s = Selling(
Expand Down
15 changes: 1 addition & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Pillow = "^10.4.0"
mistune = "^3.0.2"
django-jinja = "^2.11"
cryptography = "^42.0.8"
pytz = "^2021.1"
djangorestframework = "^3.13"
django-phonenumber-field = "^6.3"
phonenumbers = "^8.12"
Expand Down

0 comments on commit a1296dc

Please sign in to comment.