mirror of
https://github.com/ae-utbm/sith.git
synced 2026-04-30 10:36:03 +00:00
resolve warnings
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import datetime
|
||||
from typing import Any
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.timezone import get_current_timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import User
|
||||
@@ -60,6 +62,15 @@ class AlbumEditForm(forms.ModelForm):
|
||||
Album.objects.all(), required=True, widget=AutoCompleteSelectAlbum
|
||||
)
|
||||
|
||||
def clean_date(self):
|
||||
album_date: datetime.date = self.cleaned_data["date"]
|
||||
return datetime.datetime(
|
||||
year=album_date.year,
|
||||
month=album_date.month,
|
||||
day=album_date.day,
|
||||
tzinfo=get_current_timezone(),
|
||||
)
|
||||
|
||||
|
||||
class PictureModerationRequestForm(forms.ModelForm):
|
||||
"""Form to create a PictureModerationRequest.
|
||||
|
||||
@@ -220,7 +220,7 @@ class TestAlbumEdit:
|
||||
data = {
|
||||
"name": album.name[: Album.NAME_MAX_LENGTH],
|
||||
"parent": baker.make(Album, parent=album.parent, is_moderated=True).pk,
|
||||
"date": localdate().strftime("%Y-%m-%d"),
|
||||
"date": localdate(),
|
||||
"file": "/random/path",
|
||||
"edit_groups": [settings.SITH_GROUP_SAS_ADMIN_ID],
|
||||
"recursive": False,
|
||||
@@ -232,7 +232,7 @@ class TestAlbumEdit:
|
||||
data = {
|
||||
"name": album.name[: Album.NAME_MAX_LENGTH],
|
||||
"parent": album.pk,
|
||||
"date": localdate().strftime("%Y-%m-%d"),
|
||||
"date": localdate(),
|
||||
}
|
||||
assert AlbumEditForm(data=data).is_valid()
|
||||
|
||||
@@ -245,7 +245,7 @@ class TestAlbumEdit:
|
||||
payload = {
|
||||
"name": album.name[: Album.NAME_MAX_LENGTH],
|
||||
"parent": album.pk,
|
||||
"date": localdate().strftime("%Y-%m-%d"),
|
||||
"date": localdate(),
|
||||
}
|
||||
response = client.post(
|
||||
reverse("sas:album_edit", kwargs={"album_id": album.pk}), payload
|
||||
@@ -284,7 +284,7 @@ class TestAlbumEdit:
|
||||
payload = {
|
||||
"name": album.name[: Album.NAME_MAX_LENGTH],
|
||||
"parent": parent().id,
|
||||
"date": localdate().strftime("%Y-%m-%d"),
|
||||
"date": localdate(),
|
||||
"recursive": False,
|
||||
}
|
||||
response = client.post(
|
||||
|
||||
Reference in New Issue
Block a user