Merge pull request #706 from ae-utbm/ruff-rules

Add more ruff rules
This commit is contained in:
thomas girod
2024-07-08 15:42:22 +02:00
committed by GitHub
260 changed files with 1071 additions and 1394 deletions

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2022
# - Maréchal <thgirod@hotmail.com

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2022
# - Maréchal <thgirod@hotmail.com

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import django.db.models.deletion

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr
@ -57,6 +56,9 @@ class Basket(models.Model):
)
date = models.DateTimeField(_("date"), auto_now=True)
def __str__(self):
return f"{self.user}'s basket ({self.items.all().count()} items)"
def add_product(self, p: Product, q: int = 1):
"""
Given p an object of the Product model and q an integer,
@ -208,9 +210,6 @@ class Basket(models.Model):
data.append(("PBX_HMAC", pbx_hmac.hexdigest().upper()))
return data
def __str__(self):
return "%s's basket (%d items)" % (self.user, self.items.all().count())
class Invoice(models.Model):
"""
@ -227,6 +226,9 @@ class Invoice(models.Model):
date = models.DateTimeField(_("date"), auto_now=True)
validated = models.BooleanField(_("validated"), default=False)
def __str__(self):
return f"{self.user} - {self.get_total()} - {self.date}"
def get_total(self) -> float:
total = self.items.aggregate(
total=Sum(F("quantity") * F("product_unit_price"))
@ -269,9 +271,6 @@ class Invoice(models.Model):
self.validated = True
self.save()
def __str__(self):
return "%s - %s - %s" % (self.user, self.get_total(), self.date)
class AbstractBaseItem(models.Model):
product_id = models.IntegerField(_("product id"))

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2016,2017
# - Skia <skia@libskia.so>

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*
#
# Skia < skia AT libskia DOT so >
#

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2016,2017, 2022
# - Skia <skia@libskia.so>

View File

@ -1,4 +1,3 @@
# -*- coding:utf-8 -*
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr