mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
Rename fields in cotisations.Cotisation
This commit is contained in:
parent
4906fa8842
commit
ef4d6a57e6
2 changed files with 26 additions and 7 deletions
20
cotisations/migrations/0042_auto_20190325_0840.py
Normal file
20
cotisations/migrations/0042_auto_20190325_0840.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2019-03-25 07:40
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cotisations', '0041_auto_20190325_0837'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='cotisation',
|
||||||
|
old_name='vente',
|
||||||
|
new_name='purchase',
|
||||||
|
),
|
||||||
|
]
|
|
@ -872,8 +872,7 @@ class Cotisation(RevMixin, AclMixin, models.Model):
|
||||||
('All', _("Both of them")),
|
('All', _("Both of them")),
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO : change vente to purchase
|
purchase = models.OneToOneField(
|
||||||
vente = models.OneToOneField(
|
|
||||||
'Vente',
|
'Vente',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
null=True,
|
null=True,
|
||||||
|
@ -903,8 +902,8 @@ class Cotisation(RevMixin, AclMixin, models.Model):
|
||||||
if not user_request.has_perm('cotisations.change_cotisation'):
|
if not user_request.has_perm('cotisations.change_cotisation'):
|
||||||
return False, _("You don't have the right to edit a subscription.")
|
return False, _("You don't have the right to edit a subscription.")
|
||||||
elif not user_request.has_perm('cotisations.change_all_cotisation') \
|
elif not user_request.has_perm('cotisations.change_all_cotisation') \
|
||||||
and (self.vente.invoice.control or
|
and (self.purchase.invoice.control or
|
||||||
not self.vente.invoice.valid):
|
not self.purchase.invoice.valid):
|
||||||
return False, _("You don't have the right to edit a subscription "
|
return False, _("You don't have the right to edit a subscription "
|
||||||
"already controlled or invalidated.")
|
"already controlled or invalidated.")
|
||||||
else:
|
else:
|
||||||
|
@ -914,7 +913,7 @@ class Cotisation(RevMixin, AclMixin, models.Model):
|
||||||
if not user_request.has_perm('cotisations.delete_cotisation'):
|
if not user_request.has_perm('cotisations.delete_cotisation'):
|
||||||
return False, _("You don't have the right to delete a "
|
return False, _("You don't have the right to delete a "
|
||||||
"subscription.")
|
"subscription.")
|
||||||
if self.vente.invoice.control or not self.vente.invoice.valid:
|
if self.purchase.invoice.control or not self.purchase.invoice.valid:
|
||||||
return False, _("You don't have the right to delete a subscription "
|
return False, _("You don't have the right to delete a subscription "
|
||||||
"already controlled or invalidated.")
|
"already controlled or invalidated.")
|
||||||
else:
|
else:
|
||||||
|
@ -922,14 +921,14 @@ class Cotisation(RevMixin, AclMixin, models.Model):
|
||||||
|
|
||||||
def can_view(self, user_request, *_args, **_kwargs):
|
def can_view(self, user_request, *_args, **_kwargs):
|
||||||
if not user_request.has_perm('cotisations.view_cotisation') and\
|
if not user_request.has_perm('cotisations.view_cotisation') and\
|
||||||
self.vente.invoice.user != user_request:
|
self.purchase.invoice.user != user_request:
|
||||||
return False, _("You don't have the right to view someone else's "
|
return False, _("You don't have the right to view someone else's "
|
||||||
"subscription history.")
|
"subscription history.")
|
||||||
else:
|
else:
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.vente)
|
return str(self.purchase)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Cotisation)
|
@receiver(post_save, sender=Cotisation)
|
||||||
|
|
Loading…
Reference in a new issue