mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 08:32:26 +00:00
Merge branch 'Fix_116' into 'master'
Fix #116: Remove default SOA in Extension & Force reversion context Closes #116 See merge request federez/re2o!147
This commit is contained in:
commit
e064db626d
2 changed files with 8 additions and 5 deletions
|
@ -541,8 +541,7 @@ class Extension(RevMixin, AclMixin, models.Model):
|
|||
)
|
||||
soa = models.ForeignKey(
|
||||
'SOA',
|
||||
on_delete=models.CASCADE,
|
||||
default=SOA.new_default_soa
|
||||
on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -24,6 +24,7 @@ A set of mixins used all over the project to avoid duplicating code
|
|||
"""
|
||||
|
||||
from reversion import revisions as reversion
|
||||
from django.db import transaction
|
||||
|
||||
|
||||
class RevMixin(object):
|
||||
|
@ -33,13 +34,16 @@ class RevMixin(object):
|
|||
def save(self, *args, **kwargs):
|
||||
""" Creates a version of this object and save it to database """
|
||||
if self.pk is None:
|
||||
reversion.set_comment("Création")
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
reversion.set_comment("Création")
|
||||
return super(RevMixin, self).save(*args, **kwargs)
|
||||
return super(RevMixin, self).save(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
""" Creates a version of this object and delete it from database """
|
||||
reversion.set_comment("Suppresion")
|
||||
return super(RevMixin, self).delete(*args, **kwargs)
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
reversion.set_comment("Suppresion")
|
||||
return super(RevMixin, self).delete(*args, **kwargs)
|
||||
|
||||
|
||||
class FormRevMixin(object):
|
||||
|
|
Loading…
Reference in a new issue