This commit is contained in:
dependabot[bot] 2023-05-11 12:08:53 +00:00 committed by GitHub
commit 7ef7d8d642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 27 deletions

View File

@ -209,12 +209,13 @@ class Club(models.Model):
cache.set(f"sith_club_{self.unix_name}", self)
def delete(self, *args, **kwargs):
super().delete(*args, **kwargs)
# Invalidate the cache of this club and of its memberships
for membership in self.members.ongoing().select_related("user"):
cache.delete(f"membership_{self.id}_{membership.user.id}")
cache.delete(f"sith_club_{self.unix_name}")
super().delete(*args, **kwargs)
def __str__(self):
return self.name

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.18 on 2023-05-10 12:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("core", "0037_auto_20211105_1708"),
]
operations = [
migrations.AlterField(
model_name="preferences",
name="receive_weekmail",
field=models.BooleanField(
default=False, verbose_name="receive the Weekmail"
),
),
]

View File

@ -40,6 +40,7 @@ from core.views import (
CanEditPropMixin,
can_view,
)
from core.views.forms import MultipleFileField
from counter.models import Counter
@ -83,8 +84,7 @@ class AddFilesForm(forms.Form):
folder_name = forms.CharField(
label=_("Add a new folder"), max_length=30, required=False
)
file_field = forms.FileField(
widget=forms.ClearableFileInput(attrs={"multiple": True}),
file_field = MultipleFileField(
label=_("Files"),
required=False,
)

View File

@ -31,7 +31,8 @@ from django.urls import reverse
from django.core.exceptions import ValidationError
from django.forms import (
CheckboxSelectMultiple,
Select,
ClearableFileInput,
FileField,
DateInput,
TextInput,
DateTimeInput,
@ -59,6 +60,24 @@ from PIL import Image
# Widgets
class MultipleFileInput(ClearableFileInput):
allow_multiple_selected = True
class MultipleFileField(FileField):
def __init__(self, *args, **kwargs):
kwargs.setdefault("widget", MultipleFileInput())
super().__init__(*args, **kwargs)
def clean(self, data, initial=None):
single_file_clean = super().clean
if isinstance(data, (list, tuple)):
result = [single_file_clean(d, initial) for d in data]
else:
result = single_file_clean(data, initial)
return result
class SelectDateTime(DateTimeInput):
def render(self, name, value, attrs=None, renderer=None):
if attrs:

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-05-10 12:57
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("counter", "0020_auto_20221215_1709"),
]
operations = [
migrations.RenameField(
model_name="cashregistersummaryitem",
old_name="check",
new_name="checked",
),
]

View File

@ -990,7 +990,7 @@ class CashRegisterSummaryItem(models.Model):
)
value = CurrencyField(_("value"))
quantity = models.IntegerField(_("quantity"), default=0)
check = models.BooleanField(_("check"), default=False)
checked = models.BooleanField(_("check"), default=False)
class Meta:
verbose_name = _("cash register summary item")
@ -998,7 +998,7 @@ class CashRegisterSummaryItem(models.Model):
class Eticket(models.Model):
"""
Eticket can be linked to a product an allows PDF generation
Eticket can be linked to a product and allows PDF generation
"""
product = models.OneToOneField(

View File

@ -1199,35 +1199,35 @@ class CashRegisterSummaryForm(forms.Form):
cash_summary=summary,
value=cd["check_1_value"],
quantity=cd["check_1_quantity"],
check=True,
checked=True,
).save()
if cd["check_2_quantity"]:
CashRegisterSummaryItem(
cash_summary=summary,
value=cd["check_2_value"],
quantity=cd["check_2_quantity"],
check=True,
checked=True,
).save()
if cd["check_3_quantity"]:
CashRegisterSummaryItem(
cash_summary=summary,
value=cd["check_3_value"],
quantity=cd["check_3_quantity"],
check=True,
checked=True,
).save()
if cd["check_4_quantity"]:
CashRegisterSummaryItem(
cash_summary=summary,
value=cd["check_4_value"],
quantity=cd["check_4_quantity"],
check=True,
checked=True,
).save()
if cd["check_5_quantity"]:
CashRegisterSummaryItem(
cash_summary=summary,
value=cd["check_5_value"],
quantity=cd["check_5_quantity"],
check=True,
checked=True,
).save()
if summary.items.count() < 1:
summary.delete()

View File

@ -0,0 +1,27 @@
# Generated by Django 3.2.18 on 2023-05-10 12:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("pedagogy", "0002_auto_20190827_2251"),
]
operations = [
migrations.AlterField(
model_name="uv",
name="language",
field=models.CharField(
choices=[
("FR", "French"),
("EN", "English"),
("DE", "German"),
("SP", "Spanish"),
],
default="FR",
max_length=10,
verbose_name="language",
),
),
]

60
poetry.lock generated
View File

@ -66,6 +66,35 @@ files = [
{file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
]
[[package]]
name = "backports-zoneinfo"
version = "0.2.1"
description = "Backport of the standard library zoneinfo module"
category = "main"
optional = false
python-versions = ">=3.6"
files = [
{file = "backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc"},
{file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722"},
{file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546"},
{file = "backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl", hash = "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08"},
{file = "backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl", hash = "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7"},
{file = "backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac"},
{file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf"},
{file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570"},
{file = "backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl", hash = "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b"},
{file = "backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582"},
{file = "backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987"},
{file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1"},
{file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9"},
{file = "backports.zoneinfo-0.2.1-cp38-cp38-win32.whl", hash = "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328"},
{file = "backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl", hash = "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6"},
{file = "backports.zoneinfo-0.2.1.tar.gz", hash = "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2"},
]
[package.extras]
tzdata = ["tzdata"]
[[package]]
name = "black"
version = "23.3.0"
@ -383,20 +412,21 @@ tests = ["noseofyeti[black] (==2.4.1)", "pytest (==7.2.1)"]
[[package]]
name = "django"
version = "3.2.18"
description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design."
version = "4.2.1"
description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design."
category = "main"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.8"
files = [
{file = "Django-3.2.18-py3-none-any.whl", hash = "sha256:4d492d9024c7b3dfababf49f94511ab6a58e2c9c3c7207786f1ba4eb77750706"},
{file = "Django-3.2.18.tar.gz", hash = "sha256:08208dfe892eb64fff073ca743b3b952311104f939e7f6dae954fe72dcc533ba"},
{file = "Django-4.2.1-py3-none-any.whl", hash = "sha256:066b6debb5ac335458d2a713ed995570536c8b59a580005acb0732378d5eb1ee"},
{file = "Django-4.2.1.tar.gz", hash = "sha256:7efa6b1f781a6119a10ac94b4794ded90db8accbe7802281cd26f8664ffed59c"},
]
[package.dependencies]
asgiref = ">=3.3.2,<4"
pytz = "*"
sqlparse = ">=0.2.2"
asgiref = ">=3.6.0,<4"
"backports.zoneinfo" = {version = "*", markers = "python_version < \"3.9\""}
sqlparse = ">=0.3.1"
tzdata = {version = "*", markers = "sys_platform == \"win32\""}
[package.extras]
argon2 = ["argon2-cffi (>=19.1.0)"]
@ -1562,6 +1592,18 @@ files = [
{file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"},
]
[[package]]
name = "tzdata"
version = "2023.3"
description = "Provider of IANA time zone data"
category = "main"
optional = false
python-versions = ">=2"
files = [
{file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"},
{file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"},
]
[[package]]
name = "urllib3"
version = "1.26.13"
@ -1640,4 +1682,4 @@ testing = ["coverage"]
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
content-hash = "5069f58a9ba4b47c16b08e1a4191b0d2be68c20163300fc550b41d68c8e26d73"
content-hash = "62779938876fae9173b98825487730281115c4138c3ce31941104c60b62de4b0"

View File

@ -20,7 +20,7 @@ license = "GPL-3.0-only"
[tool.poetry.dependencies]
python = "^3.8"
Django = "^3.2"
Django = "^4.2"
Pillow = "^9.2"
mistune = "^0.8.4"
django-jinja = "^2.10"

View File

@ -17,7 +17,6 @@
from django.shortcuts import redirect
from django.http import HttpResponse, Http404
from django.urls import reverse_lazy, reverse
from core.views.forms import SelectDate
from django.views.generic import DetailView, TemplateView
from django.views.generic.edit import UpdateView, FormMixin, FormView
from django.utils.translation import gettext_lazy as _
@ -31,6 +30,7 @@ from ajax_select.fields import AutoCompleteSelectMultipleField
from core.views import CanViewMixin, CanEditMixin
from core.views.files import send_file, FileView
from core.views.forms import MultipleFileField, SelectDate
from core.models import SithFile, User, Notification, RealGroup
from sas.models import Picture, Album, PeoplePictureRelation
@ -40,11 +40,7 @@ class SASForm(forms.Form):
album_name = forms.CharField(
label=_("Add a new album"), max_length=30, required=False
)
images = forms.ImageField(
widget=forms.ClearableFileInput(attrs={"multiple": True}),
label=_("Upload images"),
required=False,
)
images = MultipleFileField(label=_("Upload images"), required=False)
def process(self, parent, owner, files, automodere=False):
try: