Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit c819cc89 authored by Levy--Falk Hugo's avatar Levy--Falk Hugo

typos, field inutiles, et documentation Google-style

parent d7b61c27
...@@ -118,6 +118,10 @@ class Migration(migrations.Migration): ...@@ -118,6 +118,10 @@ class Migration(migrations.Migration):
), ),
migrations.RunPython(add_comnpay), migrations.RunPython(add_comnpay),
migrations.RunPython(add_cheque), migrations.RunPython(add_cheque),
migrations.RunPython(add_solde) migrations.RunPython(add_solde),
migrations.RemoveField(
model_name='paiement',
name='type_paiement',
),
] ]
...@@ -554,9 +554,12 @@ class Article(RevMixin, AclMixin, models.Model): ...@@ -554,9 +554,12 @@ class Article(RevMixin, AclMixin, models.Model):
def can_buy_article(self, user, *_args, **_kwargs): def can_buy_article(self, user, *_args, **_kwargs):
"""Check if a user can buy this article. """Check if a user can buy this article.
:param self: The article Args:
:param user: The user requesting buying self: The article
:returns: A boolean stating if usage is granted and an explanation user: The user requesting buying
Returns:
A boolean stating if usage is granted and an explanation
message if the boolean is `False`. message if the boolean is `False`.
""" """
return ( return (
...@@ -569,7 +572,8 @@ class Article(RevMixin, AclMixin, models.Model): ...@@ -569,7 +572,8 @@ class Article(RevMixin, AclMixin, models.Model):
def find_allowed_articles(cls, user): def find_allowed_articles(cls, user):
"""Finds every allowed articles for an user. """Finds every allowed articles for an user.
:param user: The user requesting articles. Args:
user: The user requesting articles.
""" """
if user.has_perm('cotisations.buy_every_article'): if user.has_perm('cotisations.buy_every_article'):
return cls.objects.all() return cls.objects.all()
...@@ -604,7 +608,8 @@ class Banque(RevMixin, AclMixin, models.Model): ...@@ -604,7 +608,8 @@ class Banque(RevMixin, AclMixin, models.Model):
def check_no_balance(): def check_no_balance():
"""This functions checks that no Paiement with is_balance=True exists """This functions checks that no Paiement with is_balance=True exists
:raises ValidationError: if such a Paiement exists. Raises:
ValidationError: if such a Paiement exists.
""" """
p = Paiement.objects.filter(is_balance=True) p = Paiement.objects.filter(is_balance=True)
if len(p)>0: if len(p)>0:
...@@ -619,25 +624,13 @@ class Paiement(RevMixin, AclMixin, models.Model): ...@@ -619,25 +624,13 @@ class Paiement(RevMixin, AclMixin, models.Model):
invoice. It's easier to know this information when doing the accouts. invoice. It's easier to know this information when doing the accouts.
It is represented by: It is represented by:
* a name * a name
* a type (used for the type 'cheque' which implies the use of a bank
and an account number in related models)
""" """
PAYMENT_TYPES = (
(0, _l("Standard")),
(1, _l("Cheque")),
)
# TODO : change moyen to method # TODO : change moyen to method
moyen = models.CharField( moyen = models.CharField(
max_length=255, max_length=255,
verbose_name=_l("Method") verbose_name=_l("Method")
) )
type_paiement = models.IntegerField(
choices=PAYMENT_TYPES,
default=0,
verbose_name=_l("Payment type")
)
available_for_everyone = models.BooleanField( available_for_everyone = models.BooleanField(
default=False, default=False,
verbose_name=_l("Is available for every user") verbose_name=_l("Is available for every user")
...@@ -682,13 +675,15 @@ class Paiement(RevMixin, AclMixin, models.Model): ...@@ -682,13 +675,15 @@ class Paiement(RevMixin, AclMixin, models.Model):
""" """
The general way of ending a payment. The general way of ending a payment.
:param invoice: The invoice being created. Args:
:param request: Request sent by the user. invoice: The invoice being created.
:param use_payment_method: If `self` has an attribute `payment_method`, request: Request sent by the user.
returns the result of use_payment_method: If this flag is set to True and`self` has
`self.payment_method.end_payment(invoice, request)` an attribute `payment_method`, returns the result of
`self.payment_method.end_payment(invoice, request)`
:returns: An `HttpResponse`-like object. Returns:
An `HttpResponse`-like object.
""" """
payment_method = find_payment_method(self) payment_method = find_payment_method(self)
if payment_method is not None and use_payment_method: if payment_method is not None and use_payment_method:
...@@ -719,9 +714,11 @@ class Paiement(RevMixin, AclMixin, models.Model): ...@@ -719,9 +714,11 @@ class Paiement(RevMixin, AclMixin, models.Model):
def can_use_payment(self, user, *_args, **_kwargs): def can_use_payment(self, user, *_args, **_kwargs):
"""Check if a user can use this payment. """Check if a user can use this payment.
:param self: The payment Args:
:param user: The user requesting usage self: The payment
:returns: A boolean stating if usage is granted and an explanation user: The user requesting usage
Returns:
A boolean stating if usage is granted and an explanation
message if the boolean is `False`. message if the boolean is `False`.
""" """
return ( return (
...@@ -734,7 +731,8 @@ class Paiement(RevMixin, AclMixin, models.Model): ...@@ -734,7 +731,8 @@ class Paiement(RevMixin, AclMixin, models.Model):
def find_allowed_payments(cls, user): def find_allowed_payments(cls, user):
"""Finds every allowed payments for an user. """Finds every allowed payments for an user.
:param user: The user requesting payment methods. Args:
user: The user requesting payment methods.
""" """
if user.has_perm('cotisations.use_every_payment'): if user.has_perm('cotisations.use_every_payment'):
return cls.objects.all() return cls.objects.all()
......
...@@ -32,12 +32,14 @@ def payment_method_factory(payment, *args, creation=True, **kwargs): ...@@ -32,12 +32,14 @@ def payment_method_factory(payment, *args, creation=True, **kwargs):
it is the creation of the payment, a `PaymentMethodForm`. it is the creation of the payment, a `PaymentMethodForm`.
Else an empty form. Else an empty form.
:param payment: The payment Args:
:param *args: arguments passed to the form payment: The payment
:param creation: Should be True if you are creating the payment *args: arguments passed to the form
:param **kwargs: passed to the form creation: Should be True if you are creating the payment
**kwargs: passed to the form
:returns: A form Returns:
A form
""" """
payment_method = kwargs.pop('instance', find_payment_method(payment)) payment_method = kwargs.pop('instance', find_payment_method(payment))
if payment_method is not None: if payment_method is not None:
...@@ -60,7 +62,7 @@ class PaymentMethodForm(forms.Form): ...@@ -60,7 +62,7 @@ class PaymentMethodForm(forms.Form):
payment_method = forms.ChoiceField( payment_method = forms.ChoiceField(
label=_l("Special payment method"), label=_l("Special payment method"),
help_text=_l("Warning : You will not be able to change the payment " help_text=_l("Warning : You will not be able to change the payment "
"method later. But you will be allowed to edit its " "method later. But you will be allowed to edit the other "
"options." "options."
), ),
required=False required=False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment