-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from ae-utbm/taiste
More ruff rules, mistune update and more bot-blocking features
- Loading branch information
Showing
276 changed files
with
2,449 additions
and
2,549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding:utf-8 -* | ||
# | ||
# Copyright 2023 © AE UTBM | ||
# [email protected] / [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding:utf-8 -* | ||
# | ||
# Copyright 2023 © AE UTBM | ||
# [email protected] / [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
import django.core.validators | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
import phonenumber_field.modelfields | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding:utf-8 -* | ||
# | ||
# Copyright 2023 © AE UTBM | ||
# [email protected] / [email protected] | ||
|
@@ -37,11 +36,11 @@ class CurrencyField(models.DecimalField): | |
def __init__(self, *args, **kwargs): | ||
kwargs["max_digits"] = 12 | ||
kwargs["decimal_places"] = 2 | ||
super(CurrencyField, self).__init__(*args, **kwargs) | ||
super().__init__(*args, **kwargs) | ||
|
||
def to_python(self, value): | ||
try: | ||
return super(CurrencyField, self).to_python(value).quantize(Decimal("0.01")) | ||
return super().to_python(value).quantize(Decimal("0.01")) | ||
except AttributeError: | ||
return None | ||
|
||
|
@@ -62,6 +61,15 @@ class Company(models.Model): | |
class Meta: | ||
verbose_name = _("company") | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:co_edit", kwargs={"co_id": self.id}) | ||
|
||
def get_display_name(self): | ||
return self.name | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -88,15 +96,6 @@ def can_be_viewed_by(self, user): | |
return True | ||
return False | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:co_edit", kwargs={"co_id": self.id}) | ||
|
||
def get_display_name(self): | ||
return self.name | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
class BankAccount(models.Model): | ||
name = models.CharField(_("name"), max_length=30) | ||
|
@@ -113,6 +112,12 @@ class Meta: | |
verbose_name = _("Bank account") | ||
ordering = ["club", "name"] | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:bank_details", kwargs={"b_account_id": self.id}) | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -126,12 +131,6 @@ def is_owned_by(self, user): | |
return True | ||
return False | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:bank_details", kwargs={"b_account_id": self.id}) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
class ClubAccount(models.Model): | ||
name = models.CharField(_("name"), max_length=30) | ||
|
@@ -152,6 +151,12 @@ class Meta: | |
verbose_name = _("Club account") | ||
ordering = ["bank_account", "name"] | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:club_details", kwargs={"c_account_id": self.id}) | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -189,12 +194,6 @@ def has_open_journal(self): | |
def get_open_journal(self): | ||
return self.journals.filter(closed=False).first() | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:club_details", kwargs={"c_account_id": self.id}) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def get_display_name(self): | ||
return _("%(club_account)s on %(bank_account)s") % { | ||
"club_account": self.name, | ||
|
@@ -225,6 +224,12 @@ class Meta: | |
verbose_name = _("General journal") | ||
ordering = ["-start_date"] | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:journal_details", kwargs={"j_id": self.id}) | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -250,12 +255,6 @@ def can_be_edited_by(self, user): | |
def can_be_viewed_by(self, user): | ||
return self.club_account.can_be_viewed_by(user) | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:journal_details", kwargs={"j_id": self.id}) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
def update_amounts(self): | ||
self.amount = 0 | ||
self.effective_amount = 0 | ||
|
@@ -357,14 +356,26 @@ class Meta: | |
unique_together = ("number", "journal") | ||
ordering = ["-number"] | ||
|
||
def __str__(self): | ||
return f"{self.amount} € | {self.date} | {self.accounting_type} | {self.done}" | ||
|
||
def save(self, *args, **kwargs): | ||
if self.number is None: | ||
self.number = self.journal.operations.count() + 1 | ||
super().save(*args, **kwargs) | ||
self.journal.update_amounts() | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:journal_details", kwargs={"j_id": self.journal.id}) | ||
|
||
def __getattribute__(self, attr): | ||
if attr == "target": | ||
return self.get_target() | ||
else: | ||
return object.__getattribute__(self, attr) | ||
|
||
def clean(self): | ||
super(Operation, self).clean() | ||
super().clean() | ||
if self.date is None: | ||
raise ValidationError(_("The date must be set.")) | ||
elif self.date < self.journal.start_date: | ||
|
@@ -410,12 +421,6 @@ def get_target(self): | |
tar = Company.objects.filter(id=self.target_id).first() | ||
return tar | ||
|
||
def save(self): | ||
if self.number is None: | ||
self.number = self.journal.operations.count() + 1 | ||
super(Operation, self).save() | ||
self.journal.update_amounts() | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -444,17 +449,6 @@ def can_be_edited_by(self, user): | |
return True | ||
return False | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:journal_details", kwargs={"j_id": self.journal.id}) | ||
|
||
def __str__(self): | ||
return "%d € | %s | %s | %s" % ( | ||
self.amount, | ||
self.date, | ||
self.accounting_type, | ||
self.done, | ||
) | ||
|
||
|
||
class AccountingType(models.Model): | ||
""" | ||
|
@@ -487,6 +481,12 @@ class Meta: | |
verbose_name = _("accounting type") | ||
ordering = ["movement_type", "code"] | ||
|
||
def __str__(self): | ||
return self.code + " - " + self.get_movement_type_display() + " - " + self.label | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:type_list") | ||
|
||
def is_owned_by(self, user): | ||
""" | ||
Method to see if that object can be edited by the given user | ||
|
@@ -497,12 +497,6 @@ def is_owned_by(self, user): | |
return True | ||
return False | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:type_list") | ||
|
||
def __str__(self): | ||
return self.code + " - " + self.get_movement_type_display() + " - " + self.label | ||
|
||
|
||
class SimplifiedAccountingType(models.Model): | ||
""" | ||
|
@@ -521,25 +515,22 @@ class Meta: | |
verbose_name = _("simplified type") | ||
ordering = ["accounting_type__movement_type", "accounting_type__code"] | ||
|
||
def __str__(self): | ||
return ( | ||
f"{self.get_movement_type_display()} " | ||
f"- {self.accounting_type.code} - {self.label}" | ||
) | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:simple_type_list") | ||
|
||
@property | ||
def movement_type(self): | ||
return self.accounting_type.movement_type | ||
|
||
def get_movement_type_display(self): | ||
return self.accounting_type.get_movement_type_display() | ||
|
||
def get_absolute_url(self): | ||
return reverse("accounting:simple_type_list") | ||
|
||
def __str__(self): | ||
return ( | ||
self.get_movement_type_display() | ||
+ " - " | ||
+ self.accounting_type.code | ||
+ " - " | ||
+ self.label | ||
) | ||
|
||
|
||
class Label(models.Model): | ||
"""Label allow a club to sort its operations""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding:utf-8 -* | ||
# | ||
# Copyright 2023 © AE UTBM | ||
# [email protected] / [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# -*- coding:utf-8 -* | ||
# | ||
# Copyright 2023 © AE UTBM | ||
# [email protected] / [email protected] | ||
|
Oops, something went wrong.