mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add more Ruff rules (#891)
* ruff: apply rule F * ruff: apply rule E * ruff: apply rule SIM * ruff: apply rule TCH * ruff: apply rule ERA * ruff: apply rule PLW * ruff: apply rule FLY * ruff: apply rule PERF * ruff: apply rules FURB & RUF
This commit is contained in:
@ -30,7 +30,7 @@ from core.utils import get_start_of_semester
|
||||
|
||||
|
||||
def validate_type(value):
|
||||
if value not in settings.SITH_SUBSCRIPTIONS.keys():
|
||||
if value not in settings.SITH_SUBSCRIPTIONS:
|
||||
raise ValidationError(_("Bad subscription type"))
|
||||
|
||||
|
||||
@ -107,7 +107,9 @@ class Subscription(models.Model):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def compute_start(d: date = None, duration: int = 1, user: User = None) -> date:
|
||||
def compute_start(
|
||||
d: date | None = None, duration: int = 1, user: User | None = None
|
||||
) -> date:
|
||||
"""Computes the start date of the subscription.
|
||||
|
||||
The computation is done with respect to the given date (default is today)
|
||||
@ -129,7 +131,9 @@ class Subscription(models.Model):
|
||||
return get_start_of_semester(d)
|
||||
|
||||
@staticmethod
|
||||
def compute_end(duration: int, start: date = None, user: User = None) -> date:
|
||||
def compute_end(
|
||||
duration: int, start: date | None = None, user: User | None = None
|
||||
) -> date:
|
||||
"""Compute the end date of the subscription.
|
||||
|
||||
Args:
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from subscription.views import *
|
||||
from subscription.views import NewSubscription, SubscriptionsStatsView
|
||||
|
||||
urlpatterns = [
|
||||
# Subscription views
|
||||
|
@ -94,11 +94,13 @@ class SubscriptionForm(forms.ModelForm):
|
||||
self.errors.pop("email", None)
|
||||
self.errors.pop("date_of_birth", None)
|
||||
if cleaned_data.get("member") is None:
|
||||
# This should be handled here, but it is done in the Subscription model's clean method
|
||||
# This should be handled here,
|
||||
# but it is done in the Subscription model's clean method
|
||||
# TODO investigate why!
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You must either choose an existing user or create a new one properly"
|
||||
"You must either choose an existing "
|
||||
"user or create a new one properly"
|
||||
)
|
||||
)
|
||||
return cleaned_data
|
||||
@ -114,7 +116,7 @@ class NewSubscription(CreateView):
|
||||
raise PermissionDenied
|
||||
|
||||
def get_initial(self):
|
||||
if "member" in self.request.GET.keys():
|
||||
if "member" in self.request.GET:
|
||||
return {
|
||||
"member": self.request.GET["member"],
|
||||
"subscription_type": "deux-semestres",
|
||||
|
Reference in New Issue
Block a user