mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 08:23:12 +00:00
Merge branch 'fix-validators-positiveinteger' into 'dev'
Fix validators positiveinteger See merge request re2o/re2o!579
This commit is contained in:
commit
aea9398f34
2 changed files with 96 additions and 28 deletions
59
cotisations/migrations/0051_auto_20201228_1636.py
Normal file
59
cotisations/migrations/0051_auto_20201228_1636.py
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.29 on 2020-12-28 15:36
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("cotisations", "0050_auto_20201102_2342"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="article",
|
||||||
|
name="duration_connection",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
verbose_name="duration of the connection (in months)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="article",
|
||||||
|
name="duration_days_connection",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
verbose_name="duration of the connection (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="article",
|
||||||
|
name="duration_days_membership",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
verbose_name="duration of the membership (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="article",
|
||||||
|
name="duration_membership",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
verbose_name="duration of the membership (in months)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="vente",
|
||||||
|
name="duration_days_connection",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
default=0,
|
||||||
|
verbose_name="duration of the connection (in days, will be added to duration in months)",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="vente",
|
||||||
|
name="duration_days_membership",
|
||||||
|
field=models.PositiveIntegerField(
|
||||||
|
default=0,
|
||||||
|
verbose_name="duration of the membership (in days, will be added to duration in months)",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -293,8 +293,7 @@ class Facture(BaseInvoice):
|
||||||
"""Returns every subscription associated with this invoice."""
|
"""Returns every subscription associated with this invoice."""
|
||||||
return Cotisation.objects.filter(
|
return Cotisation.objects.filter(
|
||||||
vente__in=self.vente_set.filter(
|
vente__in=self.vente_set.filter(
|
||||||
~(Q(duration_membership=0)) |\
|
~(Q(duration_membership=0)) | ~(Q(duration_days_membership=0))
|
||||||
~(Q(duration_days_membership=0))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -467,16 +466,18 @@ class Vente(RevMixin, AclMixin, models.Model):
|
||||||
)
|
)
|
||||||
duration_days_connection = models.PositiveIntegerField(
|
duration_days_connection = models.PositiveIntegerField(
|
||||||
default=0,
|
default=0,
|
||||||
validators=[MinValueValidator(0)],
|
verbose_name=_(
|
||||||
verbose_name=_("duration of the connection (in days, will be added to duration in months)"),
|
"duration of the connection (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
duration_membership = models.PositiveIntegerField(
|
duration_membership = models.PositiveIntegerField(
|
||||||
default=0, verbose_name=_("duration of the membership (in months)")
|
default=0, verbose_name=_("duration of the membership (in months)")
|
||||||
)
|
)
|
||||||
duration_days_membership = models.PositiveIntegerField(
|
duration_days_membership = models.PositiveIntegerField(
|
||||||
default=0,
|
default=0,
|
||||||
validators=[MinValueValidator(0)],
|
verbose_name=_(
|
||||||
verbose_name=_("duration of the membership (in days, will be added to duration in months)"),
|
"duration of the membership (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -631,12 +632,14 @@ class Vente(RevMixin, AclMixin, models.Model):
|
||||||
return str(self.name) + " " + str(self.facture)
|
return str(self.name) + " " + str(self.facture)
|
||||||
|
|
||||||
def test_membership_or_connection(self):
|
def test_membership_or_connection(self):
|
||||||
""" Test if the purchase include membership or connecton
|
"""Test if the purchase include membership or connecton"""
|
||||||
"""
|
return (
|
||||||
return self.duration_membership or \
|
self.duration_membership
|
||||||
self.duration_days_membership or \
|
or self.duration_days_membership
|
||||||
self.duration_connection or \
|
or self.duration_connection
|
||||||
self.duration_days_connection
|
or self.duration_days_connection
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO : change vente to purchase
|
# TODO : change vente to purchase
|
||||||
@receiver(post_save, sender=Vente)
|
@receiver(post_save, sender=Vente)
|
||||||
|
@ -704,20 +707,20 @@ class Article(RevMixin, AclMixin, models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
duration_membership = models.PositiveIntegerField(
|
duration_membership = models.PositiveIntegerField(
|
||||||
validators=[MinValueValidator(0)],
|
|
||||||
verbose_name=_("duration of the membership (in months)")
|
verbose_name=_("duration of the membership (in months)")
|
||||||
)
|
)
|
||||||
duration_days_membership = models.PositiveIntegerField(
|
duration_days_membership = models.PositiveIntegerField(
|
||||||
validators=[MinValueValidator(0)],
|
verbose_name=_(
|
||||||
verbose_name=_("duration of the membership (in days, will be added to duration in months)"),
|
"duration of the membership (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
duration_connection = models.PositiveIntegerField(
|
duration_connection = models.PositiveIntegerField(
|
||||||
validators=[MinValueValidator(0)],
|
|
||||||
verbose_name=_("duration of the connection (in months)")
|
verbose_name=_("duration of the connection (in months)")
|
||||||
)
|
)
|
||||||
duration_days_connection = models.PositiveIntegerField(
|
duration_days_connection = models.PositiveIntegerField(
|
||||||
validators=[MinValueValidator(0)],
|
verbose_name=_(
|
||||||
verbose_name=_("duration of the connection (in days, will be added to duration in months)"),
|
"duration of the connection (in days, will be added to duration in months)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
need_membership = models.BooleanField(
|
need_membership = models.BooleanField(
|
||||||
|
@ -884,7 +887,9 @@ class Paiement(RevMixin, AclMixin, models.Model):
|
||||||
|
|
||||||
# In case a cotisation was bought, inform the user, the
|
# In case a cotisation was bought, inform the user, the
|
||||||
# cotisation time has been extended too
|
# cotisation time has been extended too
|
||||||
if any(sell.test_membership_or_connection() for sell in invoice.vente_set.all()):
|
if any(
|
||||||
|
sell.test_membership_or_connection() for sell in invoice.vente_set.all()
|
||||||
|
):
|
||||||
messages.success(
|
messages.success(
|
||||||
request,
|
request,
|
||||||
_(
|
_(
|
||||||
|
@ -956,9 +961,13 @@ class Cotisation(RevMixin, AclMixin, models.Model):
|
||||||
vente = models.OneToOneField(
|
vente = models.OneToOneField(
|
||||||
"Vente", on_delete=models.CASCADE, null=True, verbose_name=_("purchase")
|
"Vente", on_delete=models.CASCADE, null=True, verbose_name=_("purchase")
|
||||||
)
|
)
|
||||||
date_start_con = models.DateTimeField(verbose_name=_("start date for the connection"))
|
date_start_con = models.DateTimeField(
|
||||||
|
verbose_name=_("start date for the connection")
|
||||||
|
)
|
||||||
date_end_con = models.DateTimeField(verbose_name=_("end date for the connection"))
|
date_end_con = models.DateTimeField(verbose_name=_("end date for the connection"))
|
||||||
date_start_memb = models.DateTimeField(verbose_name=_("start date for the membership"))
|
date_start_memb = models.DateTimeField(
|
||||||
|
verbose_name=_("start date for the membership")
|
||||||
|
)
|
||||||
date_end_memb = models.DateTimeField(verbose_name=_("end date for the membership"))
|
date_end_memb = models.DateTimeField(verbose_name=_("end date for the membership"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in a new issue