mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 00:13:12 +00:00
Avoid failing when permissions depending on another model are None.
This commit is contained in:
parent
7edef7b722
commit
c4e8441718
2 changed files with 13 additions and 13 deletions
|
@ -138,7 +138,7 @@ class Facture(BaseInvoice):
|
||||||
abstract = False
|
abstract = False
|
||||||
permissions = (
|
permissions = (
|
||||||
# TODO : change facture to invoice
|
# TODO : change facture to invoice
|
||||||
("change_facture_control", _("Can edit the \"controlled\" state")),
|
("change_facture_control", _('Can edit the "controlled" state')),
|
||||||
("view_facture", _("Can view an invoice object")),
|
("view_facture", _("Can view an invoice object")),
|
||||||
("change_all_facture", _("Can edit all the previous invoices")),
|
("change_all_facture", _("Can edit all the previous invoices")),
|
||||||
)
|
)
|
||||||
|
@ -166,7 +166,7 @@ class Facture(BaseInvoice):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit this user's invoices."),
|
_("You don't have the right to edit this user's invoices."),
|
||||||
("cotisations.change_all_facture",) + permissions,
|
("cotisations.change_all_facture",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
elif not user_request.has_perm("cotisations.change_all_facture") and (
|
elif not user_request.has_perm("cotisations.change_all_facture") and (
|
||||||
self.control or not self.valid
|
self.control or not self.valid
|
||||||
|
@ -198,7 +198,7 @@ class Facture(BaseInvoice):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to delete this user's invoices."),
|
_("You don't have the right to delete this user's invoices."),
|
||||||
("cotisations.change_all_facture",) + permissions,
|
("cotisations.change_all_facture",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
elif not user_request.has_perm("cotisations.change_all_facture") and (
|
elif not user_request.has_perm("cotisations.change_all_facture") and (
|
||||||
self.control or not self.valid
|
self.control or not self.valid
|
||||||
|
@ -243,7 +243,7 @@ class Facture(BaseInvoice):
|
||||||
can = user_request.has_perm("cotisations.change_facture_control")
|
can = user_request.has_perm("cotisations.change_facture_control")
|
||||||
return (
|
return (
|
||||||
can,
|
can,
|
||||||
_("You don't have the right to edit the \"controlled\" state.")
|
_('You don\'t have the right to edit the "controlled" state.')
|
||||||
if not can
|
if not can
|
||||||
else None,
|
else None,
|
||||||
("cotisations.change_facture_control",),
|
("cotisations.change_facture_control",),
|
||||||
|
@ -297,21 +297,21 @@ class Facture(BaseInvoice):
|
||||||
for purchase in self.vente_set.all():
|
for purchase in self.vente_set.all():
|
||||||
if hasattr(purchase, "cotisation"):
|
if hasattr(purchase, "cotisation"):
|
||||||
cotisation = purchase.cotisation
|
cotisation = purchase.cotisation
|
||||||
if cotisation.type_cotisation == 'Connexion':
|
if cotisation.type_cotisation == "Connexion":
|
||||||
cotisation.date_start = date_con
|
cotisation.date_start = date_con
|
||||||
date_con += relativedelta(
|
date_con += relativedelta(
|
||||||
months=(purchase.duration or 0) * purchase.number,
|
months=(purchase.duration or 0) * purchase.number,
|
||||||
days=(purchase.duration_days or 0) * purchase.number,
|
days=(purchase.duration_days or 0) * purchase.number,
|
||||||
)
|
)
|
||||||
cotisation.date_end = date_con
|
cotisation.date_end = date_con
|
||||||
elif cotisation.type_cotisation == 'Adhesion':
|
elif cotisation.type_cotisation == "Adhesion":
|
||||||
cotisation.date_start = date_adh
|
cotisation.date_start = date_adh
|
||||||
date_adh += relativedelta(
|
date_adh += relativedelta(
|
||||||
months=(purchase.duration or 0) * purchase.number,
|
months=(purchase.duration or 0) * purchase.number,
|
||||||
days=(purchase.duration_days or 0) * purchase.number,
|
days=(purchase.duration_days or 0) * purchase.number,
|
||||||
)
|
)
|
||||||
cotisation.date_end = date_adh
|
cotisation.date_end = date_adh
|
||||||
else: # it is assumed that adhesion is required for a connexion
|
else: # it is assumed that adhesion is required for a connexion
|
||||||
date = min(date_adh, date_con)
|
date = min(date_adh, date_con)
|
||||||
cotisation.date_start = date
|
cotisation.date_start = date
|
||||||
date_adh += relativedelta(
|
date_adh += relativedelta(
|
||||||
|
@ -566,7 +566,7 @@ class Vente(RevMixin, AclMixin, models.Model):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit this user's purchases."),
|
_("You don't have the right to edit this user's purchases."),
|
||||||
("cotisations.change_all_facture",) + permissions,
|
("cotisations.change_all_facture",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
elif not user_request.has_perm("cotisations.change_all_vente") and (
|
elif not user_request.has_perm("cotisations.change_all_vente") and (
|
||||||
self.facture.control or not self.facture.valid
|
self.facture.control or not self.facture.valid
|
||||||
|
|
|
@ -178,7 +178,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, AclMixin, models.Model):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit a machine of another" " user."),
|
_("You don't have the right to edit a machine of another" " user."),
|
||||||
("machines.change_interface",) + permissions,
|
("machines.change_interface",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, AclMixin, models.Model):
|
||||||
"You don't have the right to delete a machine"
|
"You don't have the right to delete a machine"
|
||||||
" of another user."
|
" of another user."
|
||||||
),
|
),
|
||||||
("machines.change_interface",) + permissions,
|
("machines.change_interface",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
@ -1344,7 +1344,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit a machine of another" " user."),
|
_("You don't have the right to edit a machine of another" " user."),
|
||||||
("machines.change_interface",) + permissions,
|
("machines.change_interface",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
@ -1362,7 +1362,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit a machine of another" " user."),
|
_("You don't have the right to edit a machine of another" " user."),
|
||||||
("machines.change_interface",) + permissions,
|
("machines.change_interface",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
@ -1482,7 +1482,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
_("You don't have the right to edit a machine of another user."),
|
_("You don't have the right to edit a machine of another user."),
|
||||||
("machines.change_ipv6list",) + permissions,
|
("machines.change_ipv6list",) + (permissions or ()),
|
||||||
)
|
)
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue